示例#1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // input helper
            Components.Add(new Xin(this));

            // fps counter
            fpsCounter = new FrameRateCounter(this);
            Components.Add(fpsCounter);
            fpsCounter.IsVisible = settings.fpsCounter;

            // state manager
            gameStateManager = new GameStateManager(this);
            Components.Add(gameStateManager);

            // TODO: remove this when the game menu is implemented
            switch (settings.gameMode)
            {
            case GameMode.AI:
                playState = PlayState.CreateAIGame(this);
                break;

            case GameMode.Singleplayer:
                playState = PlayState.CreateSinglePlayerGame(this);
                break;

            case GameMode.Multiplayer:
                playState = PlayState.CreateLocalMultiPlayerGame(this);
                break;

            default:
                Exit();     //stop the game if somehow the mode is not one of those
                break;
            }

            gameStateManager.ChangeState(playState);

            base.Initialize();
        }