示例#1
0
    public void NextPoint()
    {
        Debug.Log("NEXT POINT");



        switch (mode)
        {
        case PatrolMode.Looping:
            waypointIndex = (waypointIndex + 1) % routeList.routes[selectedRoute].Points.Length;
            //ai.SetDestination(routeList.routes[selectedRoute].GetGlobalPoint(waypointIndex));
            ai.SetDestination(routeList.GetPointInRoute(selectedRoute, waypointIndex));
            break;

        case PatrolMode.OneWay:

            if (waypointIndex < routeList.routes[selectedRoute].Points.Length - 1)
            {
                waypointIndex = Mathf.Clamp(waypointIndex + 1, 0, routeList.routes[selectedRoute].Points.Length);
                ai.SetDestination(routeList.GetPointInRoute(selectedRoute, waypointIndex));
            }
            else
            {
                if (!hasEnded)
                {
                    //FIND A WAY TO MOVE ON TO NEXT STATE
                    hasEnded    = true;
                    ai.stopMove = true;
                    done        = true;
                }
            }



            break;
        }
    }