using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MobLandmine : MonoBehaviour {

	[SerializeField]
	int damage = 10;

	[SerializeField]
	float delay = .5f;

	bool triggered = false;


	void OnTriggerEnter(Collider other)
	{
		if (!triggered) {
			triggered = true;
			StartCoroutine (LandmineCountdown ());
		}
	}

	IEnumerator LandmineCountdown()
	{
		List<GameObject> targets = gameObject.GetComponent<MobVolumeTargets> ().TargetList;

		yield return new WaitForSeconds (delay);
		foreach (GameObject target in targets) {
			target.GetComponent<PlayerHealth> ().ModifyHealth(-damage);
		}
	}
}
