using UnityEngine;
using System.Collections;

public class CricketAnimationControl : MonoBehaviour {

	public Animator MASTER;
	public Rigidbody2D me;
	public enum CricketAnimatuionState {
		TakeOff=0,
		Land=1,
		Idle=2
	};
	CricketAnimatuionState currentState;
	// Use this for initialization
	void Start () {
		me = gameObject.GetComponent<Rigidbody2D> ();
		currentState = CricketAnimatuionState.Idle;
	}
	
	// Update is called once per frame
	void Update () {
		if (MASTER == null)
			return;
		if (me.velocity.y < 0) {
			MASTER.SetInteger ("State", (int)CricketAnimatuionState.Land);
			currentState=CricketAnimatuionState.Land;
		} 
		else if (me.velocity.y > 0 && me.velocity.x!=0) {
			MASTER.SetInteger ("State", (int)CricketAnimatuionState.TakeOff);
			currentState = CricketAnimatuionState.TakeOff;
		
		} else if(currentState!=CricketAnimatuionState.Idle){
				currentState=CricketAnimatuionState.Idle;
			MASTER.SetInteger ("State", (int)CricketAnimatuionState.Idle);
			
		}

	}
}
