コード例 #1
0
ファイル: Game1.cs プロジェクト: rebider/Ocean-Scream
        protected override void Update(GameTime gameTime)
        {
            InputState.UpdateInput(this);
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                if (currentServer != null)
                {
                    currentServer.finalStop();
                }
                if (requestManager != null)
                {
                    requestManager.clearAll();
                }

                this.Exit();
            }
            switch (GameState.currentGameState)
            {
            case GameState.State.PlayerVsAI:
                world.Update(gameTime);
                //by 李翔
                if (currentServer.canGameStart)
                {
                    LabelManager.currentLabelState = LabelManager.LabelState.InGame;
                }
                if (LabelManager.currentLabelState == LabelManager.LabelState.WaitForConnect)
                {
                    lableManager.WaitForConnectLabel.GetAIConncted = currentServer.connectNumber;
                }
                lableManager.Update(gameTime);
                break;

            case GameState.State.AIVsAI:
                world.Update(gameTime);
                //by 李翔
                if (lastTime - world.timeManager.FullMilisecond >= 500)
                {
                    repController.recordState();
                    lastTime = world.timeManager.FullMilisecond;
                }
                if (currentServer.canGameStart)
                {
                    LabelManager.currentLabelState = LabelManager.LabelState.InGame;
                }
                if (LabelManager.currentLabelState == LabelManager.LabelState.WaitForConnect)
                {
                    lableManager.WaitForConnectLabel.GetAIConncted = currentServer.connectNumber;
                }
                lableManager.Update(gameTime);
                break;

            case GameState.State.Video:
                repController.Update(gameTime);
                world.Update(gameTime);
                LabelManager.currentLabelState = LabelManager.LabelState.InGame;
                lableManager.Update(gameTime);
                break;

            case GameState.State.Menu:
                startMenu.Update(gameTime);
                break;

            case GameState.State.Exit:
                this.Exit();
                break;
            }
            if (world != null && world.IsGameEnd)
            {
                if (currentServer != null)
                {
                    currentServer.stop();
                    currentServer.finalStop();
                }
                world.timeManager.Stop();
                if (repController != null)
                {
                    if (!ReplayController.Enalble && SaveReplayFlag)
                    {
                        repController.recordState();
                        repController.saveReplay();
                    }
                }

                if (InputState.IsKeyPressed(Keys.Enter))
                {
                    LabelManager.currentLabelState = LabelManager.LabelState.Menu;
                    GameState.currentGameState     = GameState.State.Menu;
                }
            }

            base.Update(gameTime);
        }