Exemplo n.º 1
0
 /// <summary>
 /// Launches fireball
 /// </summary>
 public void Cast()
 {
     delay--;
     if (fireball == null && delay == 0)
     {
         fireball = new Fireball(this);
     }
     if (fireball != null)
     {
         fireball.draw();
         delay = 30;                //Shoot every half a second.
     }
 }
Exemplo n.º 2
0
        public void DrawPlayerStuff()
        {
            Texture2D x;

            PlayerShip.Draw(spriteBatch);
            switch (PlayerShip.Weapon) //This sets up the selected weapon displayer in the corner
            {
            default: { x = FireballTexture; break; }

            case 1: { x = BeamTexture; break; }

            case 2: { x = ArrowTexture; break; }
                //case 3:  { x=; }
                //case 4:  { x=; }
                //case 5:  { x=; }
            }
            Fireball g = new Fireball(x, ViewScreen, 0.0f);

            g.Draw(spriteBatch);
        }
Exemplo n.º 3
0
        public void GameRunning(KeyboardState keyState, GamePadState gamePadState, GameTime gameTime)
        {
            EnemyInteraction(gameTime);
            PlayInstanceSound();
            if (healthtimer <= 0.0f)
            {
                HealthUpdater();
            }
            if (EnemyLauncher <= 0.0f && gamestate == GameState.Running)
            {
                float difficultymultiplier = 1.0f;
                if (Controls.Default.Difficulty == 0)
                {
                    difficultymultiplier = 1.0f;
                }
                if (Controls.Default.Difficulty == 1)
                {
                    difficultymultiplier = 1.2f;
                }
                if (Controls.Default.Difficulty == 2)
                {
                    difficultymultiplier = 1.5f;
                }
                if (Points > 1000)
                {
                    launchingspeed = 5.0f / difficultymultiplier;
                }
                if (Points > 2500)
                {
                    launchingspeed = 4.0f / difficultymultiplier;
                }
                if (Points > 6000)
                {
                    launchingspeed = 3.0f / difficultymultiplier;
                }
                if (Points > 10000)
                {
                    launchingspeed = 2.0f / difficultymultiplier;
                }
                if (Points > 15000)
                {
                    launchingspeed = 1.5f / difficultymultiplier;
                }
                if (Points > 25000)
                {
                    launchingspeed = 1.0f / difficultymultiplier;
                }
                if (Points > 40000)
                {
                    launchingspeed = 0.8f / difficultymultiplier;
                }
                if (Points > 55000)
                {
                    launchingspeed = 0.6f / difficultymultiplier;
                }
                if (Points > 75000)
                {
                    launchingspeed = 0.3f / difficultymultiplier;
                }
                Random r = new Random(2);
                EnemyLauncher = (float)r.NextDouble() * launchingspeed;


                Random R = new Random();
                switch (R.Next(3))
                {
                default: CreateEnemy(EnemyTexture[(int)ShipType.Bandit], 50.0f, (int)ShipType.Bandit); break;

                case 2: if (Points > 200)
                    {
                        CreateEnemy(EnemyTexture[(int)ShipType.Bandit_Elite], 100.0f, (int)ShipType.Bandit_Elite);
                    }
                    else
                    {
                        CreateEnemy(EnemyTexture[(int)ShipType.Bandit], 50.0f, (int)ShipType.Bandit);
                    } break;
                }
            }
            if (buttonFireDelay <= 0.0f)
            {
                if (keyState.IsKeyDown(KeyEsc) ||
                    gamePadState.Buttons.Start == ButtonState.Pressed)
                {
                    gamestate       = GameState.Pause;
                    buttonFireDelay = 0.2f;
                }
                if (keyState.IsKeyDown(Keys.C) ||
                    gamePadState.Buttons.Y == ButtonState.Pressed)
                {
                    //CreateEnemy();
                    buttonFireDelay = 0.2f;
                }
            }

            if (VolumeDelay <= 0.0f)
            {
                if (keyState.IsKeyDown(Keys.F5))
                {
                    if (Controls.Default.EffectNoise > 0.0f)
                    {
                        s.Vol -= 0.01f; AdjustVolume();
                    }
                }
                if (keyState.IsKeyDown(Keys.F6))
                {
                    if (Controls.Default.EffectNoise < 1.0f)
                    {
                        s.Vol += 0.01f; AdjustVolume();
                    }
                }
                //if (Controls.Default.EffectNoise > 1.0f) Controls.Default.EffectNoise = 1.0f;
                //if (Controls.Default.EffectNoise > 0.0f) Controls.Default.EffectNoise = 0.0f;

                VolumeDelay = 0.05f;
            }

            if (keyState.IsKeyDown(KeyUp) || gamePadState.DPad.Up == ButtonState.Pressed)
            {
                PlayerShip.Accelerate();
            }
            if (keyState.IsKeyDown(KeyDown) || gamePadState.DPad.Down == ButtonState.Pressed)
            {
                PlayerShip.MoveReverse();
            }
            if (keyState.IsKeyDown(KeyLeft) || gamePadState.DPad.Left == ButtonState.Pressed)
            {
                PlayerShip.TurnLeft();
            }
            if (keyState.IsKeyDown(KeyRight) || gamePadState.DPad.Right == ButtonState.Pressed)
            {
                PlayerShip.TurnRight();
            }
            if (keyState.IsKeyDown(KeyFire) || gamePadState.Buttons.A == ButtonState.Pressed)
            {
                //PlayerShip.Fire();
                if (buttonFireDelay <= 0.0f)
                {
                    Fireball FireballShot = new Fireball(FireballTexture, new Vector2(PlayerShip.Position.X, PlayerShip.Position.Y - 10.0f), 150.0f);
                    Fireball BeamShot     = new Fireball(BeamTexture, new Vector2(PlayerShip.Position.X, PlayerShip.Position.Y - 10.0f), 300.0f);
                    Fireball ArrowShot    = new Fireball(ArrowTexture, new Vector2(PlayerShip.Position.X, PlayerShip.Position.Y - 10.0f), 300.0f);

                    //if (SelectedWeapon == 0)
                    //{
                    if (PlayerShip.GetAmmo > 0)
                    {
                        if (PlayerShip.Weapon == 0)
                        {
                            PlayerShotList.Add(FireballShot);
                            buttonFireDelay = 0.4f;
                            PlaySound(TorpedoNoise);
                        }
                        else if (PlayerShip.Weapon == 1)
                        {
                            PlayerShotList.Add(BeamShot);
                            buttonFireDelay = 0.18f;
                            PlaySound(LaserNoise);
                        }
                        else
                        {
                            PlayerShotList.Add(ArrowShot);
                            buttonFireDelay = 0.2f;
                            PlaySound(FiringNoise);
                        }

                        PlayerShip.UpdateAmmo(false);
                    }
                    //}
                }
            }
            if (keyState.IsKeyDown(KeyWepForward) ||
                gamePadState.Buttons.RightShoulder == ButtonState.Pressed)
            {
                if (changeWeaponDelay <= 0.0f)
                {
                    PlayerShip.ChangeWeapon(0);
                    changeWeaponDelay = 0.25f;
                }
            }
            if (keyState.IsKeyDown(KeyWepBackward) ||
                gamePadState.Buttons.LeftShoulder == ButtonState.Pressed)
            {
                if (changeWeaponDelay <= 0.0f)
                {
                    PlayerShip.ChangeWeapon(1);
                    changeWeaponDelay = 0.25f;
                }
            }
        }