spaceconquest.MapSelectScreen.ClickLoadMapStart C# (CSharp) Method

ClickLoadMapStart() public method

public ClickLoadMapStart ( Object o, EventArgs e ) : void
o Object
e System.EventArgs
return void
        public void ClickLoadMapStart(Object o, EventArgs e)
        {
            if (loadpath == null)
            {
                if (host) { MenuManager.screen = new GameScreen(true, "127.0.0.1", 1, null); }
                else { MenuManager.ClickNewGame(o, e); }
            }
            else
            {
                Map map = null;
                FileStream fs = null;
                try
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    fs = new FileStream(loadpath, FileMode.Open);
                    map = (Map)formatter.Deserialize(fs);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    map = null;
                }
                finally
                {
                    if (fs != null) fs.Close();
                    if (host) { MenuManager.screen = new GameScreen(true, "127.0.0.1", map.players.Count-1, map); }
                    else { MenuManager.screen = new GameScreen(true, null, 0, map); }
                }
            }
        }