public void shoot(float power) { if (type != BulletType.BasicBullet) { if (inventory.getShotCount(type) <= 0) { type = inventory.findNextShotType(); } switch (type) { case BulletType.HeavyShot: bullet = new HeavyShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); break; case BulletType.ScatterShot: bullet = new ScatterShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); break; case BulletType.TeleportShot: bullet = new TeleportShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); break; case BulletType.MissileDrop: bullet = new MissileDrop(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); break; } inventory.decrementShot(type); } else { bullet = new Bullet(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); } bullet.speed = turretDirection * new Vector2(power, -power); ((TankGame)Game).soundManager.shoot.Play(); Game.Components.Add(bullet); recoil = true; shotPosition = tankPosition.X; shotPuff = new Puff(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8), turretDirection, power); shotPuff.AutoInitialize(game.GraphicsDevice, game.Content, TankGame.spriteBatch); shotPuff.UpdateOrder = 100; shotPuff.DrawOrder = 100; shotPuff.Visible = true; }
public void shoot(float power) { if (type != BulletType.BasicBullet) { if (inventory.getShotCount(type) <= 0) type = inventory.findNextShotType(); switch (type) { case BulletType.HeavyShot: bullet = new HeavyShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); break; case BulletType.ScatterShot: bullet = new ScatterShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); break; case BulletType.TeleportShot: bullet = new TeleportShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); break; case BulletType.MissileDrop: bullet = new MissileDrop(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8)); break; } inventory.decrementShot(type); } else { bullet = new Bullet(game, new Vector2(turretPosition.X + turretPic.Width/2 , turretPosition.Y - turretPic.Height/8 )); } bullet.speed = turretDirection * new Vector2(power, -power); ((TankGame)Game).soundManager.shoot.Play(); Game.Components.Add(bullet); recoil = true; shotPosition = tankPosition.X; shotPuff = new Puff(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8), turretDirection, power); shotPuff.AutoInitialize(game.GraphicsDevice, game.Content, TankGame.spriteBatch); shotPuff.UpdateOrder = 100; shotPuff.DrawOrder = 100; shotPuff.Visible = true; }