Пример #1
0
    private void Reproduce()
    {
        CreatureController clone = Instantiate(creature, transform.position + transform.right, transform.rotation).GetComponent <CreatureController>();

        int           mutationChance = Random.Range(0, 10);
        CreatureStats cloneStats     = creatureStats.CloneStats();

        if (mutationChance == 0)
        {
            int mutationIndex = Random.Range(0, 3);

            if (mutationIndex == 0)
            {
                cloneStats.speed += initialStats.speed * 0.05f;
            }
            else if (mutationIndex == 1)
            {
                cloneStats.energy += initialStats.energy * 0.05f;
            }
            else if (mutationIndex == 2)
            {
                cloneStats.senseRadius += initialStats.senseRadius * 0.05f;
            }
        }

        clone.creatureStats = cloneStats;
    }