using UnityEngine;
using System.Collections;

public class InMechanic : MonoBehaviour {

	#region Private Variables
	[SerializeField]
	private Sprite _happy;

	[SerializeField]
	private Sprite _disappointed;

	[SerializeField]
	private SpriteRenderer _frame;
	
	private Sprite _default;
	private IconControl[] _icons;
	#endregion


	#region Events
	void Start () {

		_icons = GameObject.FindObjectsOfType <IconControl> ();
		_default = _frame.sprite;
		
	}
	#endregion


	#region Methods
	public bool Check () {
		
		string activeTag = string.Empty;

		foreach (IconControl icon in _icons) {
			if (activeTag == string.Empty)
				activeTag = icon.collidedWith;

			if (icon.collidedWith != activeTag) {
				_frame.sprite = _default;
				return false;
			}
		}

		switch (activeTag) {
			
			case "Hole":
				_frame.sprite = _happy;
				break;

			case "Pedestal":
				_frame.sprite = _disappointed;
				break;

		}

		return true;

	}
	#endregion
	
}
