Example #1
0
    public Situation BuildSituation(int cameraNumber)
    {
        Camera cam = cameras [cameraNumber];

        Situation sit = new Situation();

        Plane[] planes = GeometryUtility.CalculateFrustumPlanes(cam);

        GameObject[] actors = GameObject.FindGameObjectsWithTag("Actor");
        foreach (GameObject g in actors)
        {
            Actors actor = g.GetComponent <Actors>();
            if (actor == null)
            {
                continue;
            }
            if (GeometryUtility.TestPlanesAABB(planes,
                                               actor.GetComponent <CapsuleCollider>().bounds))
            {
                if (cam.transform.parent)
                {
                    BoxCollider b = cam.transform.parent.GetComponentInChildren <BoxCollider>();
                    if (b.bounds.Intersects(actor.GetComponent <CapsuleCollider>().bounds))
                    {
                        sit.actorNames.Add(actor.actorName);
                        sit.actorStates.Add(actor.GetActorFearState());
                    }
                }
            }
        }
        sit.cameraNum = cameraNumber;
        return(sit);
    }