public AnimalLists AddAnimals(AnimalLists animalLists, IField field, Dictionary <char, Type> bodyAndType) { Console.WriteLine(GetNotification(bodyAndType)); char key; while (Console.KeyAvailable) { key = Console.ReadKey(true).KeyChar; var newAnimalType = GetAnimalTypeFromKeyPress(key, bodyAndType); if (newAnimalType != default(Type)) { if (typeof(IHerbivore).IsAssignableFrom(newAnimalType)) { var animal = (IHerbivore)Activator.CreateInstance(newAnimalType, _standardMovement, _validator, _preySpecial); _spawner.SetSpawnPoint(field, animal); animalLists.Prey.Add(animal); } else if (typeof(ICarnivore).IsAssignableFrom(newAnimalType)) { var animal = (ICarnivore)Activator.CreateInstance(newAnimalType, _standardMovement, _validator, _predatorSpecial); _spawner.SetSpawnPoint(field, animal); animalLists.Hunters.Add(animal); } } } return(animalLists); }
public void CreateAnimal(IField field, AnimalLists animalLists, char animalBody) { if (animalBody == Settings.AntilopeBody) { var creature = new Antilope(_standardMovement, _validator, _preySpecial); _spawn.SetSpawnPoint(field, creature); animalLists.Prey.Add(creature); } else { var creature = new Lion(_standardMovement, _validator, _predSpecial); _spawn.SetSpawnPoint(field, creature); animalLists.Hunters.Add(creature); } }