public Projectile Shoot(Projectile.ProjectileType pt, Direction d) { Point projectileLocation = new Point(Sprite.Location.X + (Sprite.Width / 2), Sprite.Location.Y + (Sprite.Height / 2)); Projectile pr = new Projectile(); switch (pt) { case Projectile.ProjectileType.Bullet: pr = new Bullet(this, projectileLocation); pr.Direction = d; pr.SetController(controller); pr.StartMoving(); break; case Projectile.ProjectileType.Laser: if (d != Direction.Stop) { pr = new Laser(this, projectileLocation, d); pr.SetController(controller); pr.StartMoving(); } break; //case Projectile.ProjectileType.Missile: // pr = new Missile(this, projectileLocation, GetRandomEnemy(this)); // pr.SetController(controller); // pr.StartMoving(); // break; } return pr; }
public void Fire() { if (_fireRecoveryTime > 0) { return; } else { _fireRecoveryTime = FireRecovery; } Bullet bullet = new Bullet(_bulletTexture); bullet.SetColor(new Color(0, 1, 0, 1)); bullet.SetPosition(_sprite.GetPosition() + _gunOffset); _bulletManager.Shoot(bullet); }
public override void intersectBullet(Bullet b) { base.intersectBullet(b); if (Math.Abs(b.vX) > Math.Abs(b.vY)) { double oldX = X; X += 20 * (int)(Math.Abs(b.vX) / b.vX); foreach (Entity e in World.getEntities()) { if (e.Removed) continue; if (e != this && !(e is Bullet) && e.getBounds2D().intersects(getBounds2D())) { X = oldX; break; } } } else { double oldY = Y; Y += 20 * (int)(Math.Abs(b.vY) / b.vY); foreach (Entity e in World.getEntities()) { if (e.Removed) continue; if (e != this && !(e is Bullet) && e.getBounds2D().intersects(getBounds2D())) { Y = oldY; break; } } } }
public void Update(double elapsedTime) { _shootCountDown = _shootCountDown - elapsedTime; if (_shootCountDown <= 0) { Bullet bullet = new Bullet(_bulletTexture); Vector currentPosition = _sprite.GetPosition(); Vector bulletDir = _playerCharacter.GetPosition() - currentPosition; bulletDir = Vector.Normalize(bulletDir); bullet.Direction = bulletDir; bullet.Speed = 350; //bullet.Direction = new Vector(-1, 0, 0); bullet.SetPosition(_sprite.GetPosition()); bullet.SetColor(new Engine.Color(1, 0, 0, 1)); _bulletManager.EnemyShoot(bullet); RestartShootCountDown(); } if (Path != null) { Path.UpdatePosition(elapsedTime, this); } if (_hitFlashCountDown != 0) { _hitFlashCountDown = Math.Max(0, _hitFlashCountDown - elapsedTime); double scaledTime = 1 - (_hitFlashCountDown / HitFlashTime); _sprite.SetColor(new Engine.Color(1, 1, (float)scaledTime, 1)); } }
internal void OnCollision(Bullet bullet) { // If the ship is already dead then ignore any more bullets. if (Health == 0) { return; } Health = Math.Max(0, Health - 25); _hitFlashCountDown = HitFlashTime; // half _sprite.SetColor(new Engine.Color(1, 1, 0, 1)); if (Health == 0) { OnDestroyed(); } }
public void Shoot(Bullet bullet) { _bullets.Add(bullet); }
public override void intersectBullet(Bullet b) { base.intersectBullet(b); blowUp(); }
public void Add(Bullet b) { bullets.Add(b); }
public override void intersectBullet(Bullet b) { World.remove(b); }
internal void OnCollision(Bullet bullet) { if (Health == 0) { return; } Health = Math.Max(0, Health - 25); _hitFlashCountDown = HitFlashTime; _sprite.SetColor(new Engine.Color(1, 1, 0, 1)); if(Health == 0) { OnDestroyed(); } }
internal void OnCollision(Bullet bullet) { _dead = true; }
public virtual void intersectBullet(Bullet b) { World.remove(b); }
public override void intersectBullet(Bullet b) { }
public void EnemyShoot(Bullet bullet) { _enemyBullets.Add(bullet); }