void ChangeGauge() // 공격받으면 게이지 감소 { hp /= 3; imgHpbar.fillAmount = (float)hp / (float)initHp; badguyState = BadGuyState.die; Destroy(gameObject, 1.0f); // 5초 후에 악당 사라짐 }
public bool Hit() { if (_state != BadGuyState.Alive) { return(false); } Destroy(this.GetComponent <BoxCollider2D>()); _state = BadGuyState.Dead; GetComponentInChildren <Animator>().SetTrigger("onDeath"); GetComponent <AudioSource>().Play(); Destroy(this.gameObject, 5f); return(true); }
IEnumerator CheckBadGuyState() { while (!isDie) { yield return(new WaitForSeconds(0.2f)); float dist = Vector3.Distance(PlayerTr.position, BadGuyTr.position); if (dist <= attackDist) { badguyState = BadGuyState.attack; } else if (dist <= traceDist) { badguyState = BadGuyState.run; } else { badguyState = BadGuyState.idle; } } }