using UnityEngine;
using System.Collections;

public class SetPlayerStateScript : MonoBehaviour 
{
	private Rigidbody2D myRigidbody;
	private Transform myTransform;
	public Animator anim;

	private float currentInvincibleTime;

	// Use this for initialization
	void Awake()
	{
		myRigidbody = rigidbody2D;
		myTransform = transform;
	}

	void OnEnable()
	{
		Initialize();
	}

	void Update()
	{

	}
	
	public void Initialize() 
	{
		// Set up event listeners for state changes
		PlayerStateManager.instance.ChangePlayerState += ChangePlayerState;
	}

	private void ChangePlayerState(GameObject dispatcher)
	{
		switch (PlayerStateManager.instance.currentPlayerState)
		{
			case Enums.PlayerState.Morphing:
			{
				Debug.Log("stopping animation");
//				anim.SetBool("isMorphed", true);
				anim.enabled = false;
				break;
			}
			case Enums.PlayerState.Default:
			{
				anim.enabled = true;
//				anim.SetBool("isMorphed", false);
				break;
			}
		}
	}
}
