using UnityEngine;
using System.Collections;

public class PlayerStateManager : MonoBehaviour 
{
	// Set up delegate for state change events
	public delegate void EventHandler(GameObject e);
	public event EventHandler ChangePlayerState;
	
	static PlayerStateManager mInstance;
	
	// Whether there is an instance of the PlayerStateManager class present.
	
	static public bool isActive { get { return mInstance != null; } }
	
	// The instance of the PlayerStateManager class. Will create it if one isn't already around.
	
	static public PlayerStateManager instance
	{
		get
		{
			return mInstance;
		}
	}

	void Awake()
	{
		mInstance = this;
	}
	
	private Enums.PlayerState _currentPlayerState = Enums.PlayerState.Default;
	public Enums.PlayerState currentPlayerState
	{
		get
		{
			return _currentPlayerState;
		}
		
		set
		{
			_currentPlayerState = value;
			if (ChangePlayerState != null)
			{
				ChangePlayerState(this.gameObject);
			}
		}
	}

	public void ResetEvents()
	{
		ChangePlayerState = null;
	}
}
