using System;
using UnityEngine;

namespace Assets
{
    public class CameraControl : MonoBehaviour {

        public float moveSpeed = 0.5f;
        public float scrollSpeed = 10f;
        
        private bool _shouldMove;

        private void Update()
        {
            _shouldMove = Input.GetMouseButton(2);
        }

        void FixedUpdate()
        {
            if (Math.Abs(Input.GetAxis("Mouse ScrollWheel")) > float.Epsilon)
            {
                transform.localPosition += scrollSpeed * Input.GetAxis("Mouse ScrollWheel") * transform.forward;
            }

            if (_shouldMove)
            {
                transform.localPosition += moveSpeed * (-Input.GetAxis("Mouse X") * transform.right + Input.GetAxis("Mouse Y") * Vector3.back);
            }
        }
    }
}
