Exemplo n.º 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 'Inventory: Add or remove' Action, set to replace an item to the player's inventory with another</summary>
         * <param name = "itemIDToAdd">The ID number of the item to add</param>
         * <param name = "itemIDToRemove">The ID number of the item to remove</param>
         * <param name = "amountToAdd">The number of items to add, if multiple instances are supported</param>
         * <returns>The generated Action</returns>
         */
        public static ActionInventorySet CreateNew_Replace(int itemIDToAdd, int itemIDToRemove, int amountToAdd = 1)
        {
            ActionInventorySet newAction = (ActionInventorySet)CreateInstance <ActionInventorySet>();

            newAction.invAction    = InvAction.Replace;
            newAction.invID        = itemIDToAdd;
            newAction.invIDReplace = itemIDToRemove;
            newAction.amount       = amountToAdd;
            return(newAction);
        }
        /**
         * <summary>Creates a new instance of the 'Inventory: Add or remove' Action, set to remove an item from the player's inventory</summary>
         * <param name = "itemID">The ID number of the item to remove</param>
         * <param name = "removeAllInstances">If True, all instances of the item will be removed</param>
         * <param name = "amountToRemove">The number of instances of the item to remove, if removeAllInstances = False and multiple instances are supported</param>
         * <param name = "playerID">If non-negative, and player-switching is enabled, the ID number of the Player to remove the item from</param>
         * <returns>The generated Action</returns>
         */
        public static ActionInventorySet CreateNew_Remove(int itemID, bool removeAllInstances = true, int amountToRemove = 1, int playerID = -1)
        {
            ActionInventorySet newAction = (ActionInventorySet)CreateInstance <ActionInventorySet>();

            newAction.invAction = InvAction.Remove;
            newAction.invID     = itemID;
            newAction.setAmount = !removeAllInstances;
            newAction.amount    = amountToRemove;
            newAction.playerID  = playerID;
            return(newAction);
        }
        /**
         * <summary>Creates a new instance of the 'Inventory: Add or remove' Action, set to add an item to the player's inventory</summary>
         * <param name = "itemID">The ID number of the item to add</param>
         * <param name = "addToFront">If True, the item will be added to the front of the inventory list</param>
         * <param name = "amountToAdd">The number of items to add, if multiple instances are supported</param>
         * <param name = "playerID">If non-negative, and player-switching is enabled, the ID number of the Player to add the item to</param>
         * <returns>The generated Action</returns>
         */
        public static ActionInventorySet CreateNew_Add(int itemID, bool addToFront = false, int amountToAdd = 1, int playerID = -1)
        {
            ActionInventorySet newAction = (ActionInventorySet)CreateInstance <ActionInventorySet>();

            newAction.invAction  = InvAction.Add;
            newAction.invID      = itemID;
            newAction.addToFront = addToFront;
            newAction.amount     = amountToAdd;
            newAction.playerID   = playerID;
            return(newAction);
        }