Esempio n. 1
0
    // Start is called before the first frame update
    void Start()
    {
        if (species != Species.plant)
        {
            if (young == true)
            {
                transform.localScale = Vector3.one * 0.4f;
            }

            eatDuration = 20;

            trigger           = this.gameObject.AddComponent <SphereCollider>();
            trigger.isTrigger = true;
            diet           = genes.Diet;
            speed          = genes.speed;
            visonDistance  = genes.visonDistance;
            agent          = GetComponent <NavMeshAgent>();
            agent.speed    = speed;
            walkPointRange = visonDistance * 4;
            trigger.radius = visonDistance;

            cam = Camera.main;

            genes.isMale = (Random.value < 0.5);

            if (didInherit == false && motherGenes != null && FatherGenes != null)
            {
                genes.InheritGenes(motherGenes, FatherGenes);

                didInherit = true;
            }
        }
        else
        {
            if (young == true)
            {
                transform.localScale = Vector3.zero;
            }

            criticalPercent = Random.Range(0.1f, 1);

            if (transform.position.y != -0.7f)
            {
                Vector3 newPos = new Vector3(transform.position.x, -0.7f, transform.position.z);

                transform.position = newPos;
            }
        }
    }