예제 #1
0
파일: Player.cs 프로젝트: jordanell/Blocker
        public Player(Game game, SpriteBatch spriteBatch, Rectangle position, Level level)
            : base(game, spriteBatch, position)
        {
            this.level = level;
            this.State = PlayerState.Idle;

            Initialize();
        }
예제 #2
0
        /// <summary>
        /// Performs a transistion from level to level. Save the highest level if needed and
        /// move onto next level or end game scene.
        /// </summary>
        private void LevelComplete()
        {
            // Save if highest level has been obtained
            if (level.LevelNumber > FileHandler.TopLevel())
                FileHandler.Save(level.LevelNumber);

            // Go to end game scene
            if (level.LevelNumber == 25)
            {
                level = null;
                endGame = new EndGame(game, spriteBatch);
                state = ManagerState.EndGame;
                SoundMixer.Instance(game).PlayWinner(false);
            }
            // Go to next level
            else
            {
                int nextLevel = level.LevelNumber + 1;
                level = null;
                level = new Level(game, spriteBatch, nextLevel);
                state = ManagerState.Level;
                SoundMixer.Instance(game).PlayLevelComplete(false);
            }
        }
예제 #3
0
        /// <summary>
        /// Allows the Manager to update itself. Updates are dependant on the 
        /// current state of the Manager
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // Update the background when not in splash screen
            if (state != ManagerState.Splash)
                background.Update(gameTime);

            // Update based on state
            if (state == ManagerState.Splash)
            {
                splash.Update(gameTime);

                // Go to main menu
                if (splash.Complete)
                {
                    menu = new Menu(game, spriteBatch);
                    splash = null;
                    state = ManagerState.Menu;
                    return;
                }
            }
            else if (state == ManagerState.Menu)
            {
                menu.Update(gameTime);

                // Go to level selected
                if (menu.LoadLevel)
                {
                    level = new Level(game, spriteBatch, menu.LevelNumber);
                    menu = null;
                    state = ManagerState.Level;
                    return;
                }
            }

            else if (state == ManagerState.Level)
            {
                level.Update(gameTime);

                // Go to main menu
                if (level.Quit)
                {
                    menu = new Menu(game, spriteBatch);
                    level = null;
                    state = ManagerState.Menu;
                    return;
                }

                // Go to next level
                else if (level.Complete)
                    LevelComplete();
            }
            else if (state == ManagerState.EndGame)
            {
                endGame.Update(gameTime);

                // Go to main menu
                if (endGame.Complete)
                {
                    menu = new Menu(game, spriteBatch);
                    splash = null;
                    state = ManagerState.Menu;
                    return;
                }
            }

            base.Update(gameTime);
        }