public Creature GenerateRandomCreature(Map map, Creature player) { Random r = RandomNumberGenerator.GlobalRandom; Creature enemy = new CreatureGenerator().GetRandomCreature(); bool success = false; while(success == false) { success = map[r.Next(map.MapWidth), r.Next(map.MapHeight)].putCreature(enemy); } AI ai = new AI(map, player, enemy); enemy.AI = ai; return enemy; }
public List<Creature> GenerateCreatures(Map map, Creature player) { List<Creature> cList = new List<Creature>(); if (SizeX > 2 && SizeY > 2) { int creatureCount = Math.Min((SizeX - 2) * (SizeY - 2), 1 + r.Next(4)); for (int i = 0; i < creatureCount; ++i) { Creature enemy = new CreatureGenerator().GetRandomCreature(); bool success = false; while (success == false) { success = map[X + 1 + r.Next(SizeX - 2), Y + 1 + r.Next(SizeY - 2)].putCreature(enemy); } AI ai = new AI(map, player, enemy); enemy.AI = ai; cList.Add(enemy); } } return cList; }