using UnityEngine;
using System.Collections;

public class ThrowIntoResouce : MonoBehaviour {
	public GameObject throwableRuby;
	public GameObject throwableDiamond;
	public GameObject throwableSaphire;
	public GameObject throwableEmerald;
	public GameObject throwableTopaz;

	public InventoryManager inv;



	void Start () {
	
	}

	void Update () {
		Rigidbody r = gameObject.GetComponent<Rigidbody> ();

		if (Mathf.Abs(r.velocity.x) + Mathf.Abs(r.velocity.y)+ Mathf.Abs(r.velocity.z) < 0.01f) {
			Vector3 p = transform.position;
			GameObject g = null;
		
			switch (gameObject.name) {
			case "Ruby":
				g = Instantiate (throwableRuby,p, new Quaternion ()) as GameObject;
				break;
			case "Emerald":
				g = Instantiate (throwableEmerald,p, new Quaternion ()) as GameObject;
				break;
			case "Topaz":
				g = Instantiate (throwableTopaz,p, new Quaternion ()) as GameObject;
				break;
			case "Saphire":
				g = Instantiate (throwableSaphire,p, new Quaternion ()) as GameObject;
				break;
			case "Diamond":
				g = Instantiate (throwableDiamond,p, new Quaternion ()) as GameObject;
				break;
			}
			var pul = g.GetComponent<PowerUpLower> ();
			pul.enabled = false;
			g.name = gameObject.name;
			Destroy (gameObject);
		}
	}
}
