public void read(Dialogue_Set dialogues) { if (dialogues == null) { return; } if (coroutine == null) { GetComponent <Image>().rectTransform.localScale = new Vector3(1, 0, 1); gameObject.SetActive(true); coroutine = StartCoroutine(readDialogue(dialogues)); } else { nextDialogues.Add(dialogues); } }
//Insert Dialogue Here //Get Dialogue and begin showing text public IEnumerator readDialogue(Dialogue_Set dia) { currentSet = dia; if (dia == null) { if (nextDialogues.Count > 0 && nextDialogues[0] != null) { coroutine = StartCoroutine(readDialogue(nextDialogues[0])); nextDialogues.RemoveAt(0); yield break; } coroutine = StartCoroutine(hideTextbox()); yield break; } List <Dialogue> dialogues = dia.Dialogues; //Disable Player Movement FindObjectOfType <PlayerMovement>()?.DisableMovement(); FindObjectOfType <PlayerState>()?.SetInteracting(true); for (int d = 0; d < dialogues.Count; d++) { if (dialogues[d].Profile != null) { profile.sprite = dialogues[d].Profile; profile.gameObject.SetActive(true); } else { profile.gameObject.SetActive(false); } text.text = ""; //pops the textbox in if it's hidden if (GetComponent <Image>().rectTransform.localScale.y == 0) { while (GetComponent <Image>().rectTransform.localScale.y < 1) { GetComponent <Image>().rectTransform.localScale = new Vector3(1, GetComponent <Image>().rectTransform.localScale.y + 0.05f, 1); yield return(new WaitForFixedUpdate()); } GetComponent <Image>().rectTransform.localScale = new Vector3(1, 1, 1); } //Set the text to display string line = dialogues[d].Line; //Get needed size here text.fontSize = FONT_SIZE_NORMAL; if (line[0].ToString() == "_") { if (line[1].ToString() == "s") { text.fontSize = FONT_SIZE_SMALL; line = line.Remove(0, 2); } else if (line[1].ToString() == "l") { text.fontSize = FONT_SIZE_BIG; line = line.Remove(0, 2); } } for (int c = 0; c < line.Length; c++) { if (line[c].ToString() == "\\") { if ((line.Length > c + 1)) { if (line[c + 1].ToString() == "n") { Debug.Log("Textbox make newline"); text.text = text.text + "\n"; c += 1; continue; } else if (line[c + 1].ToString() == "t") { Debug.Log("Textbox make tab"); text.text = text.text + "\t"; c += 1; continue; } } } text.text = text.text + line[c]; if (Input.GetButton("Attack")) { yield return(new WaitForSeconds(0.01f)); } else { yield return(new WaitForSeconds(1 / speed)); } }//END forloop c yield return(new WaitForSeconds(0.5f)); //Press to continue // while continue not down, loop yield return(new WaitUntil(() => Go)); yield return(new WaitForFixedUpdate()); }//END forloop d if (currentSet.LinkedSet.Count > 0 && DecisionBox.S != null) { //Wait for selection DecisionBox.S.Open(dia.LinkedSet); yield return(new WaitUntil(() => !DecisionBox.S.Deciding)); } if (nextDialogues.Count > 0) { coroutine = StartCoroutine(readDialogue(nextDialogues[0])); nextDialogues.RemoveAt(0); yield break; } coroutine = StartCoroutine(hideTextbox()); yield break; } //END readDialogue
public override void OnInspectorGUI() { //base.OnInspectorGUI(); //Send Dialogue To Textbox.T Dialogue_Set ds = (Dialogue_Set)target; EditorGUILayout.LabelField(" - Send Dialogue to Textbox in Scene (Playmode) -"); if (GUILayout.Button("Send Dialogue")) { Debug.Log("ON_GUI: Dialogue Set sending dialogues"); ds.sendDialogue(); } EditorGUILayout.LabelField(" - Clears the whole Set -"); if (GUILayout.Button("Delete All Dialogue")) { ds.Dialogues.Clear(); } EditorGUILayout.LabelField(" - Add a dialogue to the start of this set -"); if (GUILayout.Button("Add Dialogue (Start)")) { ds.Dialogues.Insert(0, new Dialogue()); } //Change List Size size = ds.Dialogues.Count; EditorGUILayout.Separator(); d = EditorGUILayout.Foldout(d, "Dialogues - Size : " + size); //size = EditorGUILayout.IntField("Size", size); //EditorGUILayout.LabelField("Size: " + size); /* * while (size != ds.Dialogues.Count) { * while (size < ds.Dialogues.Count) { * ds.Dialogues.RemoveAt(ds.Dialogues.Count - 1); * } * while (size > ds.Dialogues.Count) * { * ds.Dialogues.Add(new Dialogue()); * } * }*/ //Display List if (d) { EditorGUI.indentLevel++; for (int i = 0; i < ds.Dialogues.Count; i++) { ds.Dialogues[i].Profile = (Sprite)EditorGUILayout.ObjectField("Profile", ds.Dialogues[i].Profile, typeof(Sprite), false); ds.Dialogues[i].Line = EditorGUILayout.TextField("Line", ds.Dialogues[i].Line); GUILayout.BeginHorizontal(); if (GUILayout.Button("Remove Dialogue")) { ds.Dialogues.Remove(ds.Dialogues[i]); } if (GUILayout.Button("Add Dialogue (Next)")) { ds.Dialogues.Insert(i + 1, new Dialogue()); } GUILayout.EndHorizontal(); } EditorGUI.indentLevel--; } EditorGUILayout.Separator(); EditorGUILayout.LabelField(" - Add a dialogue to the end of this set -"); if (GUILayout.Button("Add Dialogue (End)")) { ds.Dialogues.Add(new Dialogue()); } EditorGUILayout.Separator(); if (GUILayout.Button("Add Option")) { ds.LinkedSet.Add(new LinkSet()); } foreach (LinkSet l in ds.LinkedSet) { l.option = EditorGUILayout.TextField("Text", l.option); l.linkedSet = (Dialogue_Set)EditorGUILayout.ObjectField("Linked Set", l.linkedSet, typeof(Dialogue_Set), false); } if (GUILayout.Button("Remove Option")) { ds.LinkedSet.RemoveAt(ds.LinkedSet.Count - 1); } }
public LinkSet() { option = "Option"; linkedSet = null; }