using UnityEngine;
using System.Collections;

public class MyClickHandler : MonoBehaviour {

	MyManager manager;
	SpriteRenderer _spriteRenderer;


	Vector2 startPosition = new Vector2(17.29f,0.5f);

	string _name = "";

	Color _hoverColor = new Color(1f,1f,1f,0.5f);
	Color _resetColor = new Color(1f,1f,1f,1f);

	void Awake()
	{
		manager = GameObject.Find("MyManager").GetComponent<MyManager>();
		_spriteRenderer = transform.GetComponent<SpriteRenderer>();
	}

	void Start()
	{
		_name = gameObject.name;

	}

	void OnTriggerEnter2D(Collider2D col)
	{
		ChangeLocation();
	}

	void OnMouseDown()
	{
		ChangeLocation();
	}

	void ChangeLocation()
	{
		switch(_name)
		{
		case "wmHome":
			manager.player.SetLocation("Home");
			break;
			
		case "wmHomeSteeple":
			manager.player.SetLocation("HomeSteeple");
			break;
			
		case "wmVirginFoods":
			manager.player.SetLocation("VirginFoods");
			break;
			
		case "craftButton":
			
			break;
			
		case "backbutton 1":
			manager.player.SetLocation("Home");
			break;
			
		case "craftbutton":
			manager.workbenchManager.Craft();
			break;

		case "startButton":
			manager.player.SetLocation("Home");
			break;

		case "creditsButton":
			manager.player.SetLocation("Credits");
			break;

		case "backButton":
			manager.player.SetLocation("Start");
			break;

		case "quitButton":
			Debug.Log("quitting game you quitter");
			Application.Quit();
			break;
			
		default:
			break;
		}
	}

	void OnMouseEnter()
	{
		_spriteRenderer.color = _hoverColor;
	}

	void OnMouseExit()
	{
		_spriteRenderer.color = _resetColor;
	}
}
