コード例 #1
0
 // Public functions
 public void SetCurrentLightGazeToObject(Transform transIn, bool reset)
 {
     currentLightGaze = transIn;
     currentLight.SetCurrentObject(transIn);
     currentLight.SetGazeTypeReset(LookAt.LookTypes.stareAtObject);
     currentLight.SetGazeTypeCurrent(LookAt.LookTypes.stareAtObject);
     if (reset)
     {
         StartCoroutine(StopStaringAtObject(currentLight));
     }
 } // Calls private coroutine StopStaringAtObject() if(reset)
コード例 #2
0
    private IEnumerator StopStaringAtObject(LookAt lightIn) // Resets gazetype to idle
    {
        yield return(new WaitForSeconds(objectStareTimer));

        lightIn.SetGazeTypeCurrent(resetType);
        lightIn.SetGazeTypeReset(resetType);
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;

        _lookAt.SetGazeTypeReset(LookAt.LookTypes.followGaze);

        Debug.DrawRay(transform.position, transform.forward, Color.green);
        RaycastHit hit;

        if (Physics.Raycast(transform.position, transform.forward, out hit, 100))
        {
            MoldContainer mold = hit.collider.gameObject.GetComponent <MoldContainer>();

            if (mold != null)
            {
                if (!runOnce)
                {
                    light.color = Color.red;
                    _LightLookingAtMold.Invoke();
                    _audioManager.FadeSoundIn("HouseCreak", 1);
                    StartCoroutine(_cameraShake.StartShake(cameraShakeMagnitude));
                    runOnce = true;
                }
                currentMoldFocus = mold;
                currentMoldFocus.SetLightFocus(true);
                if (timer > regenTimer)
                {
                    mold.RegenHealth(20);
                    timer = 0;
                }
            }
            else if (mold == null && currentMoldFocus != null)
            {
                if (runOnce)
                {
                    LightStoppedLookingAtMold.Invoke();
                    _audioManager.FadeSoundOut("HouseCreak", 2);
                    StartCoroutine(_cameraShake.StopShake(cameraShakeMagnitude));
                    runOnce = false;
                }
                currentMoldFocus.SetLightFocus(false);
                light.color = Color.white;
                timer       = 0;
            }
        }
    }