Пример #1
0
    public void RainedOn()
    {
        // Ignore when dead or game over
        if (LevelController.Instance.IsGameOver || IsDead)
        {
            return;
        }

        // Already rained on
        if (state == State.Idling || state == State.Resting || state == State.Recovering)
        {
            return;
        }

        // Stop immedeatly
        navMeshAgent.isStopped = true;
        navMeshAgent.velocity  = Vector3.zero;

        // Restore since it was reset
        curResource?.SetAccessPoint(curResourceAccessPoint);

        var go = Cloud.Instance.GetGrassUnderMouse();

        go?.GetComponent <IDousable>()?.RainedOn();

        if (state != State.Burning)
        {
            SwitchCoroutine(IdlingRoutine());
        }
        else
        {
            SwitchCoroutine(RecoveryRoutine(go.transform.position));
        }
    }
Пример #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();
    }