private void Shoot() { if (Sprite.NumberOfSprites == 1 && LastTimeShooted >= 190) { GameSounds.PlayShootSound(); Texture2D bulletTexture = Factory.CreateTexture("Bullet"); const int yOffset = 10; int xOffset; if (direction == Direction.ToLeft) { xOffset = -bulletTexture.Width; } else { xOffset = Sprite.Texture.Width; } Vector2 bulletPosition = Factory.CreateVector(Sprite.Position.X + xOffset, Sprite.Position.Y + yOffset); Rectangle bulletCollisoionRectangle = Factory.CreateRectangle((int)bulletPosition.X, (int)bulletPosition.Y, bulletTexture.Width, bulletTexture.Height); Sprite sprite = Factory.CreateSprite(bulletTexture, 1, bulletPosition); Bullet bullet = WorldFactory.CreateBullet(sprite, bulletCollisoionRectangle); bullet.direction = direction; ShootedBullets.Add(bullet); LastTimeShooted = 0; } }
public void Shoot() { Texture2D bulletTexture = Factory.CreateTexture("Bullet"); int yOffset = 10; int xOffset; if (Direction == Direction.ToLeft) { xOffset = -bulletTexture.Width; } else { xOffset = Sprite.Texture.Width; } Vector2 bulletPosition = Factory.CreateVector(Sprite.Position.X + xOffset, Sprite.Position.Y + yOffset); Rectangle bulletCollisoionRectangle = Factory.CreateRectangle((int)bulletPosition.X, (int)bulletPosition.Y, bulletTexture.Width, bulletTexture.Height); Sprite sprite = Factory.CreateSprite(bulletTexture, 1, bulletPosition); Bullet bullet = WorldFactory.CreateBullet(sprite, bulletCollisoionRectangle); bullet.direction = Direction; ShootedBullets.Add(bullet); }