Exemple #1
0
    private void InitializeModes()
    {
        // Get all travel scripts.
        travelBehaviorDirect       = ScriptableObject.CreateInstance <DroneTravelDirect>();
        travelBehaviorTurnThenMove = ScriptableObject.CreateInstance <DroneTravelTurnThenMove>();
        travelBehaviorIncremental  = ScriptableObject.CreateInstance <DroneTravelIncremental>();

        // Get all motion scripts.
        motionBehaviorSine   = ScriptableObject.CreateInstance <DroneMotionSinusoidal>();
        motionBehaviorSimple = ScriptableObject.CreateInstance <DroneMotionSimple>();
        motionBehaviorNone   = ScriptableObject.CreateInstance <DroneMotionNone>();

        // Get all targeting scripts.
        targetDirectBehavior      = ScriptableObject.CreateInstance <DroneTargetDirect>();
        targetWaypointBehavior    = ScriptableObject.CreateInstance <DroneTargetWaypoint>();
        targetConstrainedBehavior = ScriptableObject.CreateInstance <DroneTargetConstrained>();
        targetBehavior            = targetDirectBehavior; // Set initial targeting to direct.
    }
Exemple #2
0
    // This is called each time a destination is reached, for possible update.
    private void SetUserTravelAndMotion(bool force = false)
    {
        if (force || (userTravelMode != curTravelMode))
        {
            switch (userTravelMode)
            {
            case DroneTravelMode.TurnThenMove:
                travelBehavior = travelBehaviorTurnThenMove;
                curTravelMode  = DroneTravelMode.TurnThenMove;
                break;

            case DroneTravelMode.Incremental:
                travelBehavior = travelBehaviorIncremental;
                curTravelMode  = DroneTravelMode.Incremental;
                break;

            default:
                travelBehavior = travelBehaviorDirect;
                curTravelMode  = DroneTravelMode.Direct;
                break;
            }
        }

        if (force || (userMotionMode != curMotionMode))
        {
            switch (userMotionMode)
            {
            case DroneMotionMode.Sine:
                motionBehavior = motionBehaviorSine;
                curMotionMode  = DroneMotionMode.Sine;
                break;

            case DroneMotionMode.Simple:
                motionBehavior = motionBehaviorSimple;
                curMotionMode  = DroneMotionMode.Simple;
                break;

            default:
                motionBehavior = motionBehaviorNone;
                curMotionMode  = DroneMotionMode.None;
                break;
            }
        }
    }
    // This is called each time a destination is reached, for possible update.
    private void SetUserTravelAndMotion(bool force = false)
    {
        if (force || (userTravelMode != curTravelMode))
        {
            switch (userTravelMode)
            {
                case DroneTravelMode.TurnThenMove:
                    travelBehavior = travelBehaviorTurnThenMove;
                    curTravelMode = DroneTravelMode.TurnThenMove;
                    break;
                case DroneTravelMode.Incremental:
                    travelBehavior = travelBehaviorIncremental;
                    curTravelMode = DroneTravelMode.Incremental;
                    break;
                default:
                    travelBehavior = travelBehaviorDirect;
                    curTravelMode = DroneTravelMode.Direct;
                    break;
            }
        }

        if (force || (userMotionMode != curMotionMode))
        {
            switch (userMotionMode)
            {
                case DroneMotionMode.Sine:
                    motionBehavior = motionBehaviorSine;
                    curMotionMode = DroneMotionMode.Sine;
                    break;
                case DroneMotionMode.Simple:
                    motionBehavior = motionBehaviorSimple;
                    curMotionMode = DroneMotionMode.Simple;
                    break;
                default:
                    motionBehavior = motionBehaviorNone;
                    curMotionMode = DroneMotionMode.None;
                    break;
            }
        }

    }
    private void InitializeModes()
    {
        // Get all travel scripts.
        travelBehaviorDirect = ScriptableObject.CreateInstance<DroneTravelDirect>();
        travelBehaviorTurnThenMove = ScriptableObject.CreateInstance<DroneTravelTurnThenMove>();
        travelBehaviorIncremental = ScriptableObject.CreateInstance<DroneTravelIncremental>();

        // Get all motion scripts.
        motionBehaviorSine = ScriptableObject.CreateInstance<DroneMotionSinusoidal>();
        motionBehaviorSimple = ScriptableObject.CreateInstance<DroneMotionSimple>();
        motionBehaviorNone = ScriptableObject.CreateInstance<DroneMotionNone>();

        // Get all targeting scripts.
        targetDirectBehavior = ScriptableObject.CreateInstance<DroneTargetDirect>();
        targetWaypointBehavior = ScriptableObject.CreateInstance<DroneTargetWaypoint>();
        targetConstrainedBehavior = ScriptableObject.CreateInstance<DroneTargetConstrained>();
        targetBehavior = targetDirectBehavior;  // Set initial targeting to direct.

    }