void Die() { isDie = true; StopAllCoroutines(); MonsterStatus = MonStatus.die; navMeshAgent.Stop(); animator.SetTrigger("IsDie"); gameObject.GetComponentInChildren<CapsuleCollider>().enabled = false; foreach (Collider coll in gameObject.GetComponentsInChildren<SphereCollider>()) { coll.enabled = false; } _gameUI.DispScore(50); StartCoroutine(this.PushObjectPool()); }
private IEnumerator CheckDistance() { while (!isDie) { yield return new WaitForSeconds(0.2f); float dist = Vector3.Distance(playerTr.position, monsterTr.position); if (dist <= attackDist) { MonsterStatus = MonStatus.attack; } else if (dist <= traceDist) { MonsterStatus = MonStatus.trace; } else { MonsterStatus = MonStatus.idle; } } }
/// <summary> /// Load status name from configuration /// </summary> public static void LoadStatusNames() { _StatusNames = new Dictionary <Status, Dictionary <string, string> >(); foreach (Status MonStatus in (Status[])Enum.GetValues(typeof(Status))) { switch (MonStatus) { case Status.ToBeValidated: _StatusNames.Add(MonStatus, new Dictionary <string, string>() { { "EN", "Pending" } }); break; case Status.Deleted: _StatusNames.Add(MonStatus, new Dictionary <string, string>() { { "EN", "Scrapped" } }); break; case Status.Outside: _StatusNames.Add(MonStatus, new Dictionary <string, string>() { { "EN", "Stored externally" } }); break; default: _StatusNames.Add(MonStatus, new Dictionary <string, string>() { { "EN", MonStatus.ToString() } }); break; } } }
private IEnumerator PushObjectPool() { yield return new WaitForSeconds(3.0f); isDie = false; hp = 30; MonsterStatus = MonStatus.idle; gameObject.GetComponentInChildren<CapsuleCollider>().enabled = true; foreach (Collider coll in gameObject.GetComponentsInChildren<SphereCollider>()) { coll.enabled = true; } gameObject.SetActive(false); }