public override AbstractFiringPattern Exec() { double i = start; speed = 2; firingrate = 1000; //default firing rate. angle = rnd.Next(0, 360); //generate random angle for laser. while (i < stop) //Similar to Laser, just with increasing speed for each subsequent bullet. { var t = fromModel.GetLocation(); speed += .5; BulletModel bullet = MainContent.ModelFactory.BuildEnemyBulletModel(TextureNames.LaserBullet, i, i + bulletLife, t, fromModel); bullet.SetLinearTravelAngle(angle); bullet.SetRate(speed); bullet.SetSourceModel(fromModel); bullet.SetDestinationModel(MainContent.PlayerShip); MainContent.Events.AddSingleTaggedEvent(i, fromModel, () => bullet.SetLocationFromSourcetModel()); MainContent.Events.AddScheduledTaggedEvent(i, i + bulletLife, fromModel, () => bullet.MoveLinearAngle()); scheduledEvents.Add(new GameEvents.Event(start, stop, bullet)); i += 1 / firingrate; } return(this); }
public override AbstractFiringPattern Exec() { Random rand = new Random(); for (double i = start; i < stop; i += 1 / firingrate) { BulletModel bullet = MainContent.ModelFactory.BuildEnemyBulletModel(TextureNames.LaserBullet, i, i + bulletLife, fromModel.GetLocation(), fromModel); bullet.SetLinearTravelAngle(rand.Next(360)); bullet.SetRate(speed); bullet.SetSourceModel(fromModel); bullet.SetDestinationModel(MainContent.PlayerShip); MainContent.Events.AddSingleTaggedEvent(i, fromModel, () => bullet.SetLocationFromSourcetModel()); MainContent.Events.AddScheduledTaggedEvent(i, i + bulletLife, fromModel, () => bullet.MoveLinearAngle()); scheduledEvents.Add(new GameEvents.Event(start, stop, bullet)); } return(this); }
public override AbstractFiringPattern Exec() { double i = start; while (i < stop) { var t = fromModel.GetLocation(); BulletModel bullet = MainContent.ModelFactory.BuildEnemyBulletModel(texture, i, i + bulletLife, t, fromModel); bullet.SetRate(speed); bullet.SetSourceModel(fromModel); bullet.SetLinearTravelAngle(angle); MainContent.Events.AddSingleTaggedEvent(i, fromModel, () => bullet.SetLocationFromSourcetModel()); MainContent.Events.AddScheduledTaggedEvent(i, i + bulletLife, fromModel, () => bullet.MoveLinearAngle()); scheduledEvents.Add(new GameEvents.Event(start, stop, bullet)); i += 1 / firingrate; } return(this); }
public override AbstractFiringPattern Exec() { for (double i = 0; i < 360; i += (360 / spokes)) { double jAngle = i; for (double j = start; j < stop; j += 1 / firingrate) { BulletModel bullet1 = MainContent.ModelFactory.BuildEnemyBulletModel(texture, j, j + 10, fromModel.GetLocation(), fromModel); if (bullet1 != null) { bullet1.SetLinearTravelAngle(jAngle); bullet1.SetSourceModel(fromModel); bullet1.SetRate(speed); MainContent.Events.AddSingleTaggedEvent(j, fromModel, () => bullet1.SetLocationFromSourcetModel()); MainContent.Events.AddScheduledTaggedEvent(j, j + bulletLife, fromModel, () => bullet1.MoveLinearAngle()); jAngle += 5 * direction; jAngle %= 360; } scheduledEvents.Add(new GameEvents.Event(i, i + bulletLife, bullet1)); } } return(this); }
public override AbstractFiringPattern Exec() { double jAngle = startDegree; int direction = 10; for (double i = start; i < stop; i += 1 / firingrate) { BulletModel bullet1 = MainContent.ModelFactory.BuildEnemyBulletModel(texture, i, i + bulletLife, fromModel.GetLocation(), fromModel); if (bullet1 != null) { bullet1.SetLinearTravelAngle(jAngle); bullet1.SetSourceModel(fromModel); bullet1.SetRate(speed); MainContent.Events.AddSingleTaggedEvent(i, fromModel, () => bullet1.SetLocationFromSourcetModel()); MainContent.Events.AddScheduledTaggedEvent(i, i + bulletLife, fromModel, () => bullet1.MoveLinearAngle()); if (jAngle >= max + Math.Abs(direction) || jAngle <= min - Math.Abs(direction)) { direction *= -1; } jAngle += direction; } } return(this); }
public override AbstractFiringPattern Exec() { double i; for (i = start; i < stop; i += 1 / firingrate) { double j = startAngle - 1; while (j < stopAngle) { BulletModel bullet = MainContent.ModelFactory.BuildEnemyBulletModel(texture, i, i + bulletLife, fromModel.GetLocation(), fromModel); bullet.SetLinearTravelAngle(j); bullet.SetSourceModel(fromModel); bullet.SetRate(speed); bullet.SetDamage(damage); MainContent.Events.AddSingleTaggedEvent(i, fromModel, () => bullet.SetLocationFromSourcetModel()); MainContent.Events.AddScheduledTaggedEvent(i, i + bulletLife, fromModel, () => bullet.MoveLinearAngle()); j += density; scheduledEvents.Add(new GameEvents.Event(start, stop, bullet)); } } return(this); }