public override void Update(float deltaTime) { base.Update(deltaTime); laserGun.PointAt(InputManager.MouseX, InputManager.MouseY); if (InputManager.MouseLeft == ButtonState.Pressed) { laserGun.Shoot(); } laserGun.Update(deltaTime); }
public override void Update(float deltaTime) { base.Update(deltaTime); target = CollisionManager.CollidesWithEnemy(view); if (target != null) { laserGun.PointAt((int)target.X + target.Width / 2, (int)target.Y + target.Height / 2); laserGun.Shoot(); } laserGun.Update(deltaTime); }
public Turret(ContentManager content, int groundLevel, Enemy.EnemyDirection enemyDirection) : base(content, groundLevel) { SetTexture("turret1"); Y = groundLevel - Height; this.groundLevel = groundLevel; if (enemyDirection == Enemy.EnemyDirection.ToLeft) { X = Game.GAME_WIDTH / 2 - Width / 2 + 290; view = new Rectangle((int)X + Width, 0, Game.GAME_WIDTH - (int)X - Width, (int)Y + Height); } else { X = Game.GAME_WIDTH / 2 - Width / 2 - 290; view = new Rectangle(0, 0, (int)X, (int)Y + Height); spriteEffects = SpriteEffects.FlipHorizontally; } int gunX; if (spriteEffects == SpriteEffects.FlipHorizontally) { gunX = (int)X; } else { gunX = (int)X + 8; } int gunY = (int)Y + 8; laserGun = new LaserGun(content, gunX, gunY, 10, this); if (enemyDirection == Enemy.EnemyDirection.ToRight) { laserGun.PointAt(0, (int)laserGun.Y + laserGun.Height / 2); } healthBar.Height /= 2; healthBar.Width /= 2; layerDepth += .01f; HealthLevel = 1; Alive = false; }