Exemplo n.º 1
0
    /// <summary>
    /// Intermittently announces the scent? Or only when animals move nearby?
    /// POSSIBLE SOLUTION: keep a list of all scents attached to this tile, only "announce" scents in ontriggerenter
    /// </summary>
    void AnnounceScent()//performed how often? via what?
    {
        if (announceCycleBusy)
        {
            return;
        }
        StartCoroutine(AnnounceCycleCoroutine());
        List <GameObject> animalsInRadius = new List <GameObject>();

        Collider[] hitColliders = Physics.OverlapSphere(this.gameObject.transform.position, scentRadius);
        int        i            = 0;

        while (i < hitColliders.Length)
        {
            if (hitColliders[i].gameObject.GetComponent <SenseSmell>())
            {
                animalsInRadius.Add(hitColliders[i].gameObject);
            }
            i++;
        }
        foreach (GameObject g in animalsInRadius)
        {
            SenseSmell smell = g.GetComponent <SenseSmell>();
            smell.ReceiveScent(this);
        }
    }
Exemplo n.º 2
0
    // Start is called before the first frame update
    void Start()
    {
        movementScript = GetComponent <Movement>();
        smellScript    = GetComponent <SenseSmell>();
        sightScript    = GetComponent <SenseSight>();
        hearingScript  = GetComponent <SenseHearing>();

        hunger = Random.Range(.7f, 1f);
        thirst = Random.Range(.7f, 1f);
        if (isPredator)
        {
            hunger = .45f;
        }
    }
Exemplo n.º 3
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.GetComponent <Scent>())
     {
         Scent animalScent = other.GetComponent <Scent>();
         if (animalScent.scentStrength > scentStrength)
         {
             AddScent(animalScent);
         }
     }
     if (other.GetComponent <SenseSmell>() && isTurf)
     {
         SenseSmell smell = other.GetComponent <SenseSmell>();
         smell.ReceiveScent(this);
     }
 }