/**
  * <summary>Ends the ActionList or ActionListAsset associated with a given ActiveList data container</summary>
  * <param name = "activeList">The ActiveList associated with the ActionList or ActionListAsset to end.</param>
  */
 public void EndList(ActiveList activeList)
 {
     activeList.Reset(false);
     if (activeList.GetConversationOnEnd())
     {
         ResetSkipVars();
         activeList.RunConversation();
     }
 }
Beispiel #2
0
        protected void OnEndConversation(Conversation conversation)
        {
            if (conversation == this && onFinishActiveList != null)
            {
                if (onFinishActiveList.actionListAsset)
                {
                    onFinishActiveList.actionList = AdvGame.RunActionListAsset(onFinishActiveList.actionListAsset, onFinishActiveList.startIndex, true);
                }
                else if (onFinishActiveList.actionList)
                {
                    onFinishActiveList.actionList.Interact(onFinishActiveList.startIndex, true);
                }
            }

            onFinishActiveList = null;
        }
Beispiel #3
0
 /**
  * <summary>Recreates ActionList resume data from a saved data string.</summary>
  * <param name = "_dataString">The saved data string</param>
  */
 public void LoadData(string _dataString)
 {
     activeLists.Clear();
     if (_dataString != null && _dataString.Length > 0)
     {
         string[] dataArray = _dataString.Split(SaveSystem.pipe[0]);
         foreach (string chunk in dataArray)
         {
             ActiveList activeList = new ActiveList();
             if (activeList.LoadData(chunk))
             {
                 activeLists.Add(activeList);
             }
         }
     }
 }
        /**
         * <summary>Recreates ActionList resume data from a saved data string.</summary>
         * <param name = "_dataString">The saved data string</param>
         */
        public void LoadData(string _dataString)
        {
            activeLists.Clear();

            if (!string.IsNullOrEmpty(_dataString))
            {
                string[] dataArray = _dataString.Split(SaveSystem.pipe[0]);
                foreach (string chunk in dataArray)
                {
                    ActiveList activeList = new ActiveList();
                    if (activeList.LoadData(chunk))
                    {
                        activeLists.Add(activeList);
                    }
                }
            }
        }
        /**
         * <summary>Ends the ActionList or ActionListAsset associated with a given ActiveList data container</summary>
         * <param name = "activeList">The ActiveList associated with the ActionList or ActionListAsset to end.</param>
         */
        public void EndList(ActiveList activeList)
        {
            activeList.Reset(false);

            if (activeList.GetConversationOnEnd())
            {
                ResetSkipVars();
                activeList.RunConversation();
            }
            else
            {
                if (activeList.actionListAsset != null && activeList.actionList.actionListType == ActionListType.PauseGameplay && !activeList.actionList.unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn(null))
                {
                    // Don't affect the gamestate if we want to remain frozen
                    if (KickStarter.stateHandler.gameState != GameState.Cutscene)
                    {
                        ResetSkipVars();
                    }
                    PurgeLists();
                }
                else
                {
                    SetCorrectGameStateEnd();
                }
            }

            /*if (activeList != null && activeList.actionList != null && activeList.actionList.autosaveAfter)
             * {
             *      if (!IsGameplayBlocked ())
             *      {
             *              SaveSystem.SaveAutoSave ();
             *      }
             *      else
             *      {
             *              saveAfterCutscene = true;
             *      }
             * }*/
        }
        /**
         * <summary>Recreates ActionList resume data from a saved data string.</summary>
         * <param name = "If set, the data is for a subscene and so existing data will not be cleared.</param>
         * <param name = "_localResumeData">The saved data string</param>
         */
        public void LoadData(string _dataString, SubScene subScene = null)
        {
            saveAfterCutscene       = false;
            playCutsceneOnVarChange = false;

            if (subScene == null)
            {
                activeLists.Clear();
            }

            if (!string.IsNullOrEmpty(_dataString))
            {
                string[] dataArray = _dataString.Split(SaveSystem.pipe[0]);
                foreach (string chunk in dataArray)
                {
                    ActiveList activeList = new ActiveList();
                    if (activeList.LoadData(chunk, subScene))
                    {
                        activeLists.Add(activeList);
                    }
                }
            }
        }
Beispiel #7
0
        /**
         * <summary>Shows the Conversation's dialogue options.</summary>
         * <param name = "actionList">The ActionList that contains the Action that calls this function</param>
         * <param name = "actionConversation">The "Dialogue: Start conversation" Action that calls this function.  This is necessary when that Action overrides the Converstion's options.</param>
         */
        public void Interact(ActionList actionList, ActionConversation actionConversation)
        {
            overrideActiveList = null;

            if (actionList)
            {
                onFinishActiveList = null;

                int actionIndex = actionList.actions.IndexOf(actionConversation);
                if (actionList && actionIndex >= 0 && actionIndex < actionList.actions.Count)
                {
                    if (actionConversation.overrideOptions)
                    {
                        overrideActiveList = new ActiveList(actionList, true, actionIndex);
                        actionList.ResetList();
                    }
                    else if (actionConversation.willWait && !KickStarter.settingsManager.allowGameplayDuringConversations && actionConversation.endings.Count > 0)
                    {
                        ActionEnd ending = actionConversation.endings[0];
                        if (ending.resultAction != ResultAction.Stop)
                        {
                            switch (ending.resultAction)
                            {
                            case ResultAction.Continue:
                                if (actionIndex < actionList.actions.Count - 1)
                                {
                                    onFinishActiveList = new ActiveList(actionList, true, actionIndex + 1);
                                }
                                break;

                            case ResultAction.Skip:
                                onFinishActiveList = new ActiveList(actionList, true, ending.skipAction);
                                break;

                            case ResultAction.RunCutscene:
                                if (actionList is RuntimeActionList)
                                {
                                    if (ending.linkedAsset)
                                    {
                                        onFinishActiveList = new ActiveList(null, true, 0);
                                        onFinishActiveList.actionListAsset = ending.linkedAsset;
                                    }
                                }
                                else if (ending.linkedCutscene)
                                {
                                    onFinishActiveList = new ActiveList(ending.linkedCutscene, true, 0);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }

            KickStarter.eventManager.Call_OnStartConversation(this);

            CancelInvoke("RunDefault");
            int numPresent = 0;

            foreach (ButtonDialog _option in options)
            {
                if (_option.CanShow())
                {
                    numPresent++;
                }
            }

            if (numPresent == 1 && autoPlay)
            {
                foreach (ButtonDialog _option in options)
                {
                    if (_option.CanShow())
                    {
                        RunOption(_option);
                        return;
                    }
                }
            }
            else if (numPresent > 0)
            {
                KickStarter.playerInput.activeConversation = this;
            }
            else
            {
                KickStarter.playerInput.EndConversation();
                return;
            }

            if (isTimed)
            {
                startTime = Time.time;
                Invoke("RunDefault", timer);
            }
        }
Beispiel #8
0
 protected void OnFinishLoading()
 {
     onFinishActiveList = null;
     overrideActiveList = null;
 }
Beispiel #9
0
        protected void RunOption(ButtonDialog _option)
        {
            _option.hasBeenChosen = true;
            if (options.Contains(_option))
            {
                lastOption = options.IndexOf(_option);

                if (overrideActiveList != null)
                {
                    if (overrideActiveList.actionListAsset)
                    {
                        overrideActiveList.actionList = AdvGame.RunActionListAsset(overrideActiveList.actionListAsset, overrideActiveList.startIndex, true);
                    }
                    else if (overrideActiveList.actionList)
                    {
                        overrideActiveList.actionList.Interact(overrideActiveList.startIndex, true);
                    }

                    KickStarter.eventManager.Call_OnClickConversation(this, _option.ID);
                    overrideActiveList = null;
                    return;
                }
                lastOption = -1;
            }

            Conversation endConversation = null;

            if (interactionSource != AC.InteractionSource.CustomScript)
            {
                if (_option.conversationAction == ConversationAction.ReturnToConversation)
                {
                    endConversation = this;
                }
                else if (_option.conversationAction == ConversationAction.RunOtherConversation && _option.newConversation)
                {
                    endConversation = _option.newConversation;
                }
            }

            if (interactionSource == AC.InteractionSource.AssetFile && _option.assetFile)
            {
                AdvGame.RunActionListAsset(_option.assetFile, endConversation);
            }
            else if (interactionSource == AC.InteractionSource.CustomScript)
            {
                if (_option.customScriptObject && !string.IsNullOrEmpty(_option.customScriptFunction))
                {
                    _option.customScriptObject.SendMessage(_option.customScriptFunction);
                }
            }
            else if (interactionSource == AC.InteractionSource.InScene && _option.dialogueOption)
            {
                _option.dialogueOption.conversation = endConversation;
                _option.dialogueOption.Interact();
            }
            else
            {
                ACDebug.Log("No DialogueOption object found on Conversation '" + gameObject.name + "'", this);
                KickStarter.eventManager.Call_OnEndConversation(this);

                if (endConversation)
                {
                    endConversation.Interact();
                }
            }

            KickStarter.eventManager.Call_OnClickConversation(this, _option.ID);
        }