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

public class FocusZoomer : MonoBehaviour
{
    public static FocusZoomer instance;

    private Vector2 minMaxZoom = new Vector2(1f, 3f);
    private float defaultZoom = 2f;
    private float currentZoom;
    private float zoomSpeed = 80f;

    private void Awake()
    {
        instance = this;
    }

    private void Start()
    {
        ResetZoom();
    }

    public void ResetZoom()
    {
        SetZ(defaultZoom);
        currentZoom = defaultZoom;
    }

    private void Update()
    {
        currentZoom += Input.GetAxis("Mouse ScrollWheel") * zoomSpeed * Time.deltaTime;
        currentZoom = Mathf.Clamp(currentZoom, minMaxZoom.x, minMaxZoom.y);
        SetZ(currentZoom);
    }

    private void SetZ(float pos)
    {
        transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, pos);
    }
}