コード例 #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();
        }
コード例 #2
0
        private void RunExampleTwo()
        {
            // 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;
            }

            // Create the Actions, but this time with references to them so that we can later modify their 'After running' options

            // Check if a global bool variable is True or False
            ActionVarCheck variableCheck = ActionVarCheck.CreateNew_Global(globalBoolVariableID);

            // Response if the variable is True
            ActionComment commentIfTrue = ActionComment.CreateNew("The bool variable is currently True!");

            // Response if the variable is False
            ActionComment commentIfFalse = ActionComment.CreateNew("The bool variable is currently False!");

            // Assign the Actions to the ActionList
            actionList.actions = new List <Action>
            {
                variableCheck,
                commentIfTrue,
                commentIfFalse,
            };

            // Modify the 'Variable: Check' Action's 'After running' fields so that commentIfTrue is run if the condition is met, and commentIfFalse is run otherwise
            variableCheck.SetOutputs(new ActionEnd(commentIfTrue), new ActionEnd(commentIfFalse));

            // Modify the two comment Actions so that their 'After running' fields are both set to Stop, so that the ActionList stops after either one is run
            commentIfTrue.SetOutput(new ActionEnd(true));
            commentIfFalse.SetOutput(new ActionEnd(true));

            // Run the ActionList
            actionList.Interact();
        }