Ejemplo n.º 1
0
        private void SideMenu(ButtonDialog option)
        {
            GenericMenu menu = new GenericMenu();

            sideItem = _target.options.IndexOf(option);

            menu.AddItem(new GUIContent("Insert after"), false, Callback, "Insert after");
            if (_target.options.Count > 0)
            {
                menu.AddItem(new GUIContent("Delete"), false, Callback, "Delete");
            }
            if (sideItem > 0 || sideItem < _target.options.Count - 1)
            {
                menu.AddSeparator("");
            }
            if (sideItem > 0)
            {
                menu.AddItem(new GUIContent("Move up"), false, Callback, "Move up");
            }
            if (sideItem < _target.options.Count - 1)
            {
                menu.AddItem(new GUIContent("Move down"), false, Callback, "Move down");
            }

            menu.ShowAsContext();
        }
Ejemplo n.º 2
0
        private void RunOption(ButtonDialog _option)
        {
            _option.hasBeenChosen = true;
            if (options.Contains(_option))
            {
                lastOption = options.IndexOf(_option);
                if (KickStarter.actionListManager.OverrideConversation(lastOption))
                {
                    return;
                }
                lastOption = -1;
            }

            Conversation endConversation;

            if (_option.conversationAction == ConversationAction.ReturnToConversation)
            {
                endConversation = this;
            }
            else if (_option.conversationAction == ConversationAction.RunOtherConversation && _option.newConversation != null)
            {
                endConversation = _option.newConversation;
            }
            else
            {
                endConversation = null;
            }

            if (interactionSource == InteractionSource.AssetFile && _option.assetFile)
            {
                AdvGame.RunActionListAsset(_option.assetFile, endConversation);
            }
            else if (interactionSource == InteractionSource.CustomScript)
            {
                if (_option.customScriptObject != null && _option.customScriptFunction != "")
                {
                    _option.customScriptObject.SendMessage(_option.customScriptFunction);
                }
            }
            else if (interactionSource == InteractionSource.InScene && _option.dialogueOption)
            {
                _option.dialogueOption.conversation = endConversation;
                _option.dialogueOption.Interact();
            }
            else
            {
                ACDebug.Log("No Interaction object found!");

                if (endConversation != null)
                {
                    endConversation.Interact();
                }
                else
                {
                    KickStarter.stateHandler.gameState = GameState.Normal;
                }
            }
        }
        protected void GetChoices()
        {
            conversation.options.Clear();

            for (int i = 0; i < ACInkIntegration.inkStory.currentChoices.Count; ++i)
            {
                Choice       choice = ACInkIntegration.inkStory.currentChoices[i];
                ButtonDialog button = new ButtonDialog(choice.index, choice.text, true);
                conversation.options.Add(button);
            }
        }
Ejemplo n.º 4
0
        private void CreateOptionsGUI()
        {
            EditorGUILayout.LabelField("Dialogue options", EditorStyles.boldLabel);

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(_target.options.Count * 21, 130f) + 5));
            foreach (ButtonDialog option in _target.options)
            {
                EditorGUILayout.BeginHorizontal();

                string buttonLabel = option.ID + ": " + option.label;
                if (option.label == "")
                {
                    buttonLabel += "(Untitled)";
                }
                if (_target.isTimed && _target.options.IndexOf(option) == _target.defaultOption)
                {
                    buttonLabel += " (Default)";
                }

                if (GUILayout.Toggle(option.isEditing, buttonLabel, "Button"))
                {
                    if (_target.selectedOption != option)
                    {
                        DeactivateAllOptions();
                        ActivateOption(option);
                    }
                }

                if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                {
                    SideMenu(option);
                }

                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();

            if (GUILayout.Button("Add new dialogue option"))
            {
                Undo.RecordObject(_target, "Create dialogue option");
                ButtonDialog newOption = new ButtonDialog(_target.GetIDArray());
                _target.options.Add(newOption);
                DeactivateAllOptions();
                ActivateOption(newOption);
            }
        }
Ejemplo n.º 5
0
        private void Callback(object obj)
        {
            if (sideItem >= 0)
            {
                ButtonDialog tempItem = _target.options[sideItem];

                switch (obj.ToString())
                {
                case "Insert after":
                    Undo.RecordObject(_target, "Insert option");
                    _target.options.Insert(sideItem + 1, new ButtonDialog(_target.GetIDArray()));
                    break;

                case "Delete":
                    Undo.RecordObject(_target, "Delete option");
                    DeactivateAllOptions();
                    _target.options.RemoveAt(sideItem);
                    break;

                case "Move up":
                    Undo.RecordObject(_target, "Move option up");
                    _target.options.RemoveAt(sideItem);
                    _target.options.Insert(sideItem - 1, tempItem);
                    break;

                case "Move down":
                    Undo.RecordObject(_target, "Move option down");
                    _target.options.RemoveAt(sideItem);
                    _target.options.Insert(sideItem + 1, tempItem);
                    break;
                }
            }

            EditorUtility.SetDirty(_target);

            sideItem = -1;
        }
Ejemplo n.º 6
0
        private void SideMenu(ButtonDialog option)
        {
            GenericMenu menu = new GenericMenu();

            sideItem = _target.options.IndexOf(option);

            menu.AddItem(new GUIContent("Insert after"), false, Callback, "Insert after");
            if (_target.options.Count > 0)
            {
                menu.AddItem(new GUIContent("Delete"), false, Callback, "Delete");
            }

            if (sideItem > 0 || sideItem < _target.options.Count - 1)
            {
                menu.AddSeparator("");
            }

            if (sideItem > 0)
            {
                menu.AddItem(new GUIContent("Re-arrange/Move to top"), false, Callback, "Move to top");
                menu.AddItem(new GUIContent("Re-arrange/Move up"), false, Callback, "Move up");
            }
            if (sideItem < (_target.options.Count - 1))
            {
                menu.AddItem(new GUIContent("Re-arrange/Move down"), false, Callback, "Move down");
                menu.AddItem(new GUIContent("Re-arrange/Move to bottom"), false, Callback, "Move to bottom");
            }

            if (_target.isTimed && _target.options.IndexOf(option) != _target.defaultOption)
            {
                menu.AddSeparator("");
                menu.AddItem(new GUIContent("Make default"), false, Callback, "Make default");
            }

            menu.ShowAsContext();
        }
Ejemplo n.º 7
0
        private void EditOptionGUI(ButtonDialog option, InteractionSource source)
        {
            EditorGUILayout.BeginVertical("Button");

            if (option.lineID > -1)
            {
                EditorGUILayout.LabelField("Speech Manager ID:", option.lineID.ToString());
            }

            option.label = EditorGUILayout.TextField("Label:", option.label);

            if (source == InteractionSource.AssetFile)
            {
                option.assetFile = (ActionListAsset)EditorGUILayout.ObjectField("Interaction:", option.assetFile, typeof(ActionListAsset), false);
            }
            else if (source == InteractionSource.CustomScript)
            {
                option.customScriptObject   = (GameObject)EditorGUILayout.ObjectField("Object with script:", option.customScriptObject, typeof(GameObject), true);
                option.customScriptFunction = EditorGUILayout.TextField("Message to send:", option.customScriptFunction);
            }
            else if (source == InteractionSource.InScene)
            {
                EditorGUILayout.BeginHorizontal();
                option.dialogueOption = (DialogueOption)EditorGUILayout.ObjectField("Interaction:", option.dialogueOption, typeof(DialogueOption), true);
                if (option.dialogueOption == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        Undo.RecordObject(_target, "Auto-create dialogue option");
                        DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();

                        newDialogueOption.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Option");
                        newDialogueOption.Initialise();
                        EditorUtility.SetDirty(newDialogueOption);
                        option.dialogueOption = newDialogueOption;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            option.cursorIcon.ShowGUI(false, true, "Icon texture:");

            option.isOn = EditorGUILayout.Toggle("Is enabled?", option.isOn);
            if (source == InteractionSource.CustomScript)
            {
                EditorGUILayout.HelpBox("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info);
            }
            else
            {
                option.conversationAction = (ConversationAction)EditorGUILayout.EnumPopup("When finished:", option.conversationAction);
                if (option.conversationAction == AC.ConversationAction.RunOtherConversation)
                {
                    option.newConversation = (Conversation)EditorGUILayout.ObjectField("Conversation to run:", option.newConversation, typeof(Conversation), true);
                }
            }

            option.linkToInventory = EditorGUILayout.ToggleLeft("Only show if carrying specific inventory item?", option.linkToInventory);
            if (option.linkToInventory)
            {
                option.linkedInventoryID = CreateInventoryGUI(option.linkedInventoryID);
            }

            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 8
0
		private void RunOption (ButtonDialog _option)
		{
			Conversation endConversation;
			if (_option.conversationAction == ConversationAction.ReturnToConversation)
			{
				endConversation = this;
			}
			else if (_option.conversationAction == ConversationAction.RunOtherConversation && _option.newConversation != null)
			{
				endConversation = _option.newConversation;
			}
			else
			{
				endConversation = null;
			}
			
			if (interactionSource == ActionListSource.AssetFile && _option.assetFile)
			{
				AdvGame.RunActionListAsset (_option.assetFile, endConversation);
			}
			else if (interactionSource == ActionListSource.InScene && _option.dialogueOption)
			{
				_option.dialogueOption.conversation = endConversation;
				_option.dialogueOption.Interact ();
			}
			else
			{
				Debug.Log ("No Interaction object found!");
				stateHandler.gameState = GameState.Normal;
			}
		}
Ejemplo n.º 9
0
        private void ExtractDialogOption(ButtonDialog dialogOption, bool onlySeekNew)
        {
            ProcessActionListAsset (dialogOption.assetFile, onlySeekNew);

            if (onlySeekNew && dialogOption.lineID < 1)
            {
                // Assign a new ID on creation
                SpeechLine newLine;
                newLine = new SpeechLine (GetIDArray(), UnityVersionHandler.GetCurrentSceneName (), dialogOption.label, languages.Count - 1, AC_TextType.DialogueOption);
                dialogOption.lineID = newLine.lineID;
                lines.Add (newLine);
            }

            else if (!onlySeekNew && dialogOption.lineID > 0)
            {
                // Already has an ID, so don't replace
                SpeechLine existingLine = new SpeechLine (dialogOption.lineID, UnityVersionHandler.GetCurrentSceneName (), dialogOption.label, languages.Count - 1, AC_TextType.DialogueOption);

                int lineID = SmartAddLine (existingLine);
                if (lineID >= 0) dialogOption.lineID = lineID;
            }
        }
Ejemplo n.º 10
0
 private void ActivateOption(ButtonDialog option)
 {
     option.isEditing                  = true;
     _target.selectedOption            = option;
     EditorGUIUtility.editingTextField = false;
 }
	private void ActivateOption (ButtonDialog option)
	{
		option.isEditing = true;
		_target.selectedOption = option;
	}
 private void ActivateOption(ButtonDialog option)
 {
     option.isEditing       = true;
     _target.selectedOption = option;
 }
        private void EditOptionGUI(ButtonDialog option, InteractionSource source)
        {
            EditorGUILayout.BeginVertical ("Button");

            if (option.lineID > -1)
            {
                EditorGUILayout.LabelField ("Speech Manager ID:", option.lineID.ToString ());
            }

            option.label = EditorGUILayout.TextField ("Label:", option.label);

            if (source == InteractionSource.AssetFile)
            {
                option.assetFile = (ActionListAsset) EditorGUILayout.ObjectField ("Interaction:", option.assetFile, typeof (ActionListAsset), false);
            }
            else if (source == InteractionSource.CustomScript)
            {
                option.customScriptObject = (GameObject) EditorGUILayout.ObjectField ("Object with script:", option.customScriptObject, typeof (GameObject), true);
                option.customScriptFunction = EditorGUILayout.TextField ("Message to send:", option.customScriptFunction);
            }
            else if (source == InteractionSource.InScene)
            {
                EditorGUILayout.BeginHorizontal ();
                option.dialogueOption = (DialogueOption) EditorGUILayout.ObjectField ("Interaction:", option.dialogueOption, typeof (DialogueOption), true);
                if (option.dialogueOption == null)
                {
                    if (GUILayout.Button ("Create", GUILayout.MaxWidth (60f)))
                    {
                        Undo.RecordObject (_target, "Auto-create dialogue option");
                        DialogueOption newDialogueOption = SceneManager.AddPrefab ("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();

                        newDialogueOption.gameObject.name = AdvGame.UniqueName (_target.gameObject.name + "_Option");
                        newDialogueOption.Initialise ();
                        EditorUtility.SetDirty (newDialogueOption);
                        option.dialogueOption = newDialogueOption;
                    }
                }
                EditorGUILayout.EndHorizontal ();
            }

            EditorGUILayout.BeginHorizontal ();
            EditorGUILayout.LabelField ("Icon texture:", GUILayout.Width (155f));
            option.icon = (Texture2D) EditorGUILayout.ObjectField (option.icon, typeof (Texture2D), false, GUILayout.Width (70f), GUILayout.Height (30f));
            EditorGUILayout.EndHorizontal ();

            option.isOn = EditorGUILayout.Toggle ("Is enabled?", option.isOn);
            if (source == InteractionSource.CustomScript)
            {
                EditorGUILayout.HelpBox ("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info);
            }
            else
            {
                option.conversationAction = (ConversationAction) EditorGUILayout.EnumPopup ("When finished:", option.conversationAction);
                if (option.conversationAction == AC.ConversationAction.RunOtherConversation)
                {
                    option.newConversation = (Conversation) EditorGUILayout.ObjectField ("Conversation to run:", option.newConversation, typeof (Conversation), true);
                }
            }

            if (_target.isTimed)
            {
                if (_target.options.IndexOf (option) != _target.defaultOption)
                {
                    if (GUILayout.Button ("Make default", GUILayout.MaxWidth (80)))
                    {
                        Undo.RecordObject (_target, "Change default conversation option");
                        _target.defaultOption = _target.options.IndexOf (option);
                        EditorUtility.SetDirty (_target);
                    }
                }
            }

            EditorGUILayout.EndVertical ();
        }
	private void EditOptionGUI (ButtonDialog option, bool useAssetFile)
	{
		EditorGUILayout.BeginVertical ("Button");
		
		if (option.lineID > -1)
		{
			EditorGUILayout.LabelField ("Speech Manager ID:", option.lineID.ToString ());
		}
		
		option.label = EditorGUILayout.TextField ("Label:", option.label);

		if (useAssetFile)
		{
			option.assetFile = (ActionListAsset) EditorGUILayout.ObjectField ("Interaction:", option.assetFile, typeof (ActionListAsset), false);
		}
		else
		{
			EditorGUILayout.BeginHorizontal ();
			option.dialogueOption = (DialogueOption) EditorGUILayout.ObjectField ("Interaction:", option.dialogueOption, typeof (DialogueOption), true);
			if (option.dialogueOption == null)
			{
				if (GUILayout.Button ("Auto-create", GUILayout.MaxWidth (90f)))
				{
					Undo.RecordObject (_target, "Auto-create dialogue option");
					DialogueOption newDialogueOption = AdvGame.GetReferences ().sceneManager.AddPrefab ("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();
					
					newDialogueOption.gameObject.name = AdvGame.UniqueName (_target.gameObject.name + "_Option");
					option.dialogueOption = newDialogueOption;
				}
			}
			EditorGUILayout.EndHorizontal ();
		}
		
		EditorGUILayout.BeginHorizontal ();
		EditorGUILayout.LabelField ("Icon texture:", GUILayout.Width (155f));
		option.icon = (Texture2D) EditorGUILayout.ObjectField (option.icon, typeof (Texture2D), false, GUILayout.Width (70f), GUILayout.Height (30f));
		EditorGUILayout.EndHorizontal ();
		
		option.isOn = EditorGUILayout.Toggle ("Is enabled?", option.isOn);
		option.conversationAction = (ConversationAction) EditorGUILayout.EnumPopup ("When finished:", option.conversationAction);
		if (option.conversationAction == AC.ConversationAction.RunOtherConversation)
		{
			option.newConversation = (Conversation) EditorGUILayout.ObjectField ("Conversation to run:", option.newConversation, typeof (Conversation), true);
		}
		
		if (_target.isTimed)
		{
			if (_target.options.IndexOf (option) != _target.defaultOption)
			{
				if (GUILayout.Button ("Make default", GUILayout.MaxWidth (80)))
				{
					Undo.RecordObject (_target, "Change default conversation option");
					_target.defaultOption = _target.options.IndexOf (option);
					EditorUtility.SetDirty (_target);
				}
			}
		}
		
		EditorGUILayout.EndVertical ();
	}
Ejemplo n.º 15
0
		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 ();
		}
Ejemplo n.º 16
0
        private void Callback(object obj)
        {
            if (sideItem >= 0)
            {
                ButtonDialog tempItem = _target.options[sideItem];

                switch (obj.ToString())
                {
                case "Insert after":
                    Undo.RecordObject(_target, "Insert option");
                    _target.options.Insert(sideItem + 1, new ButtonDialog(_target.GetIDArray()));
                    break;

                case "Delete":
                    Undo.RecordObject(_target, "Delete option");
                    DeactivateAllOptions();
                    _target.options.RemoveAt(sideItem);
                    break;

                case "Move to top":
                    Undo.RecordObject(this, "Move option to top");
                    if (_target.defaultOption == sideItem)
                    {
                        _target.defaultOption = 0;
                    }
                    _target.options.RemoveAt(sideItem);
                    _target.options.Insert(0, tempItem);
                    break;

                case "Move up":
                    Undo.RecordObject(_target, "Move option up");
                    if (_target.defaultOption == sideItem)
                    {
                        _target.defaultOption--;
                    }
                    _target.options.RemoveAt(sideItem);
                    _target.options.Insert(sideItem - 1, tempItem);
                    break;

                case "Move down":
                    Undo.RecordObject(_target, "Move option down");
                    if (_target.defaultOption == sideItem)
                    {
                        _target.defaultOption++;
                    }
                    _target.options.RemoveAt(sideItem);
                    _target.options.Insert(sideItem + 1, tempItem);
                    break;

                case "Move to bottom":
                    Undo.RecordObject(_target, "Move option to bottom");
                    if (_target.defaultOption == sideItem)
                    {
                        _target.defaultOption = _target.options.Count - 1;
                    }
                    _target.options.RemoveAt(sideItem);
                    _target.options.Insert(_target.options.Count, tempItem);
                    break;

                case "Make default":
                    Undo.RecordObject(_target, "Change default Conversation option");
                    _target.defaultOption = sideItem;
                    EditorUtility.SetDirty(_target);
                    break;
                }
            }

            EditorUtility.SetDirty(_target);

            sideItem = -1;
        }
Ejemplo n.º 17
0
		private void ExtractDialogOption (ButtonDialog dialogOption, bool onlySeekNew)
		{
			if (dialogOption.assetFile != null)
			{
				ProcessActionList (dialogOption.assetFile.actions, onlySeekNew, true);
				EditorUtility.SetDirty (dialogOption.assetFile);
			}

			if (onlySeekNew && dialogOption.lineID < 1)
			{
				// Assign a new ID on creation
				SpeechLine newLine;
				newLine = new SpeechLine (GetIDArray(), EditorApplication.currentScene, dialogOption.label, languages.Count - 1, AC_TextType.DialogueOption);
				dialogOption.lineID = newLine.lineID;
				lines.Add (newLine);
			}
			
			else if (!onlySeekNew && dialogOption.lineID > 0)
			{
				// Already has an ID, so don't replace
				lines.Add (new SpeechLine (dialogOption.lineID, EditorApplication.currentScene, dialogOption.label, languages.Count - 1, AC_TextType.DialogueOption));
			}
		}
	private void CreateOptionsGUI ()
	{
		EditorGUILayout.LabelField ("Dialogue options", EditorStyles.boldLabel);
		
		foreach (ButtonDialog option in _target.options)
		{
			EditorGUILayout.BeginHorizontal ();
			
			string buttonLabel = option.ID + ": " + option.label;
			if (option.label == "")
			{
				buttonLabel += "(Untitled)";	
			}
			if (_target.isTimed && _target.options.IndexOf (option) == _target.defaultOption)
			{
				buttonLabel += " (Default)";
			}
			
			if (GUILayout.Toggle (option.isEditing, buttonLabel, "Button"))
			{
				if (_target.selectedOption != option)
				{
					DeactivateAllOptions ();
					ActivateOption (option);
				}
			}
			
			if (GUILayout.Button (sideIcon, GUILayout.Width (20f), GUILayout.Height (15f)))
			{
				SideMenu (option);
			}

			EditorGUILayout.EndHorizontal ();
		}
		
		if (GUILayout.Button ("Add new dialogue option"))
		{
			Undo.RecordObject (_target, "Create dialogue option");
			ButtonDialog newOption = new ButtonDialog (_target.GetIDArray ());
			_target.options.Add (newOption);
			DeactivateAllOptions ();
			ActivateOption (newOption);
		}
	}
	private void SideMenu (ButtonDialog option)
	{
		GenericMenu menu = new GenericMenu ();
		sideItem = _target.options.IndexOf (option);
		
		menu.AddItem (new GUIContent ("Insert after"), false, Callback, "Insert after");
		if (_target.options.Count > 0)
		{
			menu.AddItem (new GUIContent ("Delete"), false, Callback, "Delete");
		}
		if (sideItem > 0 || sideItem < _target.options.Count-1)
		{
			menu.AddSeparator ("");
		}
		if (sideItem > 0)
		{
			menu.AddItem (new GUIContent ("Move up"), false, Callback, "Move up");
		}
		if (sideItem < _target.options.Count-1)
		{
			menu.AddItem (new GUIContent ("Move down"), false, Callback, "Move down");
		}
		
		menu.ShowAsContext ();
	}
Ejemplo n.º 20
0
        private void RunOption(ButtonDialog _option)
        {
            if (options.Contains (_option))
            {
                if (KickStarter.actionListManager.OverrideConversation (options.IndexOf (_option)))
                {
                    return;
                }
            }

            Conversation endConversation;
            if (_option.conversationAction == ConversationAction.ReturnToConversation)
            {
                endConversation = this;
            }
            else if (_option.conversationAction == ConversationAction.RunOtherConversation && _option.newConversation != null)
            {
                endConversation = _option.newConversation;
            }
            else
            {
                endConversation = null;
            }

            if (interactionSource == InteractionSource.AssetFile && _option.assetFile)
            {
                AdvGame.RunActionListAsset (_option.assetFile, endConversation);
            }
            else if (interactionSource == InteractionSource.CustomScript)
            {
                if (_option.customScriptObject != null && _option.customScriptFunction != "")
                {
                    _option.customScriptObject.SendMessage (_option.customScriptFunction);
                }
            }
            else if (interactionSource == InteractionSource.InScene && _option.dialogueOption)
            {
                _option.dialogueOption.conversation = endConversation;
                _option.dialogueOption.Interact ();
            }
            else
            {
                Debug.Log ("No Interaction object found!");
                KickStarter.stateHandler.gameState = GameState.Normal;
            }
        }
Ejemplo n.º 21
0
        private void EditOptionGUI(ButtonDialog option, InteractionSource source)
        {
            CustomGUILayout.BeginVertical();

            if (option.lineID > -1)
            {
                EditorGUILayout.LabelField("Speech Manager ID:", option.lineID.ToString());
            }

            option.label = CustomGUILayout.TextField("Label:", option.label, "", "The option's display label");

            if (source == InteractionSource.AssetFile)
            {
                option.assetFile = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("Interaction:", option.assetFile, false, "", "The ActionListAsset to run");
            }
            else if (source == InteractionSource.CustomScript)
            {
                option.customScriptObject   = (GameObject)CustomGUILayout.ObjectField <GameObject> ("Object with script:", option.customScriptObject, true, "", "The GameObject with the custom script to run");
                option.customScriptFunction = CustomGUILayout.TextField("Message to send:", option.customScriptFunction, "", "The name of the function to run");
            }
            else if (source == InteractionSource.InScene)
            {
                EditorGUILayout.BeginHorizontal();
                option.dialogueOption = (DialogueOption)CustomGUILayout.ObjectField <DialogueOption> ("DialogOption:", option.dialogueOption, true, "", "The DialogOption to run");
                if (option.dialogueOption == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        Undo.RecordObject(_target, "Auto-create dialogue option");
                        DialogueOption newDialogueOption = SceneManager.AddPrefab("Logic", "DialogueOption", true, false, true).GetComponent <DialogueOption>();

                        newDialogueOption.gameObject.name = AdvGame.UniqueName(_target.gameObject.name + "_Option");
                        newDialogueOption.Initialise();
                        EditorUtility.SetDirty(newDialogueOption);
                        option.dialogueOption = newDialogueOption;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            option.cursorIcon.ShowGUI(false, true, "Icon texture:", CursorRendering.Software, "", "The icon to display in DialogList menu elements");

            option.isOn = CustomGUILayout.Toggle("Is enabled?", option.isOn, "", "If True, the option is enabled, and will be displayed in a MenuDialogList element");
            if (source == InteractionSource.CustomScript)
            {
                EditorGUILayout.HelpBox("Using a custom script will cause the conversation to end when finished, unless it is re-run explicitly.", MessageType.Info);
            }
            else
            {
                option.conversationAction = (ConversationAction)CustomGUILayout.EnumPopup("When finished:", option.conversationAction, "", "What happens when the DialogueOption ActionList has finished");
                if (option.conversationAction == AC.ConversationAction.RunOtherConversation)
                {
                    option.newConversation = (Conversation)CustomGUILayout.ObjectField <Conversation> ("Conversation to run:", option.newConversation, true, "", "The new Conversation to run");
                }
            }

            option.linkToInventory = CustomGUILayout.ToggleLeft("Only show if carrying specific inventory item?", option.linkToInventory, "", " If True, then the option will only be visible if a given inventory item is being carried");
            if (option.linkToInventory)
            {
                option.linkedInventoryID = CreateInventoryGUI(option.linkedInventoryID);
            }

            CustomGUILayout.EndVertical();
        }
Ejemplo n.º 22
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);
        }
Ejemplo n.º 23
0
        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 ();
        }