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; }
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); }
public override void resolveCollision(CommandCenter collider) { if (boxCollider.Intersects(collider.boxCollider)) { if (Player != collider) { collider.Hit(); Player._currentActive = null; isAlive = false; } } }
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); } } }
}//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(){
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--; }
}//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
abstract public void resolveCollision(CommandCenter collider);
public Missile(CommandCenter player, Texture2D texture, Vector2 position, float scale, float rotation, SpriteEffects spriteEffects) : base(texture, position, scale, rotation, true, spriteEffects) { Player = player; }