using UnityEngine;
using System.Collections;

public class MagmaScript : MonoBehaviour {

	public GameObject obsidREF;

	public GameObject playerREF;
	MummyScript mummyREF;
	CircleCollider2D circleREF;

	// Use this for initialization
	void Start () {
		circleREF = playerREF.GetComponent<CircleCollider2D> ();
		mummyREF = playerREF.GetComponent<MummyScript> ();
	}
	
	// Update is called once per frame
	void Update () {
		if(Physics2D.IsTouching((Collider2D)GetComponent<BoxCollider2D>(), (Collider2D)circleREF))
		{
			if(mummyREF.wet)
			{
				GameObject obsid_TEMP =	Instantiate<GameObject>(obsidREF);
				obsid_TEMP.transform.position = transform.position;
				Destroy(gameObject);
				mummyREF.steamTimer = 0.25f;
			}
			else
			{
				if(playerREF.transform.position.y < transform.position.y + 0.25f)
				mummyREF.health = 0;
			}
		}
	}
}
