public GameLobby(bool isHosted, string clientName) { IsHosted = isHosted; ClientName = clientName; if (IsHosted) { LobbyMenu = new Menu ( Position.Bottom, Align.Center, Fonts.RegularConsolas16, ("Start Game", ActionType.Update, () => { ((GDarts)Game.SceneManager[GameState.Game]).Client = _client; ((GDarts)Game.SceneManager[GameState.Game]).ClientName = ClientName; ((GDarts)Game.SceneManager[GameState.Game]).StartGame(true); TcpAsyncServer.StopInterfaceListening(); _udpServer.StopListen(); Game.SceneManager.ActiveState = GameState.Game; } ), ("Exit Lobby", ActionType.Update, ExitLobby) ); } else { LobbyMenu = new Menu(Position.Bottom, Align.Center, Fonts.RegularConsolas16, ("Exit Lobby", ActionType.Update, ExitLobby)); } }
private void ExitLobby() { if (IsHosted) { TcpAsyncServer.StopInterfaceListening(); _udpServer.StopListen(); TcpAsyncServer.SafeCloseAllSockets(); } else { _client.Client.Socket.Close(); } Game.SceneManager.ActiveState = GameState.MainMenu; }