using UnityEngine;
using System.Collections;

public class CamControl : MonoBehaviour
{
    public Vector3 posOffset;
    public Vector3 rotOffset;
    public Camera cam;
    public Transform player;
    StateMachine sm;

    private void Awake()
    {
        cam = GetComponent<Camera>();
    }
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player").transform;
        transform.position = player.position + posOffset;
        sm = new StateMachine(this);
    }
    private void Update()
    {
        sm.Update();
    }
    void LateUpdate()
    {
        transform.position = player.position + posOffset;
        transform.eulerAngles = rotOffset;
    }
    public void ChangeState(State state)
    {
        switch (state)
        {
            case State.OneD:
                posOffset = new Vector3(2, 0, -10);
                cam.orthographic = true;
                break;
            case State.TwoD:
                cam.orthographic = true;
                break;
            case State.ThreeD:
                sm.SwitchTo<CamStateThreeD>();
                break;
            default:
                break;
        }
    }
    public enum State
    {
        OneD, TwoD, ThreeD,
    }
}
