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() { if (!sc.target.alive) { sc.Restart(); yield break; } sc.modelAnim.Play("idle"); // 공격 가능한 시간이 되면. if (currentTime >= controller.unit.status.attack_speed) { if (checkTime != null) { controller.StopCoroutine(checkTime); checkTime = null; } // 공격을 한다. AttackStart(); // 공격이 끝날때 까지 기다린다. yield return(new WaitUntil(() => attackAnimComplete)); // 공격이 끝나면 다시 시간을 계산한다. checkTime = sc.StartCoroutine(CheckTime()); } // 스테이지를 변경하고 끝낸다. controller.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); }