Example #1
0
        public void UpdateResearch()
        {
            if (_research == null)
            {
                return;
            }

            _research.Update();
            if (_research.IsDone())
            {
                Mutation newMutation = _research.Mutation;
                _research = null;
                if (OnResearchComplete != null)
                {
                    OnResearchComplete(this, newMutation);
                }
                AddMutation(newMutation);
            }
        }
        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);
        }
Example #3
0
 private void OnMutationRemoved(Mutation mutation)
 {
     UpdateStats();
     mutation.Unapply(this);
 }
Example #4
0
 private void OnMutationAdded(Mutation mutation)
 {
     UpdateStats();
     mutation.Apply(this);
 }
Example #5
0
 public void BeginResearch(Mutation mutation)
 {
     _research = new MutationResearch(mutation);
 }
Example #6
0
 public MutationResearch(Mutation mutation)
 {
     Mutation = mutation;
     Progress = 0.0f;
 }
Example #7
0
 public bool HasMutation(Mutation mutation)
 {
     return(Mutations.Contains(mutation));
 }
 private void OnResearchComplete(Species species, Mutation research)
 {
     BeginRandomResearch(species);
 }