Exemplo n.º 1
0
        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("");
        }
Exemplo n.º 2
0
 internal void CheckSurroundings(CreatureList creatures, List <Food> food)
 {
     if (CreatureType.IsHerbivore)
     {
         FoodInReachIds = CheckFoodInReach(food);
     }
     CreaturesInReachIds = CheckCreaturesInReach(creatures);
 }
Exemplo n.º 3
0
 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("");
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public CreatureList(CreatureList source)
 {
     creatures = source.creatures.ConvertAll(creature => new Creature(creature));
     lastId    = source.lastId;
 }
Exemplo n.º 6
0
 public Population(Population source)
 {
     CreatureTypes = source.CreatureTypes;
     Creatures     = new CreatureList(source.Creatures);
 }
Exemplo n.º 7
0
 public Population(CreatureTypeList creatureTypes)
 {
     CreatureTypes = creatureTypes;
     Creatures     = new CreatureList();
 }