private int GetPalmHeight() { int count = 1; Transform child = transform.GetChild(0); PalmCutter palmPart = null; while (child.childCount > 0) { child = child.GetChild(0); palmPart = child.GetComponent <PalmCutter>(); if (palmPart != null && palmPart.IsAlive) { count++; } else if (palmPart == null && child.GetComponent <Collider>() == null) { count = -1; } else { break; } } return(count); }
private IEnumerator OnDeath() { ///destroy collider GameManager.GetPlayerComponent <Inventory>().AddItem(wood); PalmCutter child = null; if (transform.childCount > 1) { Destroy(transform.parent.GetChild(1).gameObject); child = transform.GetChild(0).GetComponent <PalmCutter>(); if (child != null) { child.Kill(despawnTime + 0.2f); } } yield return(new WaitForSeconds(despawnTime)); AnimateItem.AnimateContainer(new ItemContainer(wood, 1), GameManager.GetPlayerComponent <MonoBehaviour>(), transform.position); if (child != null) { child.transform.parent = transform.parent; } Destroy(gameObject); //transform.parent = null; }