public MinionManager(Game game) { _game = game; _random = new Random(); holder = new MinionsHolder(allMinions); allMinions.Add(slowMinions); allMinions.Add(fastMinions); fastMinions.Add(crawlers); slowMinions.Add(noobs); slowMinions.Add(lizards); }
public void SpawnMinions() { if (_game.leftToSpawn == 0) { (noobs as MinionViewGroup).MinionComponents.Clear(); (crawlers as MinionViewGroup).MinionComponents.Clear(); (lizards as MinionViewGroup).MinionComponents.Clear(); _game.leftToSpawn = -1; Task.Factory.StartNew(() => { Thread.Sleep(GameUtils.WAVE_INTERVAL); _game.Hub.Clients.All.SendAsync("notifyConsole", string.Format("Wave {0} starting now", _game.wave + 1)); _game.wave++; _game.leftToSpawn = 5 + (_game.wave * 3); for (int j = 0; j < _game.leftToSpawn; j++) { var min = GetMinionToSpawn(); minions.Enqueue(min); if (min is Noob) { noobs.Add(new MinionView("NOOB")); } if (min is Lizard) { lizards.Add(new MinionView("LIZARD")); } if (min is Crawler) { crawlers.Add(new MinionView("CRAWLER")); } } //_game.leftToSpawn = 0; }); } else if (_game.leftToSpawn > 0 && _game.ticksBeforeSpawn-- == 0) { if (minions.Count > 0) { SpawnMinion(minions.Dequeue()); } _game.ticksBeforeSpawn = GameUtils.SPAWN_EVERY_X_TICK; } }