public override IEnumerator Update() { if (!sc.target.alive) { sc.Restart(); yield break; } if (checkTime != null) { controller.StopCoroutine(checkTime); checkTime = null; } currentTime = 0; AttackStart(); yield return(new WaitUntil(() => attackAnimComplete)); // 공격이 끝나면 다시 시간을 계산한다. checkTime = sc.StartCoroutine(CheckTime()); sc.ChangeState(sc.chaseSate); yield break; }
public override IEnumerator Update() { // 적을 찾는다. List <Unit> enemies = FindEnemiesWithTag(); // 조건. 적이 없다면. if (enemies.Count <= 0) { yield return(new WaitForSeconds(sc.GetRandomDelay())); yield break; } // 가장 가까운 적을 찾는다. sc.target = GetClosest(enemies); // 사거리내에 없다면. // 사이에 장애물이 있는지 확인한다. if (CheckAround()) { PathRequestManager.RequestPath(new PathRequest(controller.Position, sc.target.transform.position, OnPathFound)); } else { if (follow != null) { controller.StopCoroutine(follow); follow = null; } follow = sc.StartCoroutine(this.FollowTarget()); } yield return(new WaitForSeconds(sc.GetRandomDelay())); sc.ChangeState(sc.chaseSate); }