Ejemplo n.º 1
0
    IEnumerator FindKillableAgents(float delay)
    {
        while (true)
        {
            yield return(new WaitForSeconds(delay));

            Collider[] targetsInRadius = Physics.OverlapSphere(transform.position, radius, targetLayer);

            for (int i = 0; i < targetsInRadius.Length; i++)
            {
                Agent      info            = (targetsInRadius[i].gameObject).GetComponent <Agent>();
                GameObject eventObs        = Instantiate(obs, transform.position + new Vector3(0, 1, 0), Quaternion.identity);
                Observable observableFacts = eventObs.GetComponent <Observable>();
                Debug.Log(observableFacts);
                string   label  = "killed";
                string[] values = new string[] { gameObject.name, info.agentName };

                observableFacts.AddObservableFact(label, values);


                Destroy(eventObs.gameObject, 2);

                GameObject deadObs = Instantiate(obs, transform.position, Quaternion.identity);
                observableFacts = deadObs.GetComponent <Observable>();
                label           = "dead";
                values          = new string[] { info.agentName, "level 1", "day" };
                observableFacts.AddObservableFact(label, values);

                Destroy(targetsInRadius[i].gameObject);
            }
        }
    }