コード例 #1
0
ファイル: Game1.cs プロジェクト: acdcfanbill/SolarSailor
        /// <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();
            // TODO: Add your update logic here
            switch (currentGameState)
            {
                case GameState.StartUp:
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    hud.Enabled = false;
                    hud.Visible = false;
                    if(!menuCue.IsPlaying)
                        menuCue.Play();
                    break;
                case GameState.MainMenu:
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    hud.Enabled = false;
                    hud.Visible = false;
                    if (menuCue.IsPaused)
                    {
                        menuCue.Resume();
                    }
                    break;
                case GameState.NewGame:
                    modelManager = new ModelManager(this);
                    hud = new HUD(this);
                    hud.newDelivery();
                    Components.Add(modelManager);
                    Components.Add(hud);
                    currentGameState = GameState.InGame;
                    menuCue.Pause();
                    if (trackCue.IsPaused)
                        trackCue.Resume();
                    else
                        trackCue.Play();
                    break;
                case GameState.InGame:
                    if (!hud.start || hud.Enabled == false)
                    {
                        modelManager.Enabled = false;
                        modelManager.Visible = true;
                        hud.Enabled = true;
                        hud.Visible = true;
                    }
                    else { modelManager.Enabled = true; }
                    menuCue.Pause();
                    if (trackCue.IsPaused)
                        trackCue.Resume();
                    hud.Update(gameTime);
                    break;
                case GameState.PauseMenu:
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    hud.Enabled = false;
                    hud.Visible = false;
                    if (menuCue.IsPaused)
                    {
                        menuCue.Resume();
                    }
                    trackCue.Pause();
                    break;
                case GameState.Credits:
                    //spriteManager.Enabled = false;
                    //spriteManager.Visible = false;

                    break;
                case GameState.GameOver:
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    hud.Enabled = false;
                    hud.Visible = false;
                    Components.Remove(hud);
                    Components.Remove(modelManager);
                    trackCue.Pause();
                    break;
                case GameState.YouWin:
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    hud.Enabled = false;
                    hud.Visible = false;
                    Components.Remove(hud);
                    Components.Remove(modelManager);
                    trackCue.Pause();
                    break;
                case GameState.GameExit:
                    this.Exit();
                    break;
            }
            audioEngine.Update();
            base.Update(gameTime);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: acdcfanbill/SolarSailor
        /// <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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            camera = new Camera(this, new Vector3(5, -5, 15), Vector3.Zero, Vector3.Up, _fov);
            Components.Add(camera);

            menu = new Menus(this);
            Components.Add(menu);
            modelManager = new ModelManager(this);
            Components.Add(modelManager);
            hud = new HUD(this);
            Components.Add(hud);
            skyBox = new SkyBox(this);
            Components.Add(skyBox);
            currentGameState = GameState.StartUp;

            base.Initialize();
        }