void RunAway() { // 이전 상태 초기화 navOn = false; timerOn = false; //Debug.Log("Stag Start RunAway"); nav.ResetPath(); bearState = BEARSTATE.runaway; bearAnimator.SetBool("isRun", true); nav.speed = runSpeed; destination = transform.position - chaseTarget.transform.position; nav.SetDestination(transform.position + destination.normalized * 5); if (runAwayTimer >= runAwayTIme) { nav.ResetPath(); runAwayTimer = 0; bearAnimator.SetBool("isRun", false); bearState = BEARSTATE.ordinary; //Debug.Log("End RunAway"); } else { runAwayTimer += Time.deltaTime; } }
void ChaseOffTimer() // 추격을 하지 않고 반대로 간다. { if (chaseTimer2 >= chaseTime * 1.5f) { navOn = false; timerOn = false; chaseTimer = 0; bearState = BEARSTATE.ordinary; chaseOn = false; bearAnimator.SetBool("isRun", false); GetComponent <BoxCollider>().enabled = true; chaseTimer2 = 0; AudioSource chaseSound = GM.GetComponent <AudioSource>(); chaseSound.Stop(); } else { Debug.Log("chase off2"); destination = transform.position - chaseTarget.transform.position; nav.SetDestination(transform.position + destination.normalized * 5); //nav.SetDestination(startChasingPoint); nav.speed = runSpeed; chaseTimer2 += Time.deltaTime; } }
IEnumerator WaitAttack() { yield return(new WaitForSeconds(1.5f)); nav.enabled = true; bearState = BEARSTATE.chase; bearAnimator.SetBool("isAttack", false); bearAnimator.SetBool("isRun", true); }
void Attack(Collider other) { Debug.Log("bear attack"); bearState = BEARSTATE.attack; bearAnimator.SetBool("isAttack", true); nav.enabled = false; HP.isHit = true; StartCoroutine(WaitAttack()); }
// Use this for initialization void Start() { startChasingPoint = transform.position; nav = gameObject.GetComponent <NavMeshAgent>(); bearAnimator = GetComponent <Animator>(); bearState = BEARSTATE.ordinary; roarSound = GetComponent <AudioSource>(); chaseOn = false; chaseTimer = chaseTimer2 = 0; roarTimer = 0; idleRandomNumber = 0; attackTimer = attackTime; }
private void OnTriggerEnter(Collider other) // 플레이어 감지 { if (other.tag == "flarebulletLightBox") { RunAway(); } else { if (other.tag == "player") { Debug.Log("chase on"); if (bearState == BEARSTATE.ordinary) { //AudioSource.PlayClipAtPoint(GameManagerParameter.Instance().BackGroundSound[0], chaseTarget.transform.position, 1); AudioSource chaseSound = GM.GetComponent <AudioSource>(); chaseSound.Play(); roarSound.Play(); } GetComponent <BoxCollider>().enabled = false; bearState = BEARSTATE.chase; } } }