public void Think() { if (!getWaitTime) { if (behaviorType == mouseType.Normal) { waitTime = Random.Range(0.2f, 0.7f); } if (behaviorType == mouseType.Quick) { waitTime = Random.Range(0.05f, 0.25f); } if (behaviorType == mouseType.Thinker) { waitTime = Random.Range(0.6f, 1.2f); } getWaitTime = true; } waitTime -= Time.deltaTime; if (waitTime <= 0) { getWaitTime = false; currentState = mouseStates.Run; } }
public void Run() { agent.destination = waypoints[waypointCounter].transform.position; if (Vector3.Distance(this.transform.position, agent.destination) < 1.0f) { if (waypointCounter + 1 == waypoints.Length) { //Lose } else { waypointCounter++; currentState = mouseStates.Think; } } }
//Start void Start() { agent = GetComponent <NavMeshAgent>(); currentState = mouseStates.Run; agent.destination = waypoints[0].transform.position; internalSqueakTime = squeakTime; if (behaviorType == mouseType.Normal) { agent.speed = 3.0f; } if (behaviorType == mouseType.Quick) { agent.speed = 4.0f; } if (behaviorType == mouseType.Thinker) { agent.speed = 2.0f; } baseSpeed = agent.speed; }