protected void movementChange() { int index = Random.Range(-1, 2); //매번 랜덤한 행동 상태 부여 if (index == 0) { monsterAction = monsterActionType.Idle; } else { //이동방향에 맞게 플립 if (index == 1) { if (transform.rotation.eulerAngles.y > 100) { transform.Rotate(0, 180, 0); } } else { if (transform.rotation.eulerAngles.y < 100) { transform.Rotate(0, 180, 0); } } monsterAction = monsterActionType.Move; } }
protected void Dead() { if (mosnterHp <= 0 && !isDead) { StopAllCoroutines(); CancelInvoke(); isDead = true; monsterAction = monsterActionType.Die; anim.SetTrigger("isDead"); Destroy(gameObject, 2f); } }
public void CancelAttack() { monsterAction = monsterActionType.Idle; //플레이어가 일정 범위 밖으로 나갔다면 다시 기본상태로 회귀 InvokeRepeating("movementChange", 2f, 2.3f); }
public void Attack() //공격 상태일때는 기존 실행중이던 코루틴을 종료하고 현재상태를 공격으로 바꿈 { CancelInvoke(); monsterAction = monsterActionType.Attack; }