using AlienAttack.MonoGame.Things.Items; namespace AlienAttack.MonoGame.Things.Bullets; internal class Bullet(float x, float y, float xVel, float yVel, Sprite owner) : Sprite(x, y) { protected float XVelocity = xVel; protected float YVelocity = yVel; public Sprite Owner { get; protected set; } = owner; public int Damage { get; protected set; } = 0; public override void Draw(SpriteDrawArgs args) { base.Draw(args); } public override void Update(SpriteUpdateContext context) { XPosition += XVelocity; YPosition += YVelocity; if (XPosition + BoundBox.Width < 0 || XPosition > context.ViewTransform.ScreenWidth || YPosition + BoundBox.Height < 0 || YPosition > context.ViewTransform.ScreenHeight) { IsDead = true; } base.Update(context); } public override void OnCollision(SpriteCollisionContext context) { if (context.Sprite is Bullet || context.Sprite == Owner || context.Sprite is Item) return; IsDead = true; float xVel = 0; float yVel = 0; if (context.Sprite is MoveableSprite moveableSprite) { xVel = moveableSprite.XVelocity; yVel = moveableSprite.YVelocity; } context.SpawnSprite(new MiniExplosion((int)XPosition, (int)YPosition, xVel, yVel)); } }