コード例 #1
0
    protected virtual IEnumerator GoToNextWaypoint()
    {
        if (LostInterestToDistractor > 0)
        {
            StopCoroutine(GoToNextWaypoint());
        }
        Status = GuardStatus.Idle;
        Debug.Log("from parent");
        float randomIdleTime = Random.Range(MinMaxWaitBeforeMovingToNextWaypoint.x, MinMaxWaitBeforeMovingToNextWaypoint.y);

        yield return(new WaitForSecondsRealtime(randomIdleTime));

        CurrentWaypointIndex = (CurrentWaypointIndex + 1) % Waypoints.transform.childCount;
        Status = GuardStatus.Patrolling;
        NavMeshAgent.SetDestination(Waypoints.GetChild(CurrentWaypointIndex).transform.position);
    }
コード例 #2
0
        IEnumerator GoToNextWaypoint()
        {
            IsPecking = (Random.Range(0f, 1f) > .3f) ? true : false;
            Animator.SetBool("pecking", IsPecking);
            Animator.SetFloat("speed", 0);

            ChickenState = ChickenState.Idle;
            float randomIdleTime = Random.Range(MinMaxWaitBeforeMovingToNextWaypoint.x, MinMaxWaitBeforeMovingToNextWaypoint.y);

            yield return(new WaitForSecondsRealtime(randomIdleTime));

            CurrentWaypointIndex = (CurrentWaypointIndex + 1) % Waypoints.transform.childCount;
            InstantTurn(Waypoints.GetChild(CurrentWaypointIndex));
            NavMeshAgent.SetDestination(Waypoints.GetChild(CurrentWaypointIndex).transform.position);
            IsPecking    = false;
            ChickenState = ChickenState.Moving;
            Animator.SetBool("pecking", false);
            Animator.SetFloat("speed", 1);
        }
コード例 #3
0
        private new IEnumerator GoToNextWaypoint()
        {
            if (LostInterestToDistractor > 0)
            {
                StopCoroutine(GoToNextWaypoint());
            }
            Status = GuardStatus.Idle;
            Animator.SetFloat("speed", 0);
            float randomIdleTime = Random.Range(MinMaxWaitBeforeMovingToNextWaypoint.x, MinMaxWaitBeforeMovingToNextWaypoint.y);

            yield return(new WaitForSecondsRealtime(randomIdleTime));


            if (LostInterestToDistractor == 0)
            {
                CurrentWaypointIndex = (CurrentWaypointIndex + 1) % Waypoints.transform.childCount;
                NavMeshAgent.SetDestination(Waypoints.GetChild(CurrentWaypointIndex).transform.position);
                Status = GuardStatus.Patrolling;
            }
        }