Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        private void ExitLobby()
        {
            if (IsHosted)
            {
                TcpAsyncServer.StopInterfaceListening();
                _udpServer.StopListen();
                TcpAsyncServer.SafeCloseAllSockets();
            }
            else
            {
                _client.Client.Socket.Close();
            }

            Game.SceneManager.ActiveState = GameState.MainMenu;
        }