Ejemplo n.º 1
0
    /// <summary>
    /// Briefly shows what the sheep is thinking about
    /// </summary>
    /// <param name="thought"></param>
    /// <returns></returns>
    IEnumerator ShowThoughtBubbleRoutine(ThoughtBubble.Thought thought = default)
    {
        if (thought == ThoughtBubble.Thought.Nohting)
        {
            thought = curThought;
        }

        thoughtBubble.SetThought(thought);
        yield return(new WaitForSeconds(timeToPreviewThought));

        // Keep it while resources are low
        if (!ResourcesLow)
        {
            thoughtBubble.DisableThought();
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Walks towards the given destination
    /// </summary>
    /// <param name="destination"></param>
    /// <returns></returns>
    IEnumerator WalkRoutine()
    {
        curResourceAccessPoint = curResource.GetAccessPoint(ResourcesLow);

        state = State.Walking;
        navMeshAgent.SetDestination(curResourceAccessPoint.position);
        navMeshAgent.isStopped = false;

        ThoughtBubble.Thought thought = curThought;
        switch (curResourceType)
        {
        case Resource.Food:
            thought = ThoughtBubble.Thought.Food;
            break;

        case Resource.Water:
            thought = ThoughtBubble.Thought.Water;
            break;

        case Resource.Rest:
            thought = ThoughtBubble.Thought.Rest;
            break;
        }

        StartCoroutine(ShowThoughtBubbleRoutine(thought));

        while (Vector3.Distance(navMeshAgent.destination, transform.position) > .01f)
        {
            yield return(new WaitForEndOfFrame());
        }

        // Fully Stop
        navMeshAgent.velocity = Vector3.zero;
        yield return(new WaitForEndOfFrame());

        // TODO: Change to smooth look at
        transform.LookAt(curResource.gameObject.transform);
        yield return(new WaitForEndOfFrame());

        curResource.SetAccessPoint(curResourceAccessPoint);

        // Continue
        AutoChangeState();
    }