using UnityEngine;
using System.Collections;

public class PlayerSimple_Movement : MonoBehaviour
{
    // Delegate type for next state
    public delegate void StateDelegate(out StateDelegate nextState);

    StateDelegate m_state;

	// Initialize system
	void Start ()
    {
        m_state = this.Movestate_Walk;
	}

    // Physics Step
	void FixedUpdate ()
    {
        // Perform step update
        StateDelegate nextState = null;
        this.m_state(out nextState);
        m_state = nextState;
	}



    // Walking on ground
    void Movestate_Walk(out StateDelegate nextState)
    {
        Vector3 t_input = new Vector3(
            Input.GetAxis("MoveY"),
            0,
            -Input.GetAxis("MoveX"));
        if (t_input.magnitude > 0.3f)
        {
            t_input = t_input.normalized;
        }
        else
        {
            t_input = Vector3.zero;
        }
        rigidbody.velocity = transform.rotation * t_input * Time.deltaTime * 600;


        nextState = this.Movestate_Walk;
    }
}
