void Think() { if (_nav._destination == null) // TODO: FIX THIS SCRIPT ORDERING PROBLEM { FindWaypoint(); } if (Time.time > _lastStateChange + _stateDelay) // if we're able to change states again { switch (_currentState) // we're gonna try and see if we can change our state { case AIState.Walking: _animator.SetBool("Walking", true); if (_nav._reachedEndOfPath) // if we get to our destination { _nav._destination = this.transform; if (_leaving && this.transform.position.y < -2.5f) { Destroy(this.gameObject); } if (_hasTape) // we came from getting our tapes { ChangeState(AIState.WaitingInLine); } else if (!_hasTape) // we haven't gotten a tape yet { ChangeState(AIState.BrowsingTapes); } } break; case AIState.BrowsingTapes: _animator.SetBool("Walking", false); if (_timer > _browsingTime) // if we get tired of browsing { _timer = 0f; if (_hasTape) // if we got our tape { _nav._destination = WaypointManager.singleton.GetRegisterWaypoint(); // TODO: INSTANTIATE HAPPY Destroy(_moodBubbleInstance); _mood.incrementMood(5); _mood.CreateMoodBubble(); } else // if we didn't get our tape { _nav._destination = WaypointManager.singleton.GetExitWaypoint(); // TODO: INSTANTIATE ANGRY Destroy(_moodBubbleInstance); _mood.decrementMood(5); _mood.CreateMoodBubble(); _leaving = true; } ChangeState(AIState.Walking); } break; case AIState.WaitingInLine: _animator.SetBool("Walking", false); if (_timer > _patienceTime) // customer lost patience { _timer = 0f; Destroy(_moodBubbleInstance); _mood.decrementMood(8); _mood.CreateMoodBubble(); _nav._destination = WaypointManager.singleton.GetExitWaypoint(); _leaving = true; DropTape(); _register.LeaveLine(this); ChangeState(AIState.Walking); } else if (_paid) // customer got serviced { _timer = 0f; // TODO: INSTANTIATE HAPPY Destroy(_moodBubbleInstance); _mood.incrementMood(5); _mood.CreateMoodBubble(); _nav._destination = WaypointManager.singleton.GetExitWaypoint(); _leaving = true; _register.LeaveLine(this); ChangeState(AIState.Walking); } break; default: throw new ArgumentOutOfRangeException(); } } switch (_currentState) { case AIState.Walking: break; case AIState.BrowsingTapes: browseAI(); break; case AIState.WaitingInLine: lineAI(); break; } }