private Species GenerateInitialSpecies(EaterType eaterType, float calorieLimit)
        {
            List <Mutation> heads = AllMutations.Where(mutation => {
                HeadMutation head = mutation as HeadMutation;
                return(head != null && head.Type == eaterType);
            }).ToList();

            List <Mutation> remainingMutations = AllMutations.Where(mutation => {
                return(!(mutation is HeadMutation) && !(mutation is TorsoMutation));
            }).ToList();

            Species newSpecies = new Species("Species");

            newSpecies.AddMutation(_torsos[Random.Range(0, _torsos.Count)]);
            newSpecies.AddMutation(heads[Random.Range(0, heads.Count)]);

            while (remainingMutations.Count > 0 && newSpecies.CalorieConsumption < calorieLimit)
            {
                Mutation newMutation = remainingMutations[Random.Range(0, remainingMutations.Count)];

                newSpecies.AddMutation(newMutation);

                for (int i = remainingMutations.Count - 1; i >= 0; i--)
                {
                    MutationCategory category = remainingMutations[i].Category;
                    if (category != null && category == newMutation.Category)
                    {
                        remainingMutations.RemoveAt(i);
                    }
                }
            }

            newSpecies.OnResearchComplete += OnResearchComplete;
            Species.Add(newSpecies);
            BeginRandomResearch(newSpecies);

            return(newSpecies);
        }
Exemple #2
0
 /// <summary>
 /// Determine if a certain eater type can eat this type of food
 /// </summary>
 /// <param name="eater">An EaterType enumeration element</param>
 /// <returns>True if this eater type can eat this food item, false otherwise</returns>
 public override bool IsGoodFor(EaterType eater)
 {
     return (eater == EaterType.Carnivora) || (eater == EaterType.Omnivorous);
 }
Exemple #3
0
 //Each food object must define whether the object is good for a eater type
 //implementation of the method in the Interfaces is delegated in turn to sub-classes
 public abstract bool IsGoodFor(EaterType eType);
Exemple #4
0
 public TestData(Species item, EaterType eater)
 {
     this.item = item;
      this.eater = eater;
 }