public ThingList GetEnemies(GameScene game) { ThingList enemies = new ThingList(); for (int i = 0; i < thingData.Length; i++) { Thing enemy = CreateEnemyFromData(thingData[i], game); if (enemy != null) { enemies.AddThing(enemy); } } return(enemies); }
public GameScene(StageData data) { random = new Random(); map = data.GetMap(this); // player = new Player(this, 6, 1, Player.Direction.Right); player = data.GetPlayer(this); MoveCameraFast(player.Focus); players = new ThingList(); players.AddThing(player); // enemies = new ThingList(); enemies = data.GetEnemies(this); enemyAddList = new ThingList(); playerBullets = new BulletList(); enemyBullets = new BulletList(); items = new ThingList(); door = data.GetExitDoor(this); particles = new ParticleList(); particleAddList = new ParticleList(); quakeRadius = 0; quakeVector = Vector.Zero; flash = 0; numTicks = 0; cleared = false; clearTimer = 0; gameoverTimer = 0; gameover = false; backgroundParticles = new ParticleList(); audio = null; /* enemies.AddThing(new TestEnemy(this, 7, 24, TestEnemy.Direction.Left)); enemies.AddThing(new TestEnemy(this, 12, 11, TestEnemy.Direction.Left)); enemies.AddThing(new TestEnemy(this, 12, 24, TestEnemy.Direction.Left)); enemies.AddThing(new TestEnemy(this, 16, 8, TestEnemy.Direction.Left)); enemies.AddThing(new TestEnemy(this, 22, 17, TestEnemy.Direction.Left)); */ }
public GameScene(StageData data) { random = new Random(); map = data.GetMap(this); // player = new Player(this, 6, 1, Player.Direction.Right); player = data.GetPlayer(this); MoveCameraFast(player.Focus); players = new ThingList(); players.AddThing(player); // enemies = new ThingList(); enemies = data.GetEnemies(this); enemyAddList = new ThingList(); playerBullets = new BulletList(); enemyBullets = new BulletList(); items = new ThingList(); door = data.GetExitDoor(this); particles = new ParticleList(); particleAddList = new ParticleList(); quakeRadius = 0; quakeVector = Vector.Zero; flash = 0; numTicks = 0; cleared = false; clearTimer = 0; gameoverTimer = 0; gameover = false; backgroundParticles = new ParticleList(); audio = null; /* * enemies.AddThing(new TestEnemy(this, 7, 24, TestEnemy.Direction.Left)); * enemies.AddThing(new TestEnemy(this, 12, 11, TestEnemy.Direction.Left)); * enemies.AddThing(new TestEnemy(this, 12, 24, TestEnemy.Direction.Left)); * enemies.AddThing(new TestEnemy(this, 16, 8, TestEnemy.Direction.Left)); * enemies.AddThing(new TestEnemy(this, 22, 17, TestEnemy.Direction.Left)); */ }
public ThingList GetEnemies(GameScene game) { ThingList enemies = new ThingList(); for (int i = 0; i < thingData.Length; i++) { Thing enemy = CreateEnemyFromData(thingData[i], game); if (enemy != null) { enemies.AddThing(enemy); } } return enemies; }
public void AddItem(Item item) { items.AddThing(item); }
public void AddEnemy(Thing thing) { enemyAddList.AddThing(thing); }
public virtual void Tick(GameInput input) { particles.Tick(); if (door != null) { door.Tick(); } items.Tick(input); enemyBullets.Tick(players); playerBullets.Tick(enemies); enemies.Tick(input); if (player != null) { player.Tick(input); } backgroundParticles.Tick(); foreach (Thing enemy in enemyAddList) { enemies.AddThing(enemy); } enemyAddList.Clear(); foreach (Particle particle in particleAddList) { particles.AddParticle(particle); } particleAddList.Clear(); if (player != null) { MoveCamera(player.Focus); } players.SweepRemovedThings(); enemies.SweepRemovedThings(); playerBullets.SweepRemovedBullets(); enemyBullets.SweepRemovedBullets(); items.SweepRemovedThings(); particles.SweepRemovedParticles(); backgroundParticles.SweepRemovedParticles(); if (quakeRadius > 0) { double angle = 2 * Math.PI * random.NextDouble(); quakeVector = quakeRadius * new Vector(Math.Cos(angle), Math.Sin(angle)); quakeRadius -= 0.25; } if (flash > 0) { flash--; } numTicks++; if (cleared) { if (clearTimer < 16) { clearTimer++; } } if (input.Exit && !gameover) { gameover = true; gameoverTimer = 240; } if (player != null) { if (player.Removed) { gameover = true; } } if (gameover) { if (gameoverTimer == 240) { StopMusic(); } if (gameoverTimer < 256) { gameoverTimer++; } } }