示例#1
0
文件: Level.cs 项目: hk222gn/Supesu
        public virtual void Update(GameTime gameTime)
        {
            //Checks and changes the current wave in the level.
            GameStageHandler();

            //Checks if the player gets hit, or hits anything with his bullets.
            CheckBulletCollision();

            //If there is no bonus monster, take care of it.
            HandleBonusMonster();

            //Updates the bullets position, anda removes it if it hits the top of the screen.
            for (int i = 0; i < bullets.Count; i++)
            {
                if (!bullets[i].alive)
                {
                    bullets.Remove(bullets[i]);
                }
                else
                {
                    bullets[i].Update(gameTime.ElapsedGameTime.Milliseconds);
                }
            }

            //If there is a bonus monster, run his update method instead.
            if (bonusMonster != null)
            {
                bonusMonster.Update(gameTime, game.Window.ClientBounds);
            }

            if (!ship.alive)
            {
                stage = CurrentLevelStage.none;
                return;
            }

            //Checks if the enemies went too far down.
            for (int i = 0; i < enemyList.Count; i++)
            {
                if (enemyList[i].position.Y > 580)
                {
                    ship.alive = false;
                }
            }

            //Updates the ships position, and which frame to draw.
            ship.Update(gameTime, game.Window.ClientBounds);

            CheckForDeadEnemies(gameTime);

            HandleScoreMultiplier();

            //Updates the bullets position, and removes it if it hits the top of the screen.
            for (int i = 0; i < Level.shipBullets.Count; i++)
            {
                if (!Level.shipBullets[i].alive)
                {
                    Level.shipBullets.Remove(Level.shipBullets[i]);
                }
                else
                {
                    Level.shipBullets[i].Update(gameTime.ElapsedGameTime.Milliseconds);
                }
            }

            Sprite.move += (float)game.TargetElapsedTime.TotalSeconds;

            MoveSprites();

            if (enemyList.Count > 0)
            {
                EnemyShoot();
            }
        }
示例#2
0
文件: Level.cs 项目: hk222gn/Supesu
        public virtual void GameStageHandler()
        {
            //Handles the different stages in a level.
            switch (stage)
            {
                case CurrentLevelStage.enemyStage1:

                    if (!stage1Initialized)
                    {
                        InitializeStage1();
                        stage1Initialized = true;
                    }

                    if (enemyList.Count == 0)
                    {
                        stage = CurrentLevelStage.enemyStage2;
                    }
                    break;
                case CurrentLevelStage.enemyStage2:

                    if (!stage2Initialized)
                    {
                        InitializeStage2();
                        stage2Initialized = true;
                    }

                    if (enemyList.Count == 0)
                    {
                        stage = CurrentLevelStage.enemyStage3;
                    }
                    break;
                case CurrentLevelStage.enemyStage3:

                    if (!stage3Initialized)
                    {
                        InitializeStage3();
                        stage3Initialized = true;
                    }

                    if (enemyList.Count == 0)
                    {
                        stage = CurrentLevelStage.bossStage;
                    }
                    break;
                case CurrentLevelStage.bossStage:

                    //Spawn the boss if there is none
                    if (boss == null && stage != CurrentLevelStage.playerWonStage && !bossStageInitialized)
                    {
                        InitializeStageBoss();
                        bossStageInitialized = true;
                        if (InGameScreen.level == CurrentLevel.level1)
                        {
                            InGameScreen.maxBossLife = boss.Life; //Needed to draw the life bar correctly
                        }
                        else
                            InGameScreen.maxBossLife = secondBoss.Life; //Needed to draw the life bar correctly

                    }

                    //The boss is dead, give score, remove him and show a win screen.
                    if (boss != null && !boss.alive)
                    {
                        //Gives score for the boss kill.
                        Sounds.SoundBank.PlayCue("BossDeath");
                        stage = CurrentLevelStage.playerWonStage;
                        InGameScreen.playerScore += boss.scoreAmount * InGameScreen.scoreMultiplier * (int)InGameScreen.difficulty;
                        boss = null;
                        bullets.Clear();
                        Thread.Sleep(1000);
                    }
                    else if (secondBoss != null && !secondBoss.alive)
                    {
                        //Gives score for the boss kill.
                        Sounds.SoundBank.PlayCue("BossDeath");
                        stage = CurrentLevelStage.playerWonStage;
                        InGameScreen.playerScore += secondBoss.scoreAmount * InGameScreen.scoreMultiplier * (int)InGameScreen.difficulty;
                        secondBoss = null;
                        bullets.Clear();
                        Thread.Sleep(1000);
                    }
                    break;
                case CurrentLevelStage.playerWonStage:
                    if (!saved)
                    {
                        HighScores.SaveHighscoreToFile();
                        saved = true;
                        if (InGameScreen.level == CurrentLevel.level1)
                        {
                            LevelWon();
                        }
                        else
                            WinScreen();

                        InGameScreen.level += 1;
                    }
                    break;
                default:
                    break;
            }
        }