Esempio n. 1
0
        public void Update()
        {
            if (m_manager_state != DrawableState.Finished)
            {
                if (m_currScene == null)
                {
                    m_currScene      = m_sceneQ.Dequeue(); // Grab the first animation
                    m_curr_scene_num = 0;
                }
                else if (m_currScene.Scene_State == DrawableState.Finished)
                {
                    if (m_sceneQ.Count == 0)      // Ran out of scenes to perform, reset stuff
                    {
                        m_currScene.ResetScene(); // So it wont stay finished for the next time around
                        m_manager_state  = DrawableState.Finished;
                        m_currScene      = null;
                        m_curr_scene_num = -1;
                        return;
                    }
                    else // On to the next animation
                    {
                        m_curr_scene_num++;
                        m_currScene.ResetScene(); // So it wont stay finished for the next time around
                        m_currScene = m_sceneQ.Dequeue();
                    }
                }

                // Update current Animation
                m_currScene.Update();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                    bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, false);

            // Gradually fade in or out depending on whether we are covered by the pause screen.
            if (coveredByOtherScreen)
            {
                pauseAlpha = Math.Min(pauseAlpha + 1f / 32, 1);
            }
            else
            {
                pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0);
            }

            if (!otherScreenHasFocus)
            {
                m_paused = false;
            }

            if (!m_paused)
            {
                if (m_intro.Scene_State != DrawableState.Finished)
                {
                    if (!m_played_intro)
                    {
                        startround.Play();
                        m_played_intro = true;
                    }
                    m_intro.Update();
                }
                if (m_intro.Scene_State == DrawableState.Finished &&
                    m_ducks.BallsAlive())
                {
                    m_ducks.UpdateBalls(m_player1.CData, m_player2.CData, m_clouds);
                }

                if (m_intro.Scene_State == DrawableState.Finished &&
                    m_ducks.BallsDead())
                {
                    if (m_ducks.DuckOneState == BallState.DeadBall && m_ducks.DuckOneDir == Direction.Right)
                    {
                        m_player1.ScoreNum += 1;
                    }
                    else if (m_ducks.DuckOneState == BallState.DeadBall && m_ducks.DuckOneDir == Direction.Left)
                    {
                        m_player2.ScoreNum += 1;
                    }

                    if (m_ducks.DuckTwoState == BallState.DeadBall && m_ducks.DuckTwoDir == Direction.Right)
                    {
                        m_player1.ScoreNum += 1;
                    }
                    else if (m_ducks.DuckTwoState == BallState.DeadBall && m_ducks.DuckTwoDir == Direction.Left)
                    {
                        m_player2.ScoreNum += 1;
                    }


                    m_ducks.BuildIntermission();
                }

                if (m_intro.Scene_State == DrawableState.Finished &&
                    m_ducks.Intermission())
                {
                    m_ducks.UpdateIntermission();
                }
                else if (!m_ducks.Intermission() &&
                         m_ducks.BallsLimbo())
                {
                    m_ducks.ReleaseDuck();
                }

                if (m_intro.Scene_State == DrawableState.Finished)
                {
                    m_flash.Update();
                    m_clouds_p1.Update();
                    m_clouds_p2.Update();

                    m_clouds[0] = m_clouds_p1.CloudsA[0];
                    m_clouds[1] = m_clouds_p1.CloudsA[1];
                    m_clouds[2] = m_clouds_p1.CloudsA[2];
                    m_clouds[3] = m_clouds_p2.CloudsA[0];
                    m_clouds[4] = m_clouds_p2.CloudsA[1];
                    m_clouds[5] = m_clouds_p2.CloudsA[2];

                    m_duck1_flash.Update();
                    m_duck1_flash.X_Pos = m_ducks.DuckOneRectangle.X;
                    m_duck1_flash.Y_Pos = m_ducks.DuckOneRectangle.Y;
                    m_duck2_flash.Update();
                    m_duck2_flash.X_Pos = m_ducks.DuckOneRectangle.X;
                    m_duck2_flash.Y_Pos = m_ducks.DuckOneRectangle.Y;
                    m_ducks.UpdateCounter();
                    m_player1.UpdateItems();
                    m_player2.UpdateItems();

                    if (m_ducks.DuckOneState == BallState.Active)
                    {
                        m_ducks.DuckOneXVelocity += m_ducks.DuckOneXVelocity * 0.0001f;
                        m_ducks.DuckOneYVelocity += m_ducks.DuckOneYVelocity * 0.0001f;
                    }
                    else if (m_ducks.DuckTwoState == BallState.Active)
                    {
                        m_ducks.DuckTwoXVelocity += m_ducks.DuckTwoXVelocity * 0.0001f;
                        m_ducks.DuckTwoYVelocity += m_ducks.DuckTwoYVelocity * 0.0001f;
                    }
                }

                if (!m_built_ending && m_ducks.GameOver())
                {
                    endround.Play();
                    m_endround.Start(4);
                    m_ducks.SetAllDucksToBlink();
                    m_built_ending = true;
                }
                if (m_endround.isRunning && m_endround.CheckTime(gameTime))
                {
                    ScreenManager.AddScreen(new DuckHuntGameOverMenuScreen(this), null);
                    m_paused = true;
                }
            }
        }