// TODO : Implémenter un pseudo constructeur par recopie public ShotPool(LuxGame game, World world, Shot shot, int shotNb, int maxShotNb, Sprite skin = null) : base(game) { this.world = world; // A COMPLETER }
private void shoot(Shot shot, float positionX, float positionY, float speedX, float speedY, float accelX, float accelY, bool copyPosition, bool copySpeed, bool copyAccel) { if (copyPosition) { shot.Position.X = positionX; shot.Position.Y = positionY; } else { shot.Position = new Vector2(positionX, positionY); } if (copySpeed) { shot.Speed.X = speedX; shot.Speed.Y = speedY; } else { shot.Speed = new Vector2(speedX, speedY); } if (copyAccel) { shot.Accel.X = accelX; shot.Accel.Y = accelY; } else { shot.Accel = new Vector2(accelX, accelY); } shot.Shoot(); }
private void activeShotsRemove(Shot shot) { nonActiveShots.Add(shot); activeShots.Remove(shot); if (isAGoodShot) { world.GoodShots.Remove(shot); } else { world.BadShots.Remove(shot); } }
private void activeShotsAdd(Shot shot) { activeShots.Add(shot); if (isAGoodShot) { world.GoodShots.Add(shot); } else { world.BadShots.Add(shot); } }
/// <summary> /// Tire une balle, la fait rentrer en compte dans le monde pour les collisions /// </summary> /// <param name="positionX"></param> /// <param name="positionY"></param> /// <param name="speedX"></param> /// <param name="speedY"></param> /// <param name="accelX"></param> /// <param name="accelY"></param> /// <param name="copyPosition"></param> /// <param name="copySpeed"></param> /// <param name="copyAccel"></param> public void Shoot(float positionX, float positionY, float speedX, float speedY, float accelX, float accelY, bool copyPosition, bool copySpeed, bool copyAccel) { if (shotNb == maxActiveShots) { if (shotNb == maxShotNb) { return; } shotNb++; maxActiveShots++; Shot shot = new Shot(LuxGame, world, 1, null); shot.Skin = new Sprite(shot, new List<Texture2D>() { bulletText }, null); shot.Skin.SetAnimation(bulletText.Name); Game.Components.Add(shot); Game.Components.Add(shot.Skin); allShots.Add(shot); activeShotsAdd(shot); shoot(shot, positionX, positionY, speedX, speedY, accelX, accelY, copyPosition, copySpeed, copyAccel); } else { shoot(nonActiveShots[0], positionX, positionY, speedX, speedY, accelX, accelY, copyPosition, copySpeed, copyAccel); activeShotsAdd(nonActiveShots[0]); nonActiveShots.Remove(nonActiveShots[0]); maxActiveShots++; } }
public override void Initialize() { base.Initialize(); for (int i = 0; i < shotNb; i++) { Shot shot = new Shot(LuxGame, invincibleTimeSec, isAGoodShot, world, shotHitBox, damage, null); shot.Skin = new Sprite(shot, new List<Texture2D>() { bulletText }, null); shot.Skin.SetAnimation(bulletText.Name); Game.Components.Add(shot); Game.Components.Add(shot.Skin); allShots.Add(shot); nonActiveShots.Add(shot); } }