IEnumerator Move() { Reset(true); yield return(new WaitForSeconds(delayBeforeStart)); StartCoroutine(EmitRoutine()); while (true) { //move to next point, return true if reach if (MoveToPoint(indicatorT, subPath[subWaypointID])) { subWaypointID += 1; //sub waypoint reach, get the next subwaypoint if (subWaypointID >= subPath.Count) //if reach subpath destination, get subpath for next waypoint { subWaypointID = 0; waypointID += 1; if (waypointID >= path.GetPathWPCount()) //if reach path destination, reset to starting pos { Reset(); } else //else get next subpath { subPath = path.GetWPSectionPath(waypointID); } } } yield return(null); } }
public override void FixedUpdate() { base.FixedUpdate(); float attackRange = GetAttackRange(); float realStopDistance = attackRange * /* attackRange < 2 ? .65f :*/ .90f; if (!stunned && !dead) { if (useNavMesh) { if (dirtySlow) { agent.speed = GetMoveSpeed(); } if (attacker) { agent.destination = attacker.GetTargetT().position; agent.stoppingDistance = realStopDistance; if (attacker.dead) { tgtList.Remove(attacker); attacker = null; isAlarming = false; } } else if (target != null && !target.dead) { agent.destination = target.GetTargetT().position; agent.stoppingDistance = realStopDistance; } else if (behaviour == Behaviour.Default) { agent.destination = path.wpList[path.wpList.Count - 1].position; agent.stoppingDistance = .02f; } } else if (behaviour == Behaviour.Default) { if (target != null) { MoveToTarget(target.GetTargetT().position, realStopDistance); } else if (MoveToPoint(subPath[subWaypointID])) { subWaypointID += 1; if (subWaypointID >= subPath.Count) { subWaypointID = 0; waypointID += 1; if (waypointID >= path.GetPathWPCount()) { ReachDestination(); } else { subPath = path.GetWPSectionPath(waypointID); } } } } } else if (useNavMesh) { agent.SetDestination(thisT.position); } }