Пример #1
0
        public void Update(Game1 getGame1)
        {
            for (int i = 0; i < 3; i++)
            {
                Buttons[i].Update();
            }

            //Buttons
            if (CheckCollision.Collision(Buttons[0].MousePos, Buttons[0].CollisionBox))
            {
                if (Input.ClickReleased(Input.EClicks.LEFT))
                {
                    GameMode.Mode = GameMode.EGameMode.LEVELSELECT;
                }
            }
            if (CheckCollision.Collision(Buttons[1].MousePos, Buttons[1].CollisionBox))
            {
                if (Input.ClickReleased(Input.EClicks.LEFT))
                {
                    GameMode.Mode = GameMode.EGameMode.OPTIONS;
                }
            }
            if (CheckCollision.Collision(Buttons[2].MousePos, Buttons[2].CollisionBox))
            {
                if (Input.ClickReleased(Input.EClicks.LEFT))
                {
                    getGame1.Exit();
                }
            }
        }
Пример #2
0
        public void Update()
        {
            if (Input.KeyboardPressed(Keys.Escape))
            {
                GameMode.Mode = GameMode.EGameMode.MENU;
            }

            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i].Update();
            }


            if (CheckCollision.Collision(buttons[0].MousePos, buttons[0].CollisionBox))
            {
                if (Input.ClickReleased(Input.EClicks.LEFT))
                {
                    GameMode.Mode = GameMode.EGameMode.MENU;
                }
            }
            if (CheckCollision.Collision(buttons[1].MousePos, buttons[1].CollisionBox))
            {
                if (Input.ClickReleased(Input.EClicks.LEFT))
                {
                    GameMode.Mode = GameMode.EGameMode.LEVELSELECT;
                }
            }
        }
Пример #3
0
        public void Update()
        {
            for (int i = 0; i < 2; i++)
            {
                ButtonSoundsIns[i]        = ButtonSounds[i].CreateInstance();
                ButtonSoundsIns[i].Volume = 0.3f;
            }

            ButtonSoundsIns[1].Pitch  = -0.2f;
            ButtonSoundsIns[1].Volume = 0.1f;

            if (CheckCollision.Collision(MousePos, CollisionBox))
            {
                SFXTimer[0]++;
                if (SFXTimer[0] <= 1)
                {
                    ButtonSoundsIns[0].Play();
                }
                else
                {
                    SFXTimer[0] = 2;
                }

                if (Input.ClickPress(Input.EClicks.LEFT))
                {
                    SFXTimer[1]++;
                    if (SFXTimer[1] <= 1)
                    {
                        ButtonSoundsIns[1].Play();
                    }
                    else
                    {
                        SFXTimer[1] = 2;
                    }

                    SpriteAnim.currentFrame = 2;
                }
                else
                {
                    SFXTimer[1]             = 0;
                    SpriteAnim.currentFrame = 1;
                }
            }
            else
            {
                SFXTimer[0]             = 0;
                SpriteAnim.currentFrame = 0;
            }
        }
Пример #4
0
        public void Update()
        {
            for (int i = 0; i < 3; i++)
            {
                Buttons[i].Update();
            }

            //Buttons
            if (CheckCollision.Collision(Buttons[0].MousePos, Buttons[0].CollisionBox))
            {
                if (Input.ClickReleased(Input.EClicks.LEFT))
                {
                    if (GameMode.UniMusic == GameMode.EUniMusic.Mute)
                    {
                        GameMode.UniMusic = GameMode.EUniMusic.Unmute;
                    }
                    else if (GameMode.UniMusic == GameMode.EUniMusic.Unmute)
                    {
                        GameMode.UniMusic = GameMode.EUniMusic.Mute;
                    }
                }
            }
            if (CheckCollision.Collision(Buttons[1].MousePos, Buttons[1].CollisionBox))
            {
                if (Input.ClickReleased(Input.EClicks.LEFT))
                {
                    if (GameMode.Controls == GameMode.EControls.Mouse)
                    {
                        GameMode.Controls = GameMode.EControls.Keyboard;
                    }
                    else if (GameMode.Controls == GameMode.EControls.Keyboard)
                    {
                        GameMode.Controls = GameMode.EControls.Mouse;
                    }
                }
            }
            if (CheckCollision.Collision(Buttons[2].MousePos, Buttons[2].CollisionBox))
            {
                if (Input.ClickReleased(Input.EClicks.LEFT))
                {
                    GameMode.Mode = GameMode.EGameMode.MENU;
                }
            }
        }
Пример #5
0
        private void Collisions()
        {
            foreach (Bullet bullet in player.BulletList)
            {
                foreach (Enemy turret in Turret)
                {
                    if (CheckCollision.Collision(bullet.CollisionBox, turret.CollisionBox))
                    {
                        turret.Health -= bullet.Damage;
                        bullet.isAlive = false;
                    }
                }
            }
            foreach (Enemy turret in Turret)
            {
                foreach (Bullet bullet in turret.BulletList)
                {
                    if (CheckCollision.Collision(player.CollisionBox, bullet.CollisionBox))
                    {
                        if (!player.isImmune)
                        {
                            gui.PlayerHealth -= bullet.Damage;
                        }

                        bullet.isAlive = false;
                    }
                }
            }

            if (CheckCollision.Collision(MainCannonCollisionBox, player.CollisionBox))
            {
                if (!player.isImmune)
                {
                    gui.PlayerHealth -= 50;
                }
            }
        }
Пример #6
0
        private void CollisionDetection()
        {
            foreach (Enemy enemy in EnemyList)
            {
                if (CheckCollision.Collision(enemy.CollisionBox, player.CollisionBox))
                {
                    enemy.Health = 0;

                    if (!player.isImmune)
                    {
                        player.isAlive   = false;
                        gui.PlayerHealth = 0;
                    }
                }

                if (CheckCollision.Collision(player.SecondaryFireRect, enemy.CollisionBox))
                {
                    enemy.Health -= 100;
                }
                foreach (Bullet bullet in enemy.BulletList)
                {
                    if (CheckCollision.Collision(player.CollisionBox, bullet.CollisionBox))
                    {
                        if (!player.isImmune)
                        {
                            gui.PlayerHealth -= bullet.Damage;
                        }

                        bullet.isAlive = false;
                    }
                }

                foreach (Bullet bullet in player.BulletList)
                {
                    if (CheckCollision.Collision(bullet.CollisionBox, enemy.CollisionBox))
                    {
                        enemy.Health  -= bullet.Damage;
                        bullet.isAlive = false;

                        if (enemy.Health <= 0 && ItemNextDropTimer >= 500)
                        {
                            RandItemDropNum = RandItemDrop.Next(25);

                            if (RandItemDropNum == 1)
                            {
                                ItemNextDropTimer = 0;
                                WeaponUpgradeItem(enemy.Position);
                            }
                            if (RandItemDropNum == 3)
                            {
                                ItemNextDropTimer = 0;
                                LifeItem(enemy.Position);
                            }
                        }
                    }
                }
            }
            foreach (BasicItem OneUp in OneUpList)
            {
                if (CheckCollision.Collision(player.CollisionBox, OneUp.CollisionBox))
                {
                    OneUp.isAlive    = false;
                    gui.PlayerHealth = 100;
                    if (gui.PlayerLives != 3)
                    {
                        gui.PlayerLives++;
                    }
                }
            }

            foreach (BasicItem WepUp in WepUpList)
            {
                if (CheckCollision.Collision(player.CollisionBox, WepUp.CollisionBox))
                {
                    WepUp.isAlive = false;

                    if (player._weaponType == Player.EWeaponType.BASIC)
                    {
                        player._weaponType = Player.EWeaponType.ADVANCED;
                    }
                    else if (player._weaponType == Player.EWeaponType.ADVANCED)
                    {
                        player._weaponType = Player.EWeaponType.MAX;
                    }
                }
            }
        }