private void PrintCreaturesNextStatus(CreatureList currentCreatures) { foreach (Creature creature in currentCreatures) { string phraseAboutHealth = "."; string nextStatusReadable = ""; if (creature.Health <= 0.0) { phraseAboutHealth = creature.FoodCollectedLastDay < FoodToSurvive? ", and it was fatally injured in a fight." : $", but unfortunately it was fatally injured in a fight."; } switch (creature.NextStatus) { case LifeStatus.Die: nextStatusReadable = "die"; break; case LifeStatus.Reproduce: nextStatusReadable = "reproduce and have offspring"; break; case LifeStatus.StayAlive: nextStatusReadable = "stay alive"; break; } Log.Information($"Creature ID#{creature.Id} collected {creature.FoodCollectedLastDay:N2} food{phraseAboutHealth} So, next day, it will {nextStatusReadable}."); } Log.Information(""); }
internal void CheckSurroundings(CreatureList creatures, List <Food> food) { if (CreatureType.IsHerbivore) { FoodInReachIds = CheckFoodInReach(food); } CreaturesInReachIds = CheckCreaturesInReach(creatures); }
private void PrintCreatures(CreatureList currentCreatures, int day, bool beginningOfDay) { Log.Information(""); Log.Information($"Creatures {(beginningOfDay ? "that start" : "at the end of")} day {day}:"); foreach (Creature creature in currentCreatures) { Log.Information($"Creature ID#{creature.Id}, Health {creature.Health} ({creature.CreatureType.Name})"); } Log.Information(""); }
public List <int> CheckCreaturesInReach(CreatureList creatures) { List <int> creaturesInReach = new List <int>(); foreach (Creature creature in creatures) { if (creature.Id != Id && Position.InReach(creature.Position, Reach)) { creaturesInReach.Add(creature.Id); creature.ReachingCreaturesIds.Add(Id); } } return(creaturesInReach); }
public CreatureList(CreatureList source) { creatures = source.creatures.ConvertAll(creature => new Creature(creature)); lastId = source.lastId; }
public Population(Population source) { CreatureTypes = source.CreatureTypes; Creatures = new CreatureList(source.Creatures); }
public Population(CreatureTypeList creatureTypes) { CreatureTypes = creatureTypes; Creatures = new CreatureList(); }