private void DrawMenuBar() { menuBar = new Rect(0, 0, position.width, menuBarHeight); GUILayout.BeginArea(menuBar, EditorStyles.toolbar); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Save"), EditorStyles.toolbarButton, GUILayout.Width(35))) { var path = EditorUtility.SaveFilePanel( "Save as object", "Assets/Dialogues/", "", "asset"); string fn = Path.GetFileName(path); string[] arr = fn.Split('.'); Save(Path.GetFileName(arr[0])); } GUILayout.Space(5); GUILayout.Label("Save File: ", GUILayout.Width(65)); source = (DialogueObject)EditorGUILayout.ObjectField(source, typeof(DialogueObject), true); GUILayout.EndHorizontal(); GUILayout.EndArea(); }
//Busca el primer dialogo en el mapa de nodos DialogueObject GetFirstDialogue(int startId) { //Por cada nodo foreach (var node in dialog.nodes) { //Por cada parent de cada nodo foreach (var parentId in node.parentIds) { //Si hay una coincidencia entre el parentId y el startId singifica que el nodo tiene como padre al StartingNode if (parentId == startId) { /* Ahora que tengo el id del primer dialogo necesito encontrarlo en la * lista de dialogueObjects para asignarlo como el primer dialogo */ foreach (var dialogue in dialogueObjects) { if (node.id == dialogue.id) { first = dialogue; return(first); } } } } } return(null); }
public DialogueObject giveDialog(DialogueType type, GameObject prefab = null) { DialogueObject d = null; if (prefab == null) { switch (type) { case DialogueType.Dialogue: d = createDialogObject(dialogPrefab); break; case DialogueType.ItemDescription: d = createDialogObject(itemDialogPrefab); break; case DialogueType.ItemShop: d = createDialogObject(shopDialogPrefab); break; } } else { d = createDialogObject(prefab); } return(d); }
private void Save(string fName) { dialogueObject = CreateDialogueObject.Create(fName); if (dialogueObject) { dialogueObject.dialogueid = 5; dialogueObject.ConversationSet = (GenerateDictionaryFromNode()); // dialogueObject.noders = nodes; foreach (Connections c in connections) { ConnectionStruct cs = new ConnectionStruct(c.inPoint, c.outPoint, c.OnClickRemoveConnection); dialogueObject.connectionList.Add(cs); } foreach (DialogNode node in nodes) { NodeInformation nNode = new NodeInformation(node.nodeID, node.rect, node.inPoint.id, node.outPoint.id, node.conversationText, node.isRoot); dialogueObject.nodeInfoList.Add(nNode); } } }
private void PopulateOptions() { DialogueObject dialogueObject = (DialogueObject)target; areaChoices = Dialogue.GetLevelFileListings(); oldAreaChoiceIndex = areaChoiceIndex; areaChoiceIndex = EditorGUILayout.Popup(areaChoiceIndex, areaChoices); if (oldAreaChoiceIndex != areaChoiceIndex) { Dialogue.LoadAreaDialogue(areaChoices[areaChoiceIndex]); } arrayChoices = Dialogue.GetArrayListings(); arrayChoiceIndex = EditorGUILayout.Popup(arrayChoiceIndex, arrayChoices); keywordChoices = Dialogue.GetKeywordListings(arrayChoices[arrayChoiceIndex]); keywordChoiceIndex = EditorGUILayout.Popup(keywordChoiceIndex, keywordChoices); //dialogueObject.SetKeys(arrayChoices[arrayChoiceIndex], keywordChoiceIndex, ); if (GUILayout.Button("Populate")) { //dialogue.GenerateMap(); } EditorUtility.SetDirty(target); }
protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details) { if (details.Equals("endDialogue")) { DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject; if (dialogue == lObject) { AObject patient = world.GetObjectFromId("patient main"); if (this.isSuccess) { patient.SetAnimationIndex(8); } else { patient.SetAnimationIndex(7); } this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(2); this.moment = ExposePhaseMoment.END_DIALOGUE; } } else if (details.Equals("speedUpDialogue")) { DialogueObject dialogue = world.GetObjectFromId("dialogue toubib") as DialogueObject; dialogue.SpeedFactor = 10; } }
/// <summary> /// Shows the dialogue UI with the current dialogue line /// </summary> /// <param name="line">Curremt line that shoudl be displayed</param> void ShowDialogue(DialogueObject line) { //Debug.Log("Show dialogue"); dialogueCanvas.SetActive(true); dialogueInputField.gameObject.SetActive(false); speakerNameText.text = line.speakerName; dialogueText.text = line.dialogueLine; switch (line.dialogueType) { case (DialogueType.BasicLine): if (line.basicLineCall != null) { line.basicLineCall(); } break; case DialogueType.TextInput: dialogueInputField.gameObject.SetActive(true); dialogueInputField.contentType = line.inputContentType; dialogueInputField.characterLimit = line.maxInputLength; dialogueInputField.text = ""; dialogueInputField.placeholder.GetComponent <Text>().text = line.inputPlaceholderText; dialogueInputField.Select(); break; default: Debug.LogError("Error unknown DialogueType " + line.dialogueType); break; } }
void PrintDialogue(DialogueObject dialogue) { if (dialogue == null) { WriteContent("Mago", "Adios!"); return; } currentOptionsIds.Clear(); current = dialogue; var dialogueString = current.dialogue + " \n"; var contador = 0; foreach (var option in current.options) { contador++; dialogueString += "(" + contador + "): " + option.Value + " \n"; currentOptionsIds.Add(contador, option.Key); } WriteContent("Mago", dialogueString); }
//Should refactor below void PrintDialogue(DialogueObject dialogue) { if (dialogue == null) { DisplaySentence("Adios!"); return; } currentOptionsIds.Clear(); current = dialogue; var dialogueString = current.dialogue + " \n"; var contador = 0; foreach (var option in current.options) { contador++; DisplayOption("(" + contador + "): " + option.Value + " \n"); currentOptionsIds.Add(contador, option.Key); } DisplaySentence(dialogueString); }
private void Start() { choicesMode = false; currDialogNode = dialog; currSentences = currDialogNode.sentences; output = DialogueObject.CreateDialogueObject(gameObject, ""); GetNextDialogueChoices(); wait = true; }
public DialogueObject(string dialogue, Vector2 location, float lifeTime) { _dialogue = dialogue; _location = location; _next = null; _boxLifetime = lifeTime; _timer = lifeTime; _followTarget = null; }
/// <summary> /// Changes the current conversation. /// </summary> /// <param name="newConversation">New conversation to be active</param> /// <param name="_endDialogue">Function to be called once dialogue ends. Function must be type void with no parameters.</param> void ChangeCurConversation(List <DialogueObject> newConversation, EndDialogue _endDialogue) { endDialogue = _endDialogue; currentConversation.RemoveRange(0, currentConversation.Count); currentConversation.AddRange(newConversation); dialogueIndex = 0; curDialogueObject = currentConversation[dialogueIndex]; }
public IEnumerator StartDialogueCoroutine([NotNull] DialogueObject dialogue, float initialDelay = 0, bool clearPreExistingDialogue = false) { StartDialogue(dialogue, initialDelay, clearPreExistingDialogue); while (_currentDialogueCoroutine != null && !skipDialogue) { yield return(new WaitForSeconds(1)); } }
public ResponseHandler ShowDialogue(DialogueObject dialogueObject) { if (!isWritingDialogue) { StartCoroutine(DisplayDialogue(dialogueObject)); } return(responseHandler); }
void StartDialogueSequence(DialogueObject dialogue) { segments.Clear(); foreach (var segment in dialogue.dialogueSegments) { segments.Enqueue(segment); } StartCoroutine(DisplayNextSentence()); }
public DialogueObject(DialogueObject original) { _dialogue = original.Dialogue; _location = original.Location; _next = original.Next; _timer = original.Timer; _boxLifetime = original.Lifetime; _followTarget = original.FollowTarget; _freezePlayer = original.FreezePlayer; }
protected override void OnInternalGameEvent(OfficeWorld world, AObject lObject, AObject lObjectTo, string details) { DialogueObject dialogue = world.GetObjectFromId("dialogue coming") as DialogueObject; if (dialogue == lObject) { this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(1); this.moment = PrePhaseMoment.TEXT_APPEARED; } }
public override void UpdateLogic(OfficeWorld world, Time timeElapsed) { this.timeElapsed += timeElapsed; if (this.timeElapsed > periodPhase) { switch (this.moment) { case PrePhaseMoment.START: AObject bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(1); AObject toubib = world.GetObjectFromId("toubib main"); toubib.SetAnimationIndex(3); this.moment = PrePhaseMoment.BUBBLE_APPEARED; this.periodPhase = Time.FromSeconds(1.2f); this.timeElapsed = Time.Zero; break; case PrePhaseMoment.BUBBLE_APPEARED: DialogueObject dialogue = world.GetObjectFromId("dialogue coming") as DialogueObject; dialogue.SetKinematicParameters(new Vector2f(-380f, dialogue.GetHeight(-150)), new Vector2f(0f, 0f)); dialogue.LaunchDialogue(1); AObject queueTalk = world.GetObjectFromId("queueTalk main"); queueTalk.SetKinematicParameters(new Vector2f(100f, 100f), new Vector2f(0f, 0f)); bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(2); this.moment = PrePhaseMoment.START_TALKING; break; case PrePhaseMoment.TEXT_APPEARED: dialogue = world.GetObjectFromId("dialogue coming") as DialogueObject; dialogue.ResetDialogue(); bubble = world.GetObjectFromId("bubble main"); bubble.SetAnimationIndex(3); queueTalk = world.GetObjectFromId("queueTalk main"); queueTalk.SetKinematicParameters(new Vector2f(10000, 10000), new Vector2f(0, 0)); this.timeElapsed = Time.Zero; this.periodPhase = Time.FromSeconds(1); this.moment = PrePhaseMoment.END; break; case PrePhaseMoment.END: this.NodeState = NodeState.NOT_ACTIVE; break; } } }
public static DialogueObject Create(string filename) { DialogueObject asset = ScriptableObject.CreateInstance <DialogueObject>(); AssetDatabase.CreateAsset(asset, "Assets/Dialogues/" + filename + ".asset"); AssetDatabase.SaveAssets(); EditorUtility.SetDirty(asset); return(asset); }
void Start() { if (level == null) { level = GameObject.Find("LevelController").GetComponent <LevelControllerScript> (); } if (dialogue == null) { dialogue = GameObject.Find("DialogueObject").GetComponent <DialogueObject> (); } }
public void StartDialogue(DialogueObject dialogue) { animator.SetBool("IsOpen", true); characterName.text = dialogue.characterName; sentences = new Queue <string>(); foreach (string sentence in dialogue.sentences) { sentences.Enqueue(sentence); } DisplaySentence(); }
public void CallForDialogue() { DialogueObject objectToTalkTo = null; objectToTalkTo = GetObjectToTalkTo(objectToTalkTo); if (objectToTalkTo) { objectToTalkTo.Talk(); } }
/// <summary> /// Sets up the first part of the example dialogue /// </summary> void SetupExampleDialogue() { DialogueObject line1 = new DialogueObject("You", "Hey, it's Joe right?"); DialogueObject line2 = new DialogueObject("Joe", "Yes..?"); DialogueObject line3 = new DialogueObject("You", "That's right! We met a few years back at the sales convention in Atlanta. How have you been?"); DialogueObject line4 = new DialogueObject("Joe", "Oh I remember that! Remind me what is your name again?", InputField.ContentType.Standard, "Your name...", 32, EnterPlayerName); exampleDialogue.Add(line1); exampleDialogue.Add(line2); exampleDialogue.Add(line3); exampleDialogue.Add(line4); }
public void StartDialogue(int starterId, CharacterSounds characterSounds) { _characterSounds = characterSounds; HUD.SetActive(false); dialogueInterface.SetActive(true); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; dialogueObject = dialogueService.GetDialogueObject(starterId); _clipRepository = new DialogueClipRepository(); StartCoroutine(DialogueLoop()); }
public void Setup(DialogueData dialogueData, int curLine, int curActionData, DialogueObject dialogueObj) { actionData = dialogueData.dialogueLines[curLine].actionData[curActionData]; buttonText.text = actionData.choiceText; dialogueObject = dialogueObj; switch (actionData.actionType) { case ActionData.ActionType.PASSCODE: curPasscodeInput = Instantiate(passcodeInput, transform.parent); break; } }
public void SetupActionData(DialogueData dialogueData, int curLine, DialogueObject dialogueObj) { for (int i = 0; i < dialogueButtonList.Count; i++) { Destroy(dialogueButtonList[i]); } dialogueButtonList.Clear(); for (int i = 0; i < dialogueData.dialogueLines[curLine].actionData.Length; i++) { ActionData curActionData = dialogueData.dialogueLines[curLine].actionData[i]; if (curActionData.condition.haveCondition) { Condition curCondition = curActionData.condition; switch (curCondition.keyType) { case Condition.KeyType.FLOAT: if (PlayerPrefs.GetFloat(curCondition.playerPrefKey) == curCondition.targetFloatKey) { break; } return; case Condition.KeyType.INT: if (PlayerPrefs.GetInt(curCondition.playerPrefKey) == curCondition.targetIntKey) { break; } return; case Condition.KeyType.STRING: if (PlayerPrefs.GetString(curCondition.playerPrefKey) == curCondition.targetStringKey) { break; } return; } } //Spawn dialogue button GameObject spawnDialogueGO = Instantiate(dialogueButton, dialogueButtonGroup); DialogueButton dialogueButtonScript = spawnDialogueGO.GetComponent <DialogueButton>(); dialogueButtonScript.Setup(dialogueData, curLine, i, dialogueObj); dialogueButtonList.Add(spawnDialogueGO); } }
private void Update() { if (_dialogue == null) { return; } if (!Input.GetButtonDown("Jump") || pause) { return; } if (_currentLine >= _dialogue.Length) { if (!finalDialogue) { StartCoroutine(TransparentSprite()); } Debug.Log("ending dialogue"); if (GameObject.Find("ReturnToMap") != null) { GameObject.Find("ReturnToMap").GetComponent <ReturnToMap>().inDialogue = false; } TextCanvas.DOFade(0, OpeningAnimationDuration); GameLogic.Instance.dialogueActive = false; LeftCharacterImage.ToggleCharacter(OpeningAnimationDuration); RightCharacterImage.ToggleCharacter(OpeningAnimationDuration); // Actualize Game State if (_do.fireIndex) { GameLogic.Instance.IncreaseDialogueIndex(); } if (_do.fireState) { GameLogic.Instance.NextGameState(); } _do = null; _dialogue = null; finished = true; } else { PlayNextLine(); } }
private void LoadTest(string fileName) { string[] results = AssetDatabase.FindAssets(fileName); if (results.Length != 0) { DialogueObject d = (DialogueObject)AssetDatabase.LoadAssetAtPath("Assets/Dialogues/" + fileName + ".asset", typeof(DialogueObject)); if (d) { nodes = new List <DialogNode>(); ClearConnectionSelection(); connections = new List <Connections>(); for (int i = 0; i < d.nodeInfoList.Count; i++) { nodes.Add(new DialogNode( d.nodeInfoList[i].rect.position, d.nodeInfoList[i].rect.width, d.nodeInfoList[i].rect.height, nodeStyle, selectedNodeStyle, inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, d.nodeInfoList[i].inPointID, d.nodeInfoList[i].outPointID, d.nodeInfoList[i].isRoot, OnClickRemoveNode, d.nodeInfoList[i].nodeID, d.nodeInfoList[i].ConversationText )); } Debug.Log(d.connectionList.Count); foreach (ConnectionStruct connect in d.connectionList) { var inp = nodes.First(n => n.inPoint.id == connect.inPoint.id).inPoint; var outp = nodes.First(n => n.outPoint.id == connect.outPoint.id).outPoint; connections.Add(new Connections(inp, outp, OnClickRemoveConnection)); } GUI.changed = true; } } }
private void OnEnter() { if (isSpeaking && typeManager.IsDialog()) { SpeakToNearby(); isSpeaking = false; DialogueObject.CreateDialogueObject(gameObject, typeManager.GetCurrentDialogueInput(), diaDuration); typeManager.ClearDialogue(); } else { isSpeaking = true; } }
private void OnDialogueEnd([NotNull] DialogueObject dialogue) { if (dialogue.failSafeDialogue != null) { _currentFailSafeCoroutine = StartCoroutine(WaitForFailSafeDialogue(dialogue.failSafeDialogue, dialogue.failSafeDelayInSeconds)); } _currentDialogueCoroutine = null; if (dialogue.sceneIndexLoadedAtEnd > 0) { ScreenFade.Instance.FadeToBlackThenLoadScene(dialogue.sceneIndexLoadedAtEnd); } }