using UnityEngine;
using System.Collections;

public class PlayerSimple_Camera : MonoBehaviour
{
    protected Transform m_camera;
    protected Vector3 m_camera_angle;
    protected Vector3 m_camera_offset;
    protected Vector3 m_person_angle;
    public delegate void StateDelegate(out StateDelegate nextState);

    StateDelegate m_state;

    // Look around, like normal
    void Lookstate_Normal(out StateDelegate nextState)
    {
        Screen.lockCursor = true;

        m_person_angle.y += Input.GetAxis("TurnX");
        m_camera_angle.x -= Input.GetAxis("TurnY");
        transform.rotation = Quaternion.Euler(m_person_angle);
        m_camera.rotation = transform.rotation * Quaternion.Euler(m_camera_angle);
        m_camera.position = transform.position + transform.rotation * m_camera_offset;

        nextState = this.Lookstate_Normal;
    }


	void Start ()
    {
        m_camera = transform.Find("Camera");
        m_camera_angle = new Vector3(0, 0, 0);
        m_person_angle = new Vector3(0, 0, 0);
        m_camera_offset = new Vector3(0, 4.4f, 0);

        m_state = this.Lookstate_Normal;
	}
	
	void Update ()
    {
        StateDelegate nextState = null;
        this.m_state(out nextState);
        m_state = nextState;
	}
}
