예제 #1
0
        public override void Update(MainLoop mainLoop)
        {
            if (Input.IsKeyPressed(Keys.Escape))
            {
                if (enemy.getAlive() == true && player.getAlive() == true)
                {
                    pauseMenu.ToggleActive();
                }
            }

            if (pauseMenu.GetActive() == false)
            {
                if (Input.IsKeyPressed(Keys.Z))
                {
                    canShoot = true;
                }

                shootInterval--;

                if (enemy.getAlive() == false || player.getAlive() == false)
                {
                    endTimer--;
                    if (player.getAlive() == false)
                    {
                        playerBulletList.Clear();
                    }
                    if (enemy.getAlive() == false)
                    {
                        player.resetHit();
                    }
                }
                //UPDATES
                if (enemy.getAlive() == true)
                {
                    enemy.Update();
                }
                if (player.getAlive() == true)
                {
                    player.Update();
                }
                FXManager.Update();
                CommonData.UpdateData(player.getPosition().X, player.getPosition().Y);
                for (int i = bulletList.Count() - 1; i >= 0; i--)
                {
                    BulletBase bullet = bulletList[i];
                    bullet.Update(player);
                    if (enemy.getAlive() == false)
                    {
                        bullet.setAlive(false);
                    }
                    if (bullet.getAlive() == false)
                    {
                        bulletList.Remove(bullet);
                    }
                }
                for (int i = playerBulletList.Count() - 1; i >= 0; i--)
                {
                    PlayerBullet bullet = playerBulletList[i];
                    bullet.Update();
                    if (bullet.getAlive() == false)
                    {
                        playerBulletList.Remove(bullet);
                    }
                }
                //INPUTS
                if (Input.IsKeyPressed(Keys.X) && bombs > 0 && player.getAlive() == true)
                {
                    ClearBullets();
                    player.resetHit();
                    flashAlpha = 1;
                    bombs--;
                }
                if (Input.IsKeyDown(Keys.Z) && shootInterval <= 0 && canShoot == true && player.getAlive() == true)
                {
                    playerBulletList.Add(new PlayerBullet(new Vector2(player.getPosition().X - 27, player.getPosition().Y - 10)));
                    playerBulletList.Add(new PlayerBullet(new Vector2(player.getPosition().X - 9, player.getPosition().Y - 30)));
                    playerBulletList.Add(new PlayerBullet(new Vector2(player.getPosition().X + 9, player.getPosition().Y - 30)));
                    playerBulletList.Add(new PlayerBullet(new Vector2(player.getPosition().X + 27, player.getPosition().Y - 10)));
                    shootInterval = 5;
                }
                //ENDING
                if (endTimer == 0)
                {
                    if (player.getAlive() == true)
                    {
                        ScoreManager.SetScore(scene, bombs + 1);
                    }
                    pauseMenu.ToggleActive();
                }

                Console.WriteLine(bulletList.Count);
            }
            else
            {
                //PAUSEMENU
                pauseMenu.Update();
            }
            base.Update(mainLoop);
        }
예제 #2
0
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Assets.menuBG, new Vector2(CommonData.minX, CommonData.minY), new Color(255f, 255f, 255f, alpha));
            float xMod = -400 + (500 * alpha);

            spriteBatch.Draw(Assets.menuElements, new Vector2(xMod + CommonData.minX + 36, CommonData.minY + 140), new Rectangle(27, 0, 112, 92), Color.White);
            spriteBatch.Draw(Assets.menuElements, new Vector2(xMod + CommonData.minX + 8, CommonData.minY + 142 + 33 * cursor), new Rectangle(0, 0, 24, 19), Color.White);
            spriteBatch.Draw(Assets.menuElements, new Vector2(xMod + CommonData.minX + 110, CommonData.minY + 140), new Rectangle(4, 33 + (int)(32.6f * stage), 18, 25), Color.White);
            if (ScoreManager.getScore(stage) > 0)
            {
                spriteBatch.Draw(Assets.menuElements, new Vector2(xMod + CommonData.minX + 130, CommonData.minY + 140), new Rectangle(28 + 17 * ScoreManager.getScore(stage) - 17, 98, 17, 23), Color.White);
            }
        }