private void initalizeMaps(World world) { if (world.civilianMaps != null) return; Console.WriteLine("Initalizing map for world #" + world.GetHashCode() + " with goals at: "); int[][] goals = new int[world.doors.Length][]; for (int x = 0; x < goals.Length; x++) { goals[x] = new int[] { (int) world.doors[x].X, (int) world.doors[x].Y }; Console.WriteLine("X: " + goals[x][0] + "\tY: " + goals[x][1]); if (goals[x][0] > world.worldWidth || goals[x][1] > world.worldHeight) goals[x] = null; } world.civilianMaps = new DijkstraMap[1]; world.civilianMaps[0] = new DijkstraMap(world, world.worldWidth, world.worldHeight, 0, 0, 1, goals); for (int x = 0; x < 27; x++) { NPC civvie = new NPC(new FloatRectangle(), Sprites.spritesDictionary["player"], 4); civvie.ai = new CivilianAI(civvie); if (!worldPools.ContainsKey(world)) worldPools.Add(world, new Queue<Object[]>()); worldPools[world].Enqueue(new Object[] { civvie, null}); } }
private void SpawnCivilians(World world) { if (!Game1.Instance.worldManager.CurrentWorld.canRespawn) return; if (world.manager.civilianCount >= 27) return; Console.WriteLine("Respawning Civilians: " + (27 - world.manager.civilianCount) + " for world: " + world.GetHashCode()); for (int x = 0; x < 27 - world.manager.civilianCount; x++) { NPC civvie = new NPC(new FloatRectangle(), Sprites.spritesDictionary["player"], 4); civvie.ai = new CivilianAI(civvie); if (!worldPools.ContainsKey(world)) worldPools.Add(world, new Queue<Object[]>()); worldPools[world].Enqueue(new Object[] { civvie, null}); } }