void Awake() { state = new CreatureState(); metabolism = new CreatureMetabolism(gameObject, settings.StartingEnergy); size = new CreatureSize(sizeSettings, settings.Size, metabolism, transform); sense = new CreatureSense(senseSettings, settings.SenseRadius, state, metabolism, transform); movement = new CreatureMovement(velocitySettings, settings.Velocity, state, metabolism, sense, transform); creatureFactory = new CreatureFactory(gameObject, this, metabolism, transform, settings.Size); }
/// <summary> /// Constructor for creature velocity /// </summary> /// <param name="settings">Ability settings</param> /// <param name="velocity">Velocity value</param> /// <param name="state">Creature state</param> /// <param name="metabolism">Creature metabolism</param> /// <param name="sense">Creature sense</param> /// <param name="transform">Creature transform</param> public CreatureMovement(AbilitySettings settings, float velocity, ICreatureState state, ICreatureMetabolism metabolism, ICreatureSense sense, Transform transform) { Velocity = velocity; this.state = state; this.transform = transform; this.settings = settings; this.metabolism = metabolism; this.sense = sense; moveSpot = CreateMoveSpot(); }
/// <summary> /// Mutates creature attributes, based on parent creature attributes /// </summary> /// <param name="parent">parent creature</param> public void Mutate(ICreature parent) { float newStartingEnergy = MutateAttribute(parent.StartingEnergy); float newSize = Mathf.Clamp(MutateAttribute(parent.Size), 0.1f, 1000f); float newVelocity = MutateAttribute(parent.Velocity); float newSenseRadius = MutateAttribute(parent.SenseRadius); metabolism = new CreatureMetabolism(gameObject, newStartingEnergy); size = new CreatureSize(sizeSettings, newSize, metabolism, transform); sense = new CreatureSense(senseSettings, newSenseRadius, state, metabolism, transform); movement = new CreatureMovement(velocitySettings, newVelocity, state, metabolism, sense, transform); creatureFactory = new CreatureFactory(gameObject, this, metabolism, transform, newSize); }