using UnityEngine;
using System.Collections;

public class EsferaCollision : MonoBehaviour {
	public GameObject manager;

	// Use this for initialization
	void Start () {
		manager = GameObject.Find ("Level2Manager");
	}
	
	// Update is called once per frame
	void Update () {
		if (PlayerPrefs.GetInt ("pauselvl2") != 1) {

		}
	}
	void OnCollisionEnter(Collision coll){
		colisionconelemento (coll.gameObject);
	}
	void colisionconelemento(GameObject coll){
		Debug.Log ("entro"+coll.name);
		if (coll.name == "Control") {
			PlayerPrefs.SetInt ("pauselvl2", 1);
			//if (manager.GetComponent<Level2Manag> ().tiempo > manager.GetComponent<Level2Manag> ().tiempototal)
			//	manager.GetComponent<Level2Manag> ().tiempototal = manager.GetComponent<Level2Manag> ().tiempo;
		}
		switch (coll.tag) {
	
		case "lvl2cervezaconespuma":
			manager.GetComponent<Level2Manag> ().tiempo += 15;
			if (manager.GetComponent<Level2Manag> ().tiempo > manager.GetComponent<Level2Manag> ().tiempototal)
				manager.GetComponent<Level2Manag> ().tiempototal = manager.GetComponent<Level2Manag> ().tiempo;
			//manager.GetComponent<Level2Manag>().Wireframe(10);
			Destroy (coll);
			break;
		case "lvl2cervezasinespuma":
			manager.GetComponent<Level2Manag> ().tiempo -= 15;
			Destroy (coll);
			break;

		case "lvl2retamax":
			manager.GetComponent<Level2Manag>().Wireframe(10);
			Destroy (coll);
			break;

		case "lvl2confites":
			manager.GetComponent<Level2Manag> ().score += 250;
			Destroy (coll);
			break;
		case "lvl2globos":
			manager.GetComponent<Level2Manag> ().score += 150;
			Destroy (coll);
			break;
		case "lvl2cohetillos":
			manager.GetComponent<Level2Manag> ().score += 500;
			Destroy (coll);
			break;
		case "lvl2vino":
			manager.GetComponent<Level2Manag> ().score += 250;
			Destroy (coll);
			break;
		case "lvl2habas":
			manager.GetComponent<Level2Manag> ().score += 250;
			Destroy (coll);
			break;
		case "lvl2flores":
			manager.GetComponent<Level2Manag> ().score += 500;
			Destroy (coll);
			break;
		case "lvl2serpentina":
			manager.GetComponent<Level2Manag> ().score += 1000;
			manager.GetComponent<Level2Manag> ().sol.SetActive (false);
			manager.GetComponent<Level2Manag> ().luces.SetActive (true);
		//	luces (5);
			Destroy (coll);
			break;
		}		
	}
}
