Esempio n. 1
0
    private bool spottedFlag;       // becomes true if the character was ever spotted

    void Start()
    {
        gc = GameObject.Find("GameController").GetComponent <GameController>();
        screenDivisions  = gc.screenDivisions;
        observeThreshold = gc.observeThreshold;
        visible          = false;
        beingObserved    = false;
        beingIgnored     = false;

        currentScreenTime = 0f;
        observeTimer      = 0f;

        spotStage = SpotStage.OFF;
        if (camCon == null || cam == null)
        {
            camCon = GameObject.Find("Main Camera").GetComponent <CameraController>();
            cam    = GameObject.Find("Main Camera").GetComponent <Camera>();
        }
    }
Esempio n. 2
0
    // A character is "spotted" if the player's view is a closeup/midshot of an area, and a spottable character enters and exits the players view ALL WITHIN THE PERIPHERY OF THEIR VISION
    // A character can only be spotted if they have not yet been observed - because a Spot is like spotting something out of the corner of your eye


    private void CheckSpotted()
    {
        //Debug.Log("yeet?");
        RaycastHit hit;
        //Debug.Log(ray + ", " + transform.position);
        Ray objRay = cam.ScreenPointToRay(cam.WorldToScreenPoint(transform.position));

        if (!spottedFlag)
        {
            if (camCon.canSpot())
            {
                Vector2 sector = getCurrentScreenSector();
                //DescribeCurrentScreenSector();
                if (sector.x <= 2f || sector.x >= screenDivisions - 2 || sector.y <= 2f || sector.y >= screenDivisions - 2)
                {
                    if (Physics.Raycast(objRay, out hit, Mathf.Infinity))
                    {
                        Transform objectHit = hit.transform;
                        if (objectHit.name == transform.name)
                        {
                            if (spotStage == SpotStage.OFF)
                            {
                                //Debug.Log("Hmm, something there!");
                                spotStage = SpotStage.ON;
                            }
                        }
                        else
                        {
                            if (spotStage == SpotStage.ON)
                            {
                                spottedFlag = true;
                                //Debug.Log("Hey! I think you spotted " + transform.name + " in the corner of your eye!");
                            }
                        }
                    }
                }
                else
                {
                    //Debug.Log("NOI IN RANGE!");
                }
            }
        }
    }