예제 #1
0
 void OnTriggerEnter(Collider col)
 {
     if (state != State.IDLE || col.tag != "Player")
     {
         return;
     }
     cam.SetTarget(newTarget);
     camCon.Player = newTarget.gameObject;
     state         = State.BEFORE;
 }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        currentDistance = closestEnemyDistance();
        if (currentDistance < WarningDistance && chasingEnemy != null)
        {
            blinkSpeed = Mathf.Lerp(BlinkSpeedNear, BlinkSpeedFar, currentDistance / WarningDistance);
            alpha      = Mathf.Lerp(0, MaxAlpha, blinkTimer / blinkSpeed);
            shake.ShakeScreen(1, alpha * shakeFactor);
            if (Vector3.Angle(player.transform.forward, chasingEnemy.transform.forward) < MouthViewAngle && currentDistance < MouthViewDistance && camTarget != null)
            {
                if (!camSet)
                {
                    camSet = true;
                    cam.SetTarget(camTarget);
                    cam.setSpeed(CameraSnapSpeed, CameraSnapSpeed);
                }
            }
            else
            {
                if (camSet)
                {
                    cam.SetTarget(player.transform);
                    cam.setSpeed(originalCameraSnapSpeed, originalCameraSnapSpeed);
                    camSet = false;
                }
            }
        }
        else
        {
            if (camSet)
            {
                cam.setSpeed(originalCameraSnapSpeed, originalCameraSnapSpeed);
                cam.SetTarget(player.transform);
                camSet = false;
            }
            chasingEnemy = null;
            shake.ShakeScreen(0, 0);
            blinkSpeed = BlinkSpeedFar;
            alpha      = 0;
        }

        if (blinkTimer <= 0 || blinkTimer >= blinkSpeed)
        {
            blinkTimer     = Mathf.Max(0, fadeDirection * blinkSpeed);
            fadeDirection *= -1;
        }
        blinkTimer += (fadeDirection * Time.deltaTime);
    }