public void HitEnemy(Enemy e) { if (e.freeze > 0) { if (e is Enemy4 || !isMainEnemy(e)) { paused = true; Dead_reset = 96; } else { points.Add(new PopupPoints(e.PointValue, new Point(e.currentPos.X + 16, e.currentPos.Y + 6), 64)); screen.score += e.PointValue; if (e.respawns) { MapSpawner spawnfrom = spawners[GlobalRandom.random.Next(spawners.Count)]; spawnfrom.AddDeadCreep(e.etype, e.respawntime); } AllEnemies.Remove(e); } } else if (!paused) { paused = true; Dead_reset = 96; } }
public void Update() { if (KeyboardInputManager.isKeyPressed(Microsoft.Xna.Framework.Input.Keys.NumPad9)) { Globals.DEBUG = !Globals.DEBUG; } if (currentBonus > 0) { currentBonus--; } if (E_Life == null) { if (GlobalRandom.random.NextDouble() < ELIFE_SPAWN_CHANCE) { Point pos = GlobalRandom.RandomFrom <Point>(myData.espawn_possible); E_Life = new ExtraLife(pos, Globals.ETIME); myData.espawn_possible.Remove(pos); } } else { Point tmp = E_Life.currentPos; E_Life.Update(this); if (E_Life == null) { myData.espawn_possible.Add(tmp); } } if (bonus == null) { if (GlobalRandom.random.NextDouble() < ELIFE_SPAWN_CHANCE * 1.5) { Point pos = GlobalRandom.RandomFrom <Point>(myData.espawn_possible); bonus = new Bonus(pos, Globals.ETIME * 2); myData.espawn_possible.Remove(pos); } } else { Point tmp = bonus.currentPos; bonus.Update(this); if (bonus == null) { myData.espawn_possible.Add(tmp); } } if (allNotes.Count == 0) { screen.AdvanceLevel(); } foreach (PopupPoints p in points) { p.update(); } points.RemoveAll(x => !x.isAlive); if (!paused) { if (!timePause) { currentTime++; } foreach (SpawnOrder order in myData.spawnOrders) { if (order.time == currentTime) { foreach (MapSpawner spawn in spawners) { if (spawn.spawn.name.Equals(order.from)) { spawn.AddToQueue(order.type); } } } } foreach (MapSpawner spawn in spawners) { spawn.Update(this); } player.Update(this); foreach (NoteProjectile proj in NoteProj) { proj.Update(this); } if (!player.isGhost) { for (int i = allNotes.Count - 1; i >= 0; i--) { if (Entity.EntitiesIntersect_Rect(player, allNotes[i], 16)) { screen.score += 20; NoteProj.Add(new NoteProjectile(allNotes[i].currentPos, player.direction)); allNotes.RemoveAt(i); } } } for (int i = NoteProj.Count - 1; i >= 0; i--) { if (NoteProj[i].currentPos.X < -16 || NoteProj[i].currentPos.Y > 14 * 16 || NoteProj[i].currentPos.Y < -32 || NoteProj[i].currentPos.X >= 15 * 16) { NoteProj.RemoveAt(i); } else { for (int j = AllEnemies.Count - 1; j >= 0; j--) { if (Entity.EntitiesIntersect_Rect(NoteProj[i], AllEnemies[j])) { points.Add(new PopupPoints(AllEnemies[j].PointValue * NoteProj[i].multiplier++, new Point(AllEnemies[j].currentPos.X + 16, AllEnemies[j].currentPos.Y + 6), 64)); screen.score += AllEnemies[j].PointValue * NoteProj[i].multiplier++; if (AllEnemies[j].respawns) { MapSpawner spawnfrom = spawners[GlobalRandom.random.Next(spawners.Count)]; spawnfrom.AddDeadCreep(AllEnemies[j].etype, AllEnemies[j].respawntime); } AllEnemies.RemoveAt(j); } } } } for (int j = AllEnemies.Count - 1; j >= 0; j--) { if (AllEnemies[j].freeze == 0 || !isMainEnemy(AllEnemies[j])) { AllEnemies[j].Update(this); } else { AllEnemies[j].freeze--; } } if (!player.isGhost) { for (int j = AllEnemies.Count - 1; j >= 0; j--) { if (Entity.EntitiesIntersect_Rect(AllEnemies[j], player, 8 * 16)) { HitEnemy(AllEnemies[j]); } } } } if (Dead_reset > 0 && paused) { Dead_reset--; if (Dead_reset == 1) { screen.PlayerDied(); paused = false; AllEnemies.Clear(); player = new Player(new Point(myData.PlayerSpawn.X * Globals.stdTile, myData.PlayerSpawn.Y * Globals.stdTile), this); NoteProj.Clear(); foreach (MapSpawner spawn in spawners) { spawn.reset(); } foreach (SpawnOrder sorder in myData.spawnOrders) { if (sorder.time < currentTime) { foreach (MapSpawner spawn in spawners) { if (spawn.spawn.name.Equals(sorder.from)) { spawn.AddToQueue(sorder.type); } } } } } } }