Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        CameraBehavior cameraBehavior = mainCamera.GetComponent <CameraBehavior> ();

        // Set camera's isGazing by querying entities
        int cameraIsGazingAt            = -1;
        int cameraIsAboutToConverseWith = -1;

        for (int i = 0; i < this.entities.Length; i++)
        {
            Transform entity = this.entities [i];

            if (cameraBehavior.GetIsDisembodied())
            {
                // Set camera's most recent converser
                entity.GetComponent <TargetWatcherBehavior> ().SetBypass(false);
                bool isAboutToConverse = entity.GetComponent <TeleportSelfAndGazer> ().GetIsAboutToConverse();
                if (isAboutToConverse)
                {
                    cameraIsAboutToConverseWith = i;
                }
            }
            else
            {
                // Set camera's most recent gazed at entity
                entity.GetComponent <TargetWatcherBehavior> ().SetBypass(true);
                bool isGazedAt = entity.GetComponent <TeleportSelfAndGazer> ().GetIsGazedAt();
                if (isGazedAt)
                {
                    cameraIsGazingAt = i;
                    // break;
                }

                // Reset position if out of bounds
                // TODO: Track down the root cause of this bug; probably to do with conflicting teleport/gaze settings
                if (!this.PositionIsInWorldBoundaries(entity.position))
                {
                    entity.GetComponent <TeleportSelfAndGazer> ().Reset();
                }
            }
        }
        cameraBehavior.SetIsGazingAt(cameraIsGazingAt);
        cameraBehavior.SetIsAboutToConverseWith(cameraIsAboutToConverseWith);
    }