using UnityEngine;
using System.Collections;

public class player_potions : MonoBehaviour {
	public GameObject transformation1;
	public GameObject transformation2;
	public GameObject transformation3;
	public GameObject transformation4;
	public GameObject puff;
	private GameObject trans;
	void OnTriggerEnter(Collider other){
		if (other.tag == "tr1" || other.tag == "tr2" || other.tag == "tr3" || other.tag == "tr4") {
			Vector3 scale = new Vector3 (1, 2, 1);
			Vector3 position = new Vector3 (0, 0, 0);
			if (other.tag == "tr1") {
					trans = transformation1;
					scale = transformation1.transform.localScale;
					position = new Vector3 (this.transform.position.x, this.transform.position.y + 1f, this.transform.position.z);
					Transform child = transform.GetChild(1);
				child.gameObject.GetComponent<BoxCollider>().collider.enabled = false;
			}
			if (other.tag == "tr2") {
					trans = transformation2;
					scale = transformation2.transform.localScale;
					position = new Vector3 (this.transform.position.x, this.transform.position.y + 1f, this.transform.position.z);
					Transform child = transform.GetChild(1);	
					child.gameObject.GetComponent<BoxCollider>().collider.enabled = false;
			}
			if (other.tag == "tr3") {
					trans = transformation3;
					scale = transformation3.transform.localScale;
					position = new Vector3 (this.transform.position.x, this.transform.position.y + 1f, this.transform.position.z);
					Transform child = transform.GetChild(1);
					child.gameObject.GetComponent<BoxCollider>().collider.enabled = true;
			}
			if (other.tag == "tr4") {
				trans = transformation4;
				scale = transformation4.transform.localScale;
				position = new Vector3 (this.transform.position.x, this.transform.position.y + 1f, this.transform.position.z);
				Transform child = transform.GetChild(1);
				child.gameObject.GetComponent<BoxCollider>().collider.enabled = false;
			}

			Mesh mesh = trans.GetComponent<MeshFilter> ().sharedMesh;
			Vector3 collider = trans.GetComponent<BoxCollider> ().size;
			Vector3 center = trans.GetComponent<BoxCollider> ().center;

			this.GetComponent<MeshFilter> ().mesh = mesh;
			this.GetComponent<BoxCollider> ().size = collider;
			this.GetComponent<BoxCollider> ().center = center;
			this.transform.localScale = scale;
			this.transform.position = position;
			Instantiate(puff, this.transform.position, this.transform.rotation);
			Destroy (other.gameObject);
	
		}

        if (other.tag == "tr5")
        {
            Destroy(other.gameObject);
            Instantiate(puff, this.transform.position, this.transform.rotation);
        }




	}	
}
