Esempio n. 1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            m_TheMouse.Update();

            switch (getGameState())
            {
                case eGameState.MENU:
                    setGameState(m_MainMenu.update());
                    break;

                case eGameState.QUITTING:
                    Exit();
                    break;

                case eGameState.ENTER_SERVERLOBBY:
                    m_GameServer = new cGameServer();
                    m_GameServer.waitForConnection();

                    m_GameClient = new cGameClient();
                    m_GameClient.connect("127.0.0.1");

                    while (!m_GameClient.isConnected());

                    setGameState(eGameState.SERVERLOBBY);
                    break;

                case eGameState.SERVERLOBBY:
                    m_GameClient.sendData(new cInitGameMsg(m_GameClient.getPlayerID(), 15, 15, false, eGAME_TYPE.SOLO));
                    setGameState(eGameState.RUNNING);
                    break;

                case eGameState.RUNNING:

                        m_GameServer.tick(gameTime);
                    break;

            }

            // TODO: Add your update logic here

            base.Update(gameTime);
        }