示例#1
0
        /**
         * <summary>Downloads and runs the settings and Actions stored within an ActionListAsset.</summary>
         * <param name = "actionListAsset">The ActionListAsset to copy Actions from and run</param>
         * <param name = "endConversation">If set, the supplied Conversation will be run when the AcionList ends</param>
         * <param name = "i">The index number of the first Action to run</param>
         * <param name = "doSkip">If True, then the Actions will be skipped, instead of run normally</param>
         * <param name = "addToSkipQueue">If True, the ActionList will be skippable when the user presses 'EndCutscene'</param>
         * <param name = "dontRun">If True, the Actions will not be run once transferred from the ActionListAsset</param>
         */
        public void DownloadActions(ActionListAsset actionListAsset, Conversation endConversation, int i, bool doSkip, bool addToSkipQueue, bool dontRun = false)
        {
            assetSource   = actionListAsset;
            useParameters = actionListAsset.useParameters;

            parameters = new List <ActionParameter>();

            List <ActionParameter> assetParameters = actionListAsset.GetParameters();

            if (assetParameters != null)
            {
                foreach (ActionParameter assetParameter in assetParameters)
                {
                    parameters.Add(new ActionParameter(assetParameter, true));
                }
            }

            unfreezePauseMenus = actionListAsset.unfreezePauseMenus;

            actionListType = actionListAsset.actionListType;
            if (actionListAsset.actionListType == ActionListType.PauseGameplay)
            {
                isSkippable = actionListAsset.isSkippable;
            }
            else
            {
                isSkippable = false;
            }

            conversation = endConversation;
            actions.Clear();

            foreach (AC.Action action in actionListAsset.actions)
            {
                if (action != null)
                {
                    ActionEnd _lastResult = action.lastResult;

                    // Really we should re-instantiate all Actions, but this is 'safer'
                    Action newAction = (actionListAsset.canRunMultipleInstances)
                                                                                ? (Object.Instantiate(action) as Action)
                                                                                : action;

                    if (doSkip)
                    {
                        newAction.lastResult = _lastResult;
                    }

                    actions.Add(newAction);
                }
                else
                {
                    actions.Add(null);
                }
            }

            /*if (!useParameters)
             * {
             *      foreach (Action action in actions)
             *      {
             *              action.AssignValues (null);
             *      }
             * }*/

            actionListAsset.AfterDownloading();


            if (!dontRun)
            {
                if (doSkip)
                {
                    Skip(i);
                }
                else
                {
                    Interact(i, addToSkipQueue);
                }
            }

            if (actionListAsset.canSurviveSceneChanges && !actionListAsset.IsSkippable())
            {
                DontDestroyOnLoad(gameObject);
            }
        }