private IEnumerator UpdateState() { float LastCheck = 0.0f; while (true) { if (Time.realtimeSinceStartup - LastCheck >= 30.0f) { LastCheck = Time.realtimeSinceStartup; float chan = Random.Range(0.0f, 100.0f); if (AIState == CurrentAIState.GoingHome && Vector3.Distance(transform.position, Data.Home) < AttackRange) { AIState = CurrentAIState.Idling; } else if (AIState == CurrentAIState.Idling) { if (chan < 5f) { AIState = CurrentAIState.GoingHome; } else { AIState = CurrentAIState.Idling; } } } yield return null; } }
/// <summary> /// Called when the end of the path has been reached. /// </summary> private void EndOfPath() { AIState = CurrentAIState.Idling; path = null; pt = PathType.none; currentWaypoint = 0; }