using UnityEngine;
using System.Collections;

public class ConnectMechanic : MonoBehaviour {

	#region Private Variables
	private ConnectStage _stage = (ConnectStage) 0;
	#endregion


	#region Getters and Setters
	public ConnectStage stage {
		get {
			return _stage;
		}
		private set {
			_stage = value;
		}
	}
	#endregion


	#region Methods
	public void CheckStage () {

		switch (stage) {
			case ConnectStage.RemoveCages:

				if (GameObject.FindObjectsOfType <HatControl> ().Length == 0)
					NextStage ();

				break;

			case ConnectStage.ConnectWires:

				PersonaControl[] _personas = GameObject.FindObjectsOfType <PersonaControl> ();
				bool flag = true;

				foreach (PersonaControl pc in _personas)
					if (pc.renderer.color.a > 1f)
						flag = false;
				
				if (flag)
					NextStage ();

				break;

			case ConnectStage.WearPersonas:
				
				if (GameObject.FindObjectsOfType <PersonaControl> ().Length == 1)
					NextStage ();
				
				break;
			
		}
		
	}


	void NextStage () {

		stage = (ConnectStage) ((int) _stage + 1);

	}
	#endregion

}
