예제 #1
0
    private IEnumerator BossSeenPlayerTooLongEnum(Vector3 bossPos)
    {
        // big red light, play sound
        playerLightManager.BossSeenPlayerTooLong();
        playerSoundManager.BossCaughtPlayer();
        movement.canMove = false;

        // lerp to look at boss
        float      elapsedTime = 0f;
        float      duration    = 1f;
        Quaternion startRot    = transform.rotation;
        Quaternion targetRot   = Quaternion.LookRotation((bossPos - transform.position).normalized, Vector3.up);

        while (elapsedTime < duration)
        {
            elapsedTime       += Time.deltaTime;
            transform.rotation = Quaternion.Lerp(startRot, targetRot, elapsedTime / duration);
            yield return(null);
        }

        transform.rotation = targetRot;

        // zoom in
        elapsedTime = 0f;
        duration    = .3f;
        Camera cam       = camFX.GetComponent <Camera>();
        float  startFOV  = cam.fieldOfView;
        float  targetFOV = 30f;

        while (elapsedTime < duration)
        {
            elapsedTime    += Time.deltaTime;
            cam.fieldOfView = Mathf.SmoothStep(startFOV, targetFOV, elapsedTime / duration);
            yield return(null);
        }
        cam.fieldOfView = targetFOV;

        yield return(new WaitForSeconds(.5f));

        TakeDamage(1);

        yield return(new WaitForSeconds(.5f));

        // take damage, shake, heavy impact
        camFX.HighShake();
        playerSoundManager.HeavyImpact();
        playerSoundManager.BossAttackPlayer();
        cam.fieldOfView = startFOV;
        movement.BossPush(bossPos);
        movement.canMove = true;
    }