Beispiel #1
0
        public void RunExampleOne()
        {
            // Get the ActionList component
            ActionList actionList = CreateActionList();

            // Make sure we're in gameplay and that no Actions are already running
            if (actionList.AreActionsRunning() || !Application.isPlaying)
            {
                Debug.LogWarning("Cannot run Actions at this time", this);
                return;
            }

            // Declare the Actions within it
            actionList.actions = new List <Action>
            {
                // Show a Console message
                ActionComment.CreateNew("Running Example 1 - move the player, say something, and add an inventory item"),

                // Move the Player to the Marker (note: uses pathfinding, so a NavMesh will need to be set up)
                ActionCharPathFind.CreateNew(KickStarter.player, markerToMoveTo),

                // Have the Player say something (Note: The 'translation ID' parameter is optional)
                ActionSpeech.CreateNew(KickStarter.player, playerSpeechText, playerSpeechTranslationID),

                // Add an item to the Player's inventory
                ActionInventorySet.CreateNew_Add(inventoryItemIDToAdd),

                // Show another Console message
                ActionComment.CreateNew("Example complete!"),
            };

            // Run it
            actionList.Interact();
        }
        /**
         * <summary>Creates a new instance of the 'Character: Move to point' Action with key variables already set.</summary>
         * <param name = "charToMove">The character to move</param>
         * <param name = "marker">The Marker to move the character to</param>
         * <param name = "waitUntilFinish">If True, the Action will wait until the character has reached the Marker</param>
         * <param name = "pathSpeed">How fast the character moves (Walk, Run)</param>
         * <param name = "pathfind">If True, the character will rely on pathfinding to reach the Marker</param>
         * <returns>The generated Action</returns>
         */
        public static ActionCharPathFind New(Char charToMove, Marker marker, bool waitUntilFinish = true, PathSpeed pathSpeed = PathSpeed.Walk, bool pathFind = true)
        {
            ActionCharPathFind newAction = (ActionCharPathFind)CreateInstance <ActionCharPathFind>();

            newAction.charToMove = charToMove;
            newAction.marker     = marker;
            newAction.speed      = pathSpeed;
            newAction.pathFind   = pathFind;
            newAction.willWait   = waitUntilFinish;
            return(newAction);
        }
        /**
         * <summary>Creates a new instance of the 'Character: Move to point' Action with key variables already set.</summary>
         * <param name = "charToMove">The character to move</param>
         * <param name = "marker">The Marker to move the character to</param>
         * <param name = "pathSpeed">How fast the character moves (Walk, Run)</param>
         * <param name = "usePathfinding">If True, the character will rely on pathfinding to reach the Marker</param>
         * <param name = "waitUntilFinish">If True, the Action will wait until the character has reached the Marker</param>
         * <param name = "turnToFaceAfter">If True, and waitUntilFinish = true, then the character will face the same direction that the Marker is facing after reaching it</param>
         * <returns>The generated Action</returns>
         */
        public static ActionCharPathFind CreateNew(Char charToMove, Marker marker, PathSpeed pathSpeed = PathSpeed.Walk, bool usePathfinding = true, bool waitUntilFinish = true, bool turnToFaceAfter = false)
        {
            ActionCharPathFind newAction = (ActionCharPathFind)CreateInstance <ActionCharPathFind>();

            newAction.charToMove = charToMove;
            newAction.marker     = marker;
            newAction.speed      = pathSpeed;
            newAction.pathFind   = usePathfinding;
            newAction.willWait   = waitUntilFinish;
            newAction.faceAfter  = turnToFaceAfter;
            return(newAction);
        }