/**
         * <summary>Adds a new ActionList, assumed to already be running, to the internal record of currently-running ActionLists, and sets the correct GameState in StateHandler.</summary>
         * <param name = "_list">The ActionList to run</param>
         * <param name = "addToSkipQueue">If True, then the ActionList will be added to the list of ActionLists to skip</param>
         * <param name = "_startIndex">The index number of the Action to start skipping from, if addToSkipQueue = True</param>
         */
        public void AddToList(ActionList _list, bool addToSkipQueue, int _startIndex)
        {
            if (skipQueue.Count == 0 && _list.IsSkippable ())
            {
                addToSkipQueue = true;
            }

            if (!IsListRunning (_list))
            {
                activeLists.Add (_list);

                if (addToSkipQueue && !ListIsInSkipQueue (_list) && _list.IsSkippable ())
                {
                    skipQueue.Add (new SkipList (_list, _startIndex));
                }
            }

            if (_list.conversation)
            {
                conversationOnEnd = _list.conversation;
            }

            if (_list is RuntimeActionList && _list.actionListType == ActionListType.PauseGameplay && !_list.unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn (null))
            {
                // Don't affect the gamestate if we want to remain frozen
                return;
            }

            SetCorrectGameState ();
        }
 public virtual void Start()
 {
     PersistentDataManager.includeSimStatus = includeSimStatus;
     skipSyncToLua     = false;
     dummyConversation = gameObject.AddComponent <AC.Conversation>();
     SaveOriginalSettings();
     UpdateSettingsFromAC();
 }
 public virtual void Start()
 {
     PersistentDataManager.includeSimStatus = includeSimStatus;
     skipSyncToLua     = false;
     dummyConversation = gameObject.AddComponent <AC.Conversation>();
     //if (saveToGlobalVariableOnLevelChange) SetSaveOnLevelChange();
     SaveOriginalSettings();
     UpdateSettingsFromAC();
 }
		public static RuntimeActionList RunActionListAsset (ActionListAsset actionListAsset, Conversation endConversation, int i)
		{
			if (actionListAsset != null && actionListAsset.actions.Count > 0)
			{
				GameObject runtimeActionListObject = (GameObject) Instantiate (Resources.Load (Resource.runtimeActionList));
				RuntimeActionList runtimeActionList = runtimeActionListObject.GetComponent <RuntimeActionList>();
				runtimeActionList.DownloadActions (actionListAsset, endConversation, i);
				return runtimeActionList;
			}
			
			return null;
		}
        /**
         * <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>
         */
        public void DownloadActions(ActionListAsset actionListAsset, Conversation endConversation, int i, bool doSkip, bool addToSkipQueue)
        {
            this.name = actionListAsset.name;
            assetSource = actionListAsset;

            useParameters = actionListAsset.useParameters;
            parameters = actionListAsset.parameters;
            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)
            {
                ActionEnd _lastResult = action.lastResult;

                actions.Add (action);

                if (doSkip && action != null)
                {
                    actions[actions.Count-1].lastResult = _lastResult;
                }
            }

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

            if (doSkip)
            {
                Skip (i);
            }
            else
            {
                Interact (i, addToSkipQueue);
            }
        }
		public override void ShowGUI ()
		{
			linkedConversation = (Conversation) EditorGUILayout.ObjectField ("Conversation:", linkedConversation, typeof (Conversation), true);

			if (linkedConversation)
			{
				linkedConversation.Upgrade ();
			}

			constantID = FieldToID <Conversation> (linkedConversation, constantID);
			linkedConversation = IDToField <Conversation> (linkedConversation, constantID, true);

			if (linkedConversation)
			{
				optionNumber = ShowOptionGUI (linkedConversation.options, optionNumber);
			}

			switchType = (SwitchType) EditorGUILayout.EnumPopup ("Set to:", switchType);
			
			AfterRunningOption ();
		}
		public ButtonDialog (int[] idArray)
		{
			label = "";
			icon = null;
			isOn = true;
			isLocked = false;
			conversationAction = ConversationAction.ReturnToConversation;
			assetFile = null;
			newConversation = null;
			dialogueOption = null;
			lineID = -1;
			ID = 1;
			isEditing = false;

			// Update id based on array
			foreach (int _id in idArray)
			{
				if (ID == _id)
				{
					ID ++;
				}
			}
		}
		public void DownloadActions (ActionListAsset actionListAsset, Conversation endConversation, int i)
		{
			this.name = actionListAsset.name;
			assetSource = actionListAsset;

			useParameters = actionListAsset.useParameters;
			parameters = actionListAsset.parameters;
			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)
			{
				actions.Add (action);
			}

			if (!useParameters)
			{
				foreach (Action action in actions)
				{
					action.AssignValues (null);
				}
			}
			
			Interact (i);
		}
        private void OnGUI()
        {
            if (Selection.activeGameObject && Selection.activeGameObject.GetComponent <Conversation>() && (conversation == null || Selection.activeGameObject != conversation.gameObject))
            {
                if (conversation != null)
                {
                    lastConversation = conversation;
                }
                conversation = Selection.activeGameObject.GetComponent<Conversation>();
            }

            if (conversation)
            {
                conversation.Upgrade ();
            }

            if (lastConversation != null && lastConversation == conversation)
            {
                lastConversation = null;
            }

            if (conversation != null)
            {
                OptionsGUI ();
            }
            else if (lastConversation != null)
            {
                conversation = lastConversation;
            }
            else
            {
                GUILayout.Label ("Please select a Conversation in your scene");
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty (conversation);
            }
        }
Exemple #10
0
        /**
         * <summary>Runs or skips an ActionList asset file.</summary>
         * <param name = "actionListAsset">The ActionList asset to run</param>
         * <param name = "endConversation">The Conversation to enable when the ActionList is complete</param>
         * <param name = "i">The index of the Action to start from</param>
         * <param name = "doSkip">If True, all Actions within the ActionList will be run and completed instantly.</param>
         * <param name = "addToSkipQueue">True if the ActionList should be added to the skip queue</param>
         * <returns>The temporary RuntimeActionList object in the scene that performs the Actions within the asset</returns>
         */
        public static RuntimeActionList RunActionListAsset(ActionListAsset actionListAsset, Conversation endConversation, int i, bool doSkip, bool addToSkipQueue)
        {
            if (actionListAsset != null && actionListAsset.actions.Count > 0)
            {
                GameObject runtimeActionListObject = (GameObject) Instantiate (Resources.Load (Resource.runtimeActionList));
                RuntimeActionList runtimeActionList = runtimeActionListObject.GetComponent <RuntimeActionList>();
                runtimeActionList.DownloadActions (actionListAsset, endConversation, i, doSkip, addToSkipQueue);

                GameObject cutsceneFolder = GameObject.Find ("_Cutscenes");
                if (cutsceneFolder != null && cutsceneFolder.transform.position == Vector3.zero)
                {
                    runtimeActionList.transform.parent = cutsceneFolder.transform;
                }

                return runtimeActionList;
            }

            return null;
        }
Exemple #11
0
        /**
         * <summary>Updates its own variables from a MainData class.</summary>
         * <param name = "mainData">The MainData class to load from</param>
         */
        public void LoadMainData(MainData mainData)
        {
            // Active screen arrows
            RemoveActiveArrows ();
            ArrowPrompt loadedArrows = Serializer.returnComponent <ArrowPrompt> (mainData.activeArrows);
            if (loadedArrows)
            {
                loadedArrows.TurnOn ();
            }

            // Active conversation
            activeConversation = Serializer.returnComponent <Conversation> (mainData.activeConversation);
            timeScale = mainData.timeScale;
        }
Exemple #12
0
 private void ExtractConversation(Conversation conversation, bool onlySeekNew)
 {
     foreach (ButtonDialog dialogOption in conversation.options)
     {
         ExtractDialogOption (dialogOption, onlySeekNew);
     }
 }
Exemple #13
0
 public override void AssignValues(List <ActionParameter> parameters)
 {
     runtimeConversation = AssignFile <Conversation> (parameters, parameterID, constantID, conversation);
 }
Exemple #14
0
 override public void AssignValues()
 {
     linkedConversation = AssignFile <Conversation> (constantID, linkedConversation);
 }
        private void NodeWindow(int ID)
        {
            if (ID == -2)
            {
                GUILayout.Label(lastConversation.gameObject.name);
            }
            else if (ID == -1)
            {
                GUILayout.Label(conversation.gameObject.name);
            }
            else if (ID < conversation.options.Count)
            {
                GUILayout.BeginHorizontal();
                conversation.options[ID].label = GUILayout.TextField(conversation.options[ID].label);
                if (GUILayout.Button("-", GUILayout.Width(20f)))
                {
                    Undo.RecordObject(this, "Delete dialogue option");

                    foreach (ButtonDialog option in conversation.options)
                    {
                        option.isEditing = false;
                    }
                    conversation.selectedOption = null;
                    conversation.options.RemoveAt(ID);
                }
                GUILayout.EndHorizontal();
            }
            else if (ID < conversation.options.Count * 2)
            {
                int i = ID - conversation.options.Count;
                if (conversation.interactionSource == InteractionSource.AssetFile)
                {
                    conversation.options[i].assetFile = (ActionListAsset)EditorGUILayout.ObjectField(conversation.options[i].assetFile, typeof(ActionListAsset), false);
                }
                else if (conversation.interactionSource == InteractionSource.CustomScript)
                {
                    GUILayout.Label("(Set in Inspector)");
                }
                else if (conversation.interactionSource == InteractionSource.InScene)
                {
                    if (conversation.options[i].dialogueOption != null)
                    {
                        GUILayout.BeginHorizontal();

                        string label = conversation.options[i].dialogueOption.gameObject.name;
                        if (label.Length > 22)
                        {
                            label = label.Substring(0, 22);
                        }

                        if (GUILayout.Button(label))
                        {
                            if (conversation.interactionSource == InteractionSource.InScene)
                            {
                                Selection.activeGameObject = conversation.options[i].dialogueOption.gameObject;
                            }
                        }

                        if (GUILayout.Button("", ActionListEditorWindow.nodeSkin.customStyles[13]))
                        {
                            if (conversation.interactionSource == InteractionSource.InScene)
                            {
                                ActionListEditorWindow.Init(conversation.options[i].dialogueOption);
                            }
                            else
                            {
                                ActionListEditorWindow.Init(conversation.options[i].dialogueOption.assetFile);
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("(Not set)");
                        if (GUILayout.Button("Create"))
                        {
                            Undo.RecordObject(conversation, "Auto-create dialogue option");
                            DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();

                            newDialogueOption.gameObject.name = AdvGame.UniqueName(conversation.gameObject.name + "_Option");
                            newDialogueOption.Initialise();
                            EditorUtility.SetDirty(newDialogueOption);
                            conversation.options[i].dialogueOption = newDialogueOption;
                        }
                        GUILayout.EndHorizontal();
                    }
                }
            }
            else if (ID < conversation.options.Count * 3)
            {
                int i = ID - (conversation.options.Count * 2);
                conversation.options[i].conversationAction = (ConversationAction)EditorGUILayout.EnumPopup(conversation.options[i].conversationAction);
            }
            else
            {
                int i = ID - (conversation.options.Count * 3);
                if (conversation.options[i].newConversation != null)
                {
                    conversation.options[i].newConversation = (Conversation)EditorGUILayout.ObjectField(conversation.options[i].newConversation, typeof(Conversation), true);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    conversation.options[i].newConversation = (Conversation)EditorGUILayout.ObjectField(conversation.options[i].newConversation, typeof(Conversation), true);

                    if (GUILayout.Button("Create"))
                    {
                        Undo.RecordObject(conversation, "Auto-create conversation");
                        Conversation newConversation = SceneManager.AddPrefab("Logic", "Conversation", true, false, true).GetComponent <Conversation>();
                        conversation.options[i].newConversation = newConversation;
                    }
                    GUILayout.EndHorizontal();
                }
            }
        }
        private void OptionsGUI()
        {
            if (conversation == null)
            {
                return;
            }

            scrollPosition = GUI.BeginScrollView(new Rect(0, 0, position.width, position.height), scrollPosition, new Rect(0, 0, 1100, 77 * (conversation.options.Count + 2)), false, false);
            BeginWindows();

            convRect = new Rect(20, 100, 150, 50);
            convRect = GUI.Window(-1, convRect, NodeWindow, "Conversation");

            if (GUI.Button(convRect, ""))
            {
                Selection.activeGameObject = conversation.gameObject;
                foreach (ButtonDialog option in conversation.options)
                {
                    option.isEditing = false;
                }
                conversation.selectedOption = null;
            }

            if (lastConversation != null)
            {
                lastRect = new Rect(20, 20, 150, 50);
                lastRect = GUI.Window(-2, lastRect, NodeWindow, "Previous conversation");

                if (GUI.Button(lastRect, ""))
                {
                    Selection.activeGameObject = lastConversation.gameObject;
                }
            }

            for (int i = 0; i < conversation.options.Count; i++)
            {
                optionRect = new Rect(220, 20 + (i * 80), 200, 50);
                optionRect = GUI.Window(i, optionRect, NodeWindow, "Dialogue option");

                if (conversation.options[i].label == "")
                {
                    DrawNodeCurve(convRect, optionRect, Color.red);
                }
                else
                {
                    DrawNodeCurve(convRect, optionRect, Color.blue);
                }

                if (GUI.Button(optionRect, ""))
                {
                    Selection.activeGameObject = conversation.gameObject;
                    foreach (ButtonDialog option in conversation.options)
                    {
                        option.isEditing = false;
                    }
                    conversation.options[i].isEditing = true;
                    conversation.selectedOption       = conversation.options[i];
                }

                interactionRect = new Rect(440, 20 + (i * 80), 200, 50);
                interactionRect = GUI.Window(i + conversation.options.Count, interactionRect, NodeWindow, "Interaction");

                if (conversation.options[i].dialogueOption == null)
                {
                    DrawNodeCurve(optionRect, interactionRect, Color.red);
                }
                else
                {
                    DrawNodeCurve(optionRect, interactionRect, Color.blue);
                }

                if (conversation.options[i].dialogueOption != null)
                {
                    finishRect = new Rect(660, 20 + (i * 80), 200, 50);
                    finishRect = GUI.Window(i + (conversation.options.Count * 2), finishRect, NodeWindow, "When finished");
                    DrawNodeCurve(interactionRect, finishRect, Color.blue);

                    if (GUI.Button(finishRect, ""))
                    {
                        Selection.activeGameObject = conversation.gameObject;
                        foreach (ButtonDialog option in conversation.options)
                        {
                            option.isEditing = false;
                        }
                        conversation.options[i].isEditing = true;
                        conversation.selectedOption       = conversation.options[i];
                    }

                    if (conversation.options[i].conversationAction == AC.ConversationAction.RunOtherConversation)
                    {
                        newRect = new Rect(880, 20 + (i * 80), 200, 50);
                        newRect = GUI.Window(i + (conversation.options.Count * 3), newRect, NodeWindow, "Conversation");

                        if (conversation.options[i].newConversation == null)
                        {
                            DrawNodeCurve(finishRect, newRect, Color.red);
                        }
                        else
                        {
                            DrawNodeCurve(finishRect, newRect, Color.blue);
                        }

                        if (conversation.options[i].newConversation != null)
                        {
                            if (GUI.Button(newRect, ""))
                            {
                                lastConversation           = conversation;
                                Selection.activeGameObject = conversation.options[i].newConversation.gameObject;
                            }
                        }
                    }
                }
            }

            EndWindows();

            if (GUI.Button(new Rect(260, 10 + (conversation.options.Count * 80), 120, 20), "Add new option"))
            {
                Undo.RecordObject(conversation, "Create dialogue option");
                ButtonDialog newOption = new ButtonDialog(conversation.GetIDArray());
                conversation.options.Add(newOption);

                Selection.activeGameObject = conversation.gameObject;
                foreach (ButtonDialog option in conversation.options)
                {
                    option.isEditing = false;
                }
                newOption.isEditing         = true;
                conversation.selectedOption = newOption;
            }

            GUI.EndScrollView();
        }
Exemple #17
0
        protected void RunOption(ButtonDialog _option)
        {
            KickStarter.actionListManager.SetCorrectGameState();

            _option.hasBeenChosen = true;
            if (options.Contains(_option))
            {
                lastOption = options.IndexOf(_option);
                if (KickStarter.actionListManager.OverrideConversation(lastOption))
                {
                    KickStarter.eventManager.Call_OnClickConversation(this, _option.ID);
                    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 != null)
                {
                    endConversation = _option.newConversation;
                }
            }

            if (interactionSource == AC.InteractionSource.AssetFile && _option.assetFile)
            {
                AdvGame.RunActionListAsset(_option.assetFile, endConversation);
            }
            else if (interactionSource == AC.InteractionSource.CustomScript)
            {
                if (_option.customScriptObject != null && !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);

                if (endConversation != null)
                {
                    endConversation.Interact();
                }
                else
                {
                    KickStarter.stateHandler.gameState = GameState.Normal;
                }
            }

            KickStarter.eventManager.Call_OnClickConversation(this, _option.ID);
        }
 void GetChoiceID(Conversation conversation, int optionID)
 {
     choiceID = optionID;
 }
 public void OnEnable()
 {
     _target = (Conversation) target;
 }
 /**
  * <summary>Runs the Conversation set to do so when the associated ActionList has finished.</summary>
  */
 public void RunConversation()
 {
     conversationOnEnd.Interact();
     conversationOnEnd = null;
 }
        private void OptionsGUI()
        {
            if (conversation == null)
            {
                return;
            }

            scrollPosition = GUI.BeginScrollView (new Rect (0, 0, position.width, position.height), scrollPosition, new Rect (0, 0, 1100, 77 * (conversation.options.Count + 2)), false, false);
            BeginWindows ();

            convRect = new Rect (20, 100, 150, 50);
            convRect = GUI.Window(-1, convRect, NodeWindow, "Conversation");

            if (GUI.Button (convRect, ""))
            {
                Selection.activeGameObject = conversation.gameObject;
                foreach (ButtonDialog option in conversation.options)
                {
                    option.isEditing = false;
                }
                conversation.selectedOption = null;
            }

            if (lastConversation != null)
            {
                lastRect = new Rect (20, 20, 150, 50);
                lastRect = GUI.Window(-2, lastRect, NodeWindow, "Previous conversation");

                if (GUI.Button (lastRect, ""))
                {
                    Selection.activeGameObject = lastConversation.gameObject;
                }
            }

            for (int i=0; i<conversation.options.Count; i++)
            {
                optionRect = new Rect (220, 20 + (i*80), 200, 50);
                optionRect = GUI.Window(i, optionRect, NodeWindow, "Dialogue option");

                if (conversation.options[i].label == "")
                {
                    DrawNodeCurve (convRect, optionRect, Color.red);
                }
                else
                {
                    DrawNodeCurve (convRect, optionRect, Color.blue);
                }

                if (GUI.Button (optionRect, ""))
                {
                    Selection.activeGameObject = conversation.gameObject;
                    foreach (ButtonDialog option in conversation.options)
                    {
                        option.isEditing = false;
                    }
                    conversation.options[i].isEditing = true;
                    conversation.selectedOption = conversation.options[i];
                }

                interactionRect = new Rect (440, 20 + (i*80), 200, 50);
                interactionRect = GUI.Window(i + conversation.options.Count, interactionRect, NodeWindow, "Interaction");

                if (conversation.options[i].dialogueOption == null)
                {
                    DrawNodeCurve (optionRect, interactionRect, Color.red);
                }
                else
                {
                    DrawNodeCurve (optionRect, interactionRect, Color.blue);
                }

                if (conversation.options[i].dialogueOption != null)
                {
                    finishRect = new Rect (660, 20 + (i*80), 200, 50);
                    finishRect = GUI.Window(i + (conversation.options.Count*2), finishRect, NodeWindow, "When finished");
                    DrawNodeCurve (interactionRect, finishRect, Color.blue);

                    if (GUI.Button (finishRect, ""))
                    {
                        Selection.activeGameObject = conversation.gameObject;
                        foreach (ButtonDialog option in conversation.options)
                        {
                            option.isEditing = false;
                        }
                        conversation.options[i].isEditing = true;
                        conversation.selectedOption = conversation.options[i];
                    }

                    if (conversation.options[i].conversationAction == AC.ConversationAction.RunOtherConversation)
                    {
                        newRect = new Rect (880, 20 + (i*80), 200, 50);
                        newRect = GUI.Window(i + (conversation.options.Count*3), newRect, NodeWindow, "Conversation");

                        if (conversation.options[i].newConversation == null)
                        {
                            DrawNodeCurve (finishRect, newRect, Color.red);
                        }
                        else
                        {
                            DrawNodeCurve (finishRect, newRect, Color.blue);
                        }

                        if (conversation.options[i].newConversation != null)
                        {
                            if (GUI.Button (newRect, ""))
                            {
                                lastConversation = conversation;
                                Selection.activeGameObject = conversation.options[i].newConversation.gameObject;
                            }
                        }
                    }
                }

            }

            EndWindows ();

            if (GUI.Button (new Rect (260, 10 + (conversation.options.Count*80), 120, 20), "Add new option"))
            {
                Undo.RecordObject (conversation, "Create dialogue option");
                ButtonDialog newOption = new ButtonDialog (conversation.GetIDArray ());
                conversation.options.Add (newOption);

                Selection.activeGameObject = conversation.gameObject;
                foreach (ButtonDialog option in conversation.options)
                {
                    option.isEditing = false;
                }
                newOption.isEditing = true;
                conversation.selectedOption = newOption;
            }

            GUI.EndScrollView ();
        }
        /**
         * <summary>Restores the class's data from a saved string.</summary>
         * <param name = "data">The saved string to restore from</param>
         * <param name = "subScene">If set, only data for a given subscene will be loaded. If null, only data for the active scene will be loaded</param>
         * <returns>True if the data was successfully restored</returns>
         */
        public bool LoadData(string dataString, SubScene subScene = null)
        {
            if (string.IsNullOrEmpty(dataString))
            {
                return(false);
            }

            string[] dataArray = dataString.Split(SaveSystem.colon[0]);

            // ID
            string listName = AdvGame.PrepareStringForLoading(dataArray[0]);

            resumeIndices = new int[0];

            // Resume
            string[] resumeData = dataArray[1].Split("]"[0]);
            if (resumeData.Length > 0)
            {
                List <int> resumeIndexList = new List <int>();
                for (int i = 0; i < resumeData.Length; i++)
                {
                    int resumeIndex = -1;
                    if (int.TryParse(resumeData[i], out resumeIndex) && resumeIndex >= 0)
                    {
                        resumeIndexList.Add(resumeIndex);
                    }
                }
                resumeIndices = resumeIndexList.ToArray();
            }

            // StartIndex
            int.TryParse(dataArray[2], out startIndex);

            // Skip queue
            int j = 0;

            int.TryParse(dataArray[3], out j);
            inSkipQueue = (j == 1) ? true : false;

            // IsRunning
            j = 0;
            int.TryParse(dataArray[4], out j);
            isRunning = (j == 1) ? true : false;

            // Conversation on end
            int convID = 0;

            int.TryParse(dataArray[5], out convID);
            if (convID != 0)
            {
                conversationOnEnd = Serializer.returnComponent <Conversation> (convID, (subScene != null) ? subScene.gameObject : null);
            }

            // Parameter data
            parameterData = dataArray[6];

            // ActionList
            int ID = 0;

            if (int.TryParse(listName, out ID))
            {
                // Scene
                ConstantID constantID = Serializer.returnComponent <ConstantID> (ID, (subScene != null) ? subScene.gameObject : null);
                if (constantID != null && constantID.GetComponent <ActionList>() != null)
                {
                    actionList = constantID.GetComponent <ActionList>();
                    return(true);
                }
            }
            else
            {
                // Asset file
                ActionListAsset tempAsset = ScriptableObject.CreateInstance <ActionListAsset> ();
                actionListAsset = AssetLoader.RetrieveAsset <ActionListAsset> (tempAsset, listName);
                if (actionListAsset != null && actionListAsset != tempAsset)
                {
                    return(true);
                }

                ACDebug.LogWarning("Could not restore data related to the ActionList asset '" + listName + "' - to restore it correctly, the asset must be placed in a folder named Resources.");
            }
            return(false);
        }
Exemple #23
0
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            parameterID = Action.ChooseParameterGUI ("Conversation:", parameters, parameterID, ParameterType.GameObject);
            if (parameterID >= 0)
            {
                constantID = 0;
                conversation = null;
            }
            else
            {
                conversation = (Conversation) EditorGUILayout.ObjectField ("Conversation:", conversation, typeof (Conversation), true);

                constantID = FieldToID <Conversation> (conversation, constantID);
                conversation = IDToField <Conversation> (conversation, constantID, false);
            }

            if (conversation)
            {
                conversation.Upgrade ();
                overrideOptions = EditorGUILayout.Toggle ("Override options?", overrideOptions);

                if (overrideOptions)
                {
                    numSockets = conversation.options.Count;
                }
                else
                {
                    numSockets = 0;
                }
            }
            else
            {
                if (isAssetFile && overrideOptions && constantID != 0)
                {
                    EditorGUILayout.HelpBox ("Cannot find linked Conversation - please open its scene file.", MessageType.Warning);
                }
                else
                {
                    numSockets = 0;
                }
            }
        }
 public override void AssignValues()
 {
     linkedConversation = AssignFile <Conversation> (constantID, linkedConversation);
 }
Exemple #25
0
        public static RuntimeActionList RunActionListAsset(ActionListAsset actionListAsset, Conversation endConversation, int i, bool doSkip, bool addToSkipQueue)
        {
            if (actionListAsset != null && actionListAsset.actions.Count > 0)
            {
                GameObject        runtimeActionListObject = (GameObject)Instantiate(Resources.Load(Resource.runtimeActionList));
                RuntimeActionList runtimeActionList       = runtimeActionListObject.GetComponent <RuntimeActionList>();
                runtimeActionList.DownloadActions(actionListAsset, endConversation, i, doSkip, addToSkipQueue);
                return(runtimeActionList);
            }

            return(null);
        }
        /**
         * <summary>Resets and removes a ActionList from the internal record of currently-running ActionLists, and sets the correct GameState in StateHandler.</summary>
         * <param name = "_list">The ActionList to end</param>
         */
        public void EndList(ActionList _list)
        {
            if (_list == null)
            {
                return;
            }

            if (IsListRunning (_list))
            {
                activeLists.Remove (_list);
            }

            _list.ResetList ();

            if (_list.conversation == conversationOnEnd && _list.conversation != null)
            {
                if (KickStarter.stateHandler)
                {
                    KickStarter.stateHandler.gameState = GameState.Cutscene;
                }
                else
                {
                    ACDebug.LogWarning ("Could not set correct GameState!");
                }

                ResetSkipVars ();
                conversationOnEnd.Interact ();
                conversationOnEnd = null;
            }
            else
            {
                if (_list is RuntimeActionList && _list.actionListType == ActionListType.PauseGameplay && !_list.unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn (null))
                {
                    // Don't affect the gamestate if we want to remain frozen
                    if (KickStarter.stateHandler.gameState != GameState.Cutscene)
                    {
                        ResetSkipVars ();
                    }
                }
                else
                {
                    SetCorrectGameStateEnd ();
                }
            }

            if (_list.autosaveAfter)
            {
                if (!IsGameplayBlocked ())
                {
                    SaveSystem.SaveAutoSave ();
                }
                else
                {
                    saveAfterCutscene = true;
                }
            }

            if (_list is RuntimeActionList)
            {
                RuntimeActionList runtimeActionList = (RuntimeActionList) _list;
                runtimeActionList.DestroySelf ();
            }
        }
Exemple #27
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)
            {
                ActionEnd _lastResult = action.lastResult;

                if (action != null)
                {
                    // 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);
            }
        }
Exemple #28
0
 /**
  * <summary>Runs an ActionList asset file.</summary>
  * <param name = "actionListAsset">The ActionList asset to run</param>
  * <param name = "endConversation">The Conversation to enable when the ActionList is complete</param>
  * <returns>The temporary RuntimeActionList object in the scene that performs the Actions within the asset</returns>
  */
 public static RuntimeActionList RunActionListAsset(ActionListAsset actionListAsset, Conversation endConversation)
 {
     return RunActionListAsset (actionListAsset, endConversation, 0, false, true);
 }
 public void OnEnable()
 {
     _target = (Conversation)target;
 }
Exemple #30
0
 public override void AssignValues()
 {
     runtimeLinkedConversation = AssignFile <Conversation> (constantID, linkedConversation);
 }
Exemple #31
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>();
            if (useParameters && actionListAsset.parameters != null)
            {
                foreach (ActionParameter assetParameter in actionListAsset.parameters)
                {
                    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)
            {
                ActionEnd _lastResult = action.lastResult;

                actions.Add(action);

                if (doSkip && action != null)
                {
                    actions[actions.Count - 1].lastResult = _lastResult;
                }
            }

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

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

            if (actionListAsset.canSurviveSceneChanges && !actionListAsset.IsSkippable())
            {
                DontDestroyOnLoad(gameObject);
            }
        }
Exemple #32
0
 public override void AssignValues(List<ActionParameter> parameters)
 {
     conversation = AssignFile <Conversation> (parameters, parameterID, constantID, conversation);
 }
Exemple #33
0
 public static RuntimeActionList RunActionListAsset(ActionListAsset actionListAsset, Conversation endConversation)
 {
     return(RunActionListAsset(actionListAsset, endConversation, 0, false, true));
 }