Exemplo n.º 1
0
 public CrusaderMissile(CommandCenter player, Texture2D texture, Vector2 position, float scale, float rotation, SpriteEffects spriteEffects)
     : base(player, texture, position, scale, rotation, SpriteEffects.None)
 {
     specialTimerDelay = 1.0f;
     _position         = position;
     _rotation         = rotation + (float)(90 * (Math.PI / 180));
     // Adjustment of the sprite image because the image is oriented in the wrong direction
     speedMultiplier = 2.0f;
     Player          = player;
 }
Exemplo n.º 2
0
 public CrusaderShield(GameScreen screen, CommandCenter player, Texture2D texture, Vector2 position)
     : base(texture, position, 0.2f, 0.0f, true, SpriteEffects.None)
 {
     this._screen = screen;
     _position    = position;
     radius       = (_texture.Width * Scale) / 2;
     hp           = 100;
     _player      = player;
     GameScreen.gameSFXs["powerup"].Play();
     GameScreen.particleSystem.AddExplosion3(_position);
 }
Exemplo n.º 3
0
 public override void resolveCollision(CommandCenter collider)
 {
     if (boxCollider.Intersects(collider.boxCollider))
     {
         if (Player != collider)
         {
             collider.Hit();
             Player._currentActive = null;
             isAlive = false;
         }
     }
 }
Exemplo n.º 4
0
 public override void resolveCollision(CommandCenter collider)
 {
     if (boxCollider.Intersects(collider.boxCollider))
     {
         if (Player != collider)
         {
             collider.Hit();
             Player._currentActive = null;
             isAlive = false;
             GameScreen.particleSystem.AddExplosion(_position);
         }
     }
 }
Exemplo n.º 5
0
        }//public Screen ()

        public override void Initialize()
        {
            asteroids     = new List <Asteroid>();
            powerUpText   = new List <PowerUpText>();
            deadAsteroids = new Queue <Asteroid> ();
            player1       = new CommandCenter(this, texCommandCenter, texCrusaderShield, texGeminiMissile, new Vector2(100, 500));
            player2       = new CommandCenter(this, texCommandCenter, texCrusaderShield, texGeminiMissile, new Vector2(1000, 200));

            currentNumAsteroids = 0;
            currentNumPowerUps  = 0;
            spawnTimer          = 0.0f;
            spawnTimerPowerUp   = 5.0f;
            winner = " Wins!";

            random = new Random();

            for (int i = 0; i < NUM_ASTEROIDS; i++)
            {
                Asteroid tmpAsteroid = new Asteroid(texAsteroid, Vector2.Zero);
                asteroids.Add(tmpAsteroid);
                deadAsteroids.Enqueue(tmpAsteroid);
            }

            for (int i = 0; i < NUM_POWERUPS; i++)
            {
                int      randPowerUp = random.Next(0, 2);
                Asteroid tmpPowerUp;
                switch (randPowerUp)
                {
                case 0:
                    tmpPowerUp = new AhhSteroidCrusader(texAsteroid, Vector2.Zero);
                    asteroids.Add(tmpPowerUp);
                    deadAsteroids.Enqueue(tmpPowerUp);
                    break;

                case 1:
                    tmpPowerUp = new AhhSteroidPORT(texAsteroid, Vector2.Zero);
                    asteroids.Add(tmpPowerUp);
                    deadAsteroids.Enqueue(tmpPowerUp);
                    break;

                default:
                    break;
                }
            }
        }//public override void Initialize(){
Exemplo n.º 6
0
        public void resolveCollision(CommandCenter collider)
        {
            if (!isAlive)
            {
                return;
            }

            float distance = (_position - collider.Position).Length();

            if (!(distance < radius + collider.radius))
            {
                return;
            }

            collider.Hit();
            GameScreen.deadAsteroids.Enqueue(this);
            isAlive = false;
            GameScreen.currentNumAsteroids--;
        }
Exemplo n.º 7
0
        }//public override void UpdateInput(KeyboardState keyState)

        private void handlePlayerInput(CommandCenter player, KeyboardState keyState
                                       , Keys left, Keys right, Keys primary, Keys cycleLeft, Keys cycleRight)
        {
            bool readyToCycleLeft  = !prevState.IsKeyDown(cycleLeft);
            bool readyToCycleRight = !prevState.IsKeyDown(cycleRight);
            bool readyToFire       = !prevState.IsKeyDown(primary);

            if (player._currentActive == null)
            {
                if (keyState.IsKeyDown(left))
                {
                    player.AimLeft();
                }
                else if (keyState.IsKeyDown(right))
                {
                    player.AimRight();
                }

                if (keyState.IsKeyDown(primary))
                {
                    player.Launch();
                }
            }
            else
            {
                if (keyState.IsKeyDown(left))
                {
                    player._currentActive.TurnLeft();
                }
                else if (keyState.IsKeyDown(right))
                {
                    player._currentActive.TurnRight();
                }

                if (keyState.IsKeyDown(primary) && readyToFire)
                {
                    player._currentActive.ActivateSpecial();
                }
            }//else

            if (keyState.IsKeyDown(cycleLeft) && readyToCycleLeft)
            {
                player.cycleWeaponsLeft();
            }
            else if (keyState.IsKeyDown(cycleRight) && readyToCycleRight)
            {
                player.cycleWeaponsRight();
            }

            switch (currentState)
            {
            case ScreenState.GAMEOVER:
                if (keyState.IsKeyDown(Keys.Enter))
                {
                    Program.game.setScreen(new MainMenuScreen( ));
                }
                break;

            default:
                break;
            }
        }// private void function handlePlayerInput (CommandCenter player, KeyState keyState
Exemplo n.º 8
0
 abstract public void resolveCollision(CommandCenter collider);
Exemplo n.º 9
0
 public Missile(CommandCenter player, Texture2D texture, Vector2 position, float scale, float rotation, SpriteEffects spriteEffects)
     : base(texture, position, scale, rotation, true, spriteEffects)
 {
     Player = player;
 }