コード例 #1
0
 private void EnterAtHeightState()
 {
     LeaveState();
     curState = FSMDroneState.AtHeight;
     if (debugFSM)
     {
         Debug.Log(string.Format("{0}: Entering ", curState));
     }
 }
コード例 #2
0
 private void EnterFreeMovementState()
 {
     LeaveState();
     curState = FSMDroneState.FreeMovement;
     if (debugFSM)
     {
         Debug.Log(string.Format("{0}: Entering ", curState));
     }
 }
コード例 #3
0
    // Every state XXX need functions EnterXXXState(), UpdateXXXState, and a case in LeaveState().
    // By convention, EnterXXXState() should start with a call to LeaveState().

    private void EnterStartState()
    {
        //LeaveState() is not called for the initial state.
        curState = FSMDroneState.Start;
        if (debugFSM)
        {
            Debug.Log(string.Format("{0}: Entering ", curState));
        }
    }
コード例 #4
0
 private void EnterAdjustLateralState()
 {
     LeaveState();
     curState = FSMDroneState.AdjustLateral;
     if (debugFSM)
     {
         Debug.Log(string.Format("{0}: Entering ", curState));
     }
     travelBehavior.BeginLateralJourney(thisScript);
 }
コード例 #5
0
 private void EnterLandingState()
 {
     LeaveState();
     curState = FSMDroneState.Landing;
     if (debugFSM)
     {
         Debug.Log(string.Format("{0}: Entering ", curState));
     }
     ResetJourney();
 }
コード例 #6
0
 private void EnterAtDestinationState()
 {
     LeaveState();
     curState = FSMDroneState.AtDestination;
     if (debugFSM)
     {
         Debug.Log(string.Format("{0}: Entering", curState));
     }
     // If the user has changed the travel or motion mode, make the switch here.
     SetUserTravelAndMotion();
     if (curMode == DroneMode.Maintain)
     {
         // In Maintain mode, do not do anything.
         return;
     }
     if (curMode == DroneMode.Hover)
     {
         effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
         EnterAdjustHeightState();
     }
     if (curMode == DroneMode.Patrol || curMode == DroneMode.Follow)
     {
         if (!nextWaypoint)
         {
             Debug.LogError("Error:  nextWaypoint must be set in the Inspector.");
             SetMaintainMode();
             return;
         }
     }
     if (curMode == DroneMode.Patrol)
     {
         // If patrolling and waypoint reached, identify the next waypoint.
         targetBehavior.AdvanceWaypoints(nextWaypoint, target, thisScript);
         EnterAdjustLateralState();
     }
     if (curMode == DroneMode.Follow)
     {
         // If following, constrained to waypoints, and waypoint has been reached,
         // identify the next waypoint.
         if (CloseToNextWaypoint())
         {
             targetBehavior.AdvanceWaypoints(nextWaypoint, target, thisScript);
             effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
         }
         if (CloseToPrevWaypoint())
         {
             targetBehavior.AdvanceWaypoints(prevWaypoint, target, thisScript);
             effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
         }
         if (!AtTargetLateralPos())
         {
             EnterAdjustLateralState();
         }
     }
 }
コード例 #7
0
    private void EnterAtDestinationState()
    {
        LeaveState();
        curState = FSMDroneState.AtDestination;
        if (debugFSM) Debug.Log(string.Format("{0}: Entering", curState));
        // If the user has changed the travel or motion mode, make the switch here.
        SetUserTravelAndMotion();
        if (curMode == DroneMode.Maintain)
        {
            // In Maintain mode, do not do anything.
            return;
        }
        if (curMode == DroneMode.Hover)
        {
            effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);
            EnterAdjustHeightState();
        }
        if (curMode == DroneMode.Patrol || curMode == DroneMode.Follow)
        {
            if (!nextWaypoint)
            {
                Debug.LogError("Error:  nextWaypoint must be set in the Inspector.");
                SetMaintainMode();
                return;
            }
        }
        if (curMode == DroneMode.Patrol)
        {
            // If patrolling and waypoint reached, identify the next waypoint.
            targetBehavior.AdvanceWaypoints(nextWaypoint, target, thisScript);
            EnterAdjustLateralState();
        }
        if (curMode == DroneMode.Follow)
        {
            // If following, constrained to waypoints, and waypoint has been reached, 
            // identify the next waypoint.
            if (CloseToNextWaypoint())
            {
                targetBehavior.AdvanceWaypoints(nextWaypoint, target, thisScript);
                effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);

            }
            if (CloseToPrevWaypoint())
            {
                targetBehavior.AdvanceWaypoints(prevWaypoint, target, thisScript);
                effectiveTarget = targetBehavior.GetEffectiveTarget(transform, target, thisScript);

            }
            if (!AtTargetLateralPos())
                EnterAdjustLateralState();
        }
    }
コード例 #8
0
 private void EnterAdjustLateralState()
 {
     LeaveState();
     curState = FSMDroneState.AdjustLateral;
     if (debugFSM) Debug.Log(string.Format("{0}: Entering ", curState));
     travelBehavior.BeginLateralJourney(thisScript);
 }
コード例 #9
0
 private void EnterAtHeightState()
 {
     LeaveState();
     curState = FSMDroneState.AtHeight;
     if (debugFSM) Debug.Log(string.Format("{0}: Entering ", curState));
 }
コード例 #10
0
 private void EnterLandingState()
 {
     LeaveState();
     curState = FSMDroneState.Landing;
     if (debugFSM) Debug.Log(string.Format("{0}: Entering ", curState));
     ResetJourney();
 }
コード例 #11
0
 private void EnterFreeMovementState()
 {
     LeaveState();
     curState = FSMDroneState.FreeMovement;
     if (debugFSM) Debug.Log(string.Format("{0}: Entering ", curState));
 }
コード例 #12
0
    // Every state XXX need functions EnterXXXState(), UpdateXXXState, and a case in LeaveState().
    // By convention, EnterXXXState() should start with a call to LeaveState().

    private void EnterStartState()
    {
        //LeaveState() is not called for the initial state.
        curState = FSMDroneState.Start;
        if (debugFSM) Debug.Log(string.Format("{0}: Entering ", curState));
    }