private IEnumerator SetDestinationRoutine(Object target)
    {
        //get references
        UnityEngine.AI.NavMeshAgent agent = GetComponent <UnityEngine.AI.NavMeshAgent>();
        navMove    myMove = GetComponent <navMove>();
        GameObject tar    = (GameObject)target as GameObject;

        //increase agent speed
        myMove.ChangeSpeed(4);
        //set new destination of the navmesh agent
        agent.SetDestination(tar.transform.position);

        //wait until the path has been calculated
        while (agent.pathPending)
        {
            yield return(null);
        }
        //wait until agent reached its destination
        float remain = agent.remainingDistance;

        while (remain == Mathf.Infinity || remain - agent.stoppingDistance > float.Epsilon ||
               agent.pathStatus != UnityEngine.AI.NavMeshPathStatus.PathComplete)
        {
            remain = agent.remainingDistance;
            yield return(null);
        }

        //wait a few seconds at the destination,
        //then decrease agent speed and restart movement routine
        yield return(new WaitForSeconds(4));

        myMove.ChangeSpeed(1.5f);
        myMove.moveToPath = true;
        myMove.StartMove();
    }
コード例 #2
0
 private void Start()
 {
     ThisNavAgent = GetComponent <NavMeshAgent>();
     PathComp     = GetComponent <navMove>();
     ThisAudio    = GetComponent <AudioSource>();
     OrigSpeed    = ThisNavAgent.speed;
 }
コード例 #3
0
    // Token: 0x060006F0 RID: 1776 RVA: 0x0002D688 File Offset: 0x0002BA88
    private IEnumerator SetDestinationRoutine(UnityEngine.Object target)
    {
        NavMeshAgent agent  = base.GetComponent <NavMeshAgent>();
        navMove      myMove = base.GetComponent <navMove>();
        GameObject   tar    = (GameObject)target;

        myMove.ChangeSpeed(4f);
        agent.SetDestination(tar.transform.position);
        while (agent.pathPending)
        {
            yield return(null);
        }
        float remain = agent.remainingDistance;

        while (remain == float.PositiveInfinity || remain - agent.stoppingDistance > 1.401298E-45f || agent.pathStatus != NavMeshPathStatus.PathComplete)
        {
            remain = agent.remainingDistance;
            yield return(null);
        }
        yield return(new WaitForSeconds(4f));

        myMove.ChangeSpeed(1.5f);
        myMove.moveToPath = true;
        myMove.StartMove();
        yield break;
    }
コード例 #4
0
        void Execute()
        {
            var go = Fsm.GetOwnerDefaultTarget(walkerObject);

            if (go == null)
            {
                return;
            }

            List <UnityEvent> events = null;

            splineMove spline = go.GetComponentInChildren <splineMove>();

            if (spline)
            {
                events = spline.events;
            }
            else
            {
                navMove nav = go.GetComponentInChildren <navMove>();
                if (nav)
                {
                    events = nav.events;
                }
            }

            UnityEvent myEvent = events[wpIndex.Value];

            myEvent.AddListener(delegate { fsmReceiver.SendEvent(fsmEvent.Value); });
        }
コード例 #5
0
ファイル: LittleHeroManager.cs プロジェクト: dtbinh/TAFF
    private void configureStartMenuHeroMovement()
    {
        Transform    BaseNormal = gameObject.transform.Find("LittleHeroBase");
        NavMeshAgent nma        = BaseNormal.GetComponent <NavMeshAgent>();

        nma.enabled = true;
        navMove nm = BaseNormal.GetComponent <navMove>();

        nm.enabled = true;
        HeroMotionController hmc = BaseNormal.GetComponent <HeroMotionController>();

        hmc.enabled = true;
    }
コード例 #6
0
        void Execute()
        {
            var go = Fsm.GetOwnerDefaultTarget(walkerObject);

            if (go == null)
            {
                return;
            }

            List <UnityEvent> events = null;

            splineMove spline = go.GetComponentInChildren <splineMove>();

            if (spline)
            {
                events = spline.events;
            }
            else
            {
                navMove nav = go.GetComponentInChildren <navMove>();
                if (nav)
                {
                    events = nav.events;
                }
            }

            if (events == null || events.Count == 0)
            {
                Debug.Log("RemoveEventsAtWaypoint action could not find events on " + go.name);
                return;
            }

            int size = events.Count;

            if (wpIndex.Value >= size - 1)
            {
                wpIndex.Value = size - 1;
            }
            else if (wpIndex.Value <= 0)
            {
                wpIndex.Value = 0;
            }

            if (size >= wpIndex.Value)
            {
                UnityEvent myEvent = events[wpIndex.Value];
                myEvent.RemoveAllListeners();
            }
        }