using UnityEngine;
using System.Collections;

public class XavierHurtingFlame : MonoBehaviour {

    BoxCollider box;
    int damage;
    bool hurting = false;
    Player p;
    int wait = 0;

	// Use this for initialization
	void Start () {
        this.box = this.gameObject.GetComponent<BoxCollider>();
        this.damage = 50;

	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnTriggerEnter(Collider other)
    {    
        if (other.gameObject.tag == "Player") {
            p = other.gameObject.GetComponent<Player>();
            this.hurting = true;
        }
    
    }

    void OnTriggerStay(Collider other) {
        GameObject g = other.gameObject;

        if (g.tag == "Player") {
            if (hurting) {
                if (wait == 0) {
                    p.receiveDamage(this.damage, Vector3.one);
                    wait += 100;
                }

                wait--;
            }
        
        }
    }

    void OnTriggerExit(Collider other)
    {
        this.hurting = false;
        wait = 0;
    }


}
