﻿using UnityEngine;

public class Cam : MonoBehaviour
{
    [SerializeField] float sens;
    float wheelMovement;
    Vector2 movement;
    Camera cam;

    void Start()
    {
        cam = GetComponent<Camera>();
        //zoomIndex = 2;
        //cam.orthographicSize = allowedZooms[zoomIndex];
    }

    float[] allowedZooms = new float[] { 1.8f, 3.6f, 7.2f, 15.0f, 28.8f };
    float delta = 0;
    int zoomIndex;
    void Update()
    {
        //delta += Input.GetAxis("Mouse ScrollWheel") * -sens;
        //if (Mathf.Abs(delta) > 0.25f)
        //{
        //    zoomIndex += ((int)Mathf.Sign(delta));
        //    zoomIndex = Mathf.Clamp(zoomIndex, 0, allowedZooms.Length - 1);
        //    cam.orthographicSize = allowedZooms[zoomIndex];
        //    delta = 0;
        //}

        var newsize = cam.orthographicSize - Input.GetAxis("Mouse ScrollWheel") * sens;
        cam.orthographicSize = Mathf.Clamp(newsize, 1.5f, 15.4f);

        //if (Input.GetKeyDown(KeyCode.W))
        //{
        //    transform.position = new Vector3(transform.position.x, transform.position.y + 1, -10);
        //}

        movement = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

        transform.Translate(movement / 10);
    }
}
