Exemple #1
0
        public void Initialize(Species species)
        {
            _builder = GetComponent <CreatureBuilder>();

            _species = species;
            _species.OnMutationAdded   += OnMutationAdded;
            _species.OnMutationRemoved += OnMutationRemoved;

            _senseses = GetComponentInChildren <Senses>();

            _steering = GetComponent <SteeringController>();
            _steering.AddBehaviour <PredatorAvoidance>();
            _steering.AddBehaviour <Pursuit>();
            _steering.AddBehaviour <Arrive>();
            _steering.AddBehaviour <Wander>();
            _steering.DisableAll();

            _health  = species.GetStat(StatType.Health);
            Calories = species.CalorieConsumption / 2.0f;

            for (int i = 0; i < _species.MutationCount; i++)
            {
                OnMutationAdded(_species.GetMutation(i));
            }

            UpdateStats();

            RethinkState();

            name += " -" + species.Name;
        }
 public virtual void BeforeRemoveFromSpecies(Species species)
 {
     // Remove any mutations that are prerequisites for us
     for (int i = species.MutationCount - 1; i >= 0; i--)
     {
         Mutation mutation = species.GetMutation(i);
         if (mutation.Prerequisites.Contains(this))
         {
             species.RemoveMutation(mutation);
         }
     }
 }
        public virtual void BeforeAddToSpecies(Species species)
        {
            if (Category == null)
            {
                return;
            }

            for (int i = species.MutationCount - 1; i >= 0; i--)
            {
                Mutation mutation = species.GetMutation(i);
                if (mutation.Category == Category)
                {
                    species.RemoveMutation(mutation);
                }
            }
        }