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); } }
public GameEngine() { var rand = new Random(); var spawn = new Spawner(rand); var validator = new CoordinateValidator(); var pointCalc = new AxisPointCalculations(); var correctPlacement = new PlacementCorrection(); var predatorSpecial = new PredatorEssentials(validator, pointCalc, correctPlacement); var preySpecial = new PreyEssentials(validator, correctPlacement); var standardMovement = new Movement(rand, validator); var fieldToStrConverter = new FieldToString(); _factory = new SavannaFactory (validator, spawn, standardMovement, predatorSpecial, preySpecial); _field = new Field(); _displayer = new ConsoleFieldDisplayer(fieldToStrConverter); _user = new ConsoleUserAddAnimals (standardMovement, validator, predatorSpecial, preySpecial, spawn); _animalLists = new AnimalLists(); _assemblyLoader = new AssemblyLoader(validator, standardMovement, preySpecial, predatorSpecial); }
private void UserAddAnimals(Dictionary <char, Type> bodyAndType) { _displayer.DisplayField(_field); _animalLists = _user.AddAnimals(_animalLists, _field, bodyAndType); }