using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraTransitionCollider : MonoBehaviour
{
    [SerializeField] private float m_targetFOV = 60.0f;
    [SerializeField] private float m_targetRotation = 90.0f;
    [SerializeField] private float m_speed = 1.0f;

    public IEnumerator SetCameraFOV(Camera _camera)
    {
        float startFOV = _camera.fieldOfView;
        float timer = 0.0f;
        while (timer < 1.0f)
        {
            _camera.fieldOfView = Mathf.Lerp(startFOV, m_targetFOV, timer);
            timer += Time.deltaTime * m_speed;
            yield return null;
        }
    }

    public IEnumerator SetCameraRotation(Transform _cameraPivot)
    {
        Vector3 cameraRotation = _cameraPivot.rotation.eulerAngles;
        float startRotation = cameraRotation.y;
        float rotation = startRotation;
        float timer = 0.0f;
        while (timer < 1.0f)
        {
            timer += Time.deltaTime * m_speed;
            rotation = Mathf.Lerp(startRotation, m_targetRotation, timer);
            cameraRotation.y = rotation;
            _cameraPivot.rotation = Quaternion.Euler(cameraRotation);
            yield return null;
        }
    }
    
    
}
