IEnumerator KillThisThing(timedObjectDestroyer script, float delay) { killing = true; script.KillMe(); yield return(new WaitForSeconds(delay)); killing = false; }
private void Update() { if (obj != gameObject.GetComponent <Hand>().currentAttachedObject) { obj = gameObject.GetComponent <Hand>().currentAttachedObject; if (obj != null) { timedDestroy = obj.GetComponent <timedObjectDestroyer>(); if (timedDestroy != null) { if (timedDestroy.isDying()) { timedDestroy.SaveMe(); } } } } }
void OnCollisionEnter(Collision col) { var allList = GameManager.gm.goodItems.Concat(GameManager.gm.badItems); if (allList.Contains(col.gameObject.tag)) { if (col.gameObject.CompareTag("jug")) { if (!destroying) { StartCoroutine(DestroyJug(col.gameObject, 0.1f)); } } else { if (!killing) { timedObjectDestroyer timedDestory = col.gameObject.GetComponent <timedObjectDestroyer>(); StartCoroutine(KillThisThing(timedDestory, 0.25f)); } } } }