From 9f9dedba988f368173b77b1a6159d8c1df3586d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerard=20Gasc=C3=B3n?= <52170489+GerardGascon@users.noreply.github.com> Date: Thu, 15 Sep 2022 17:32:04 +0200 Subject: [PATCH] Removed old scripts --- Tools/DialogueSystem/DialogueSystem.cs | 75 -------------------- Tools/DialogueSystem/DialogueSystem.cs.meta | 11 --- Tools/DialogueSystem/TMP_Animated.cs | 78 --------------------- Tools/DialogueSystem/TMP_Animated.cs.meta | 11 --- 4 files changed, 175 deletions(-) delete mode 100644 Tools/DialogueSystem/DialogueSystem.cs delete mode 100644 Tools/DialogueSystem/DialogueSystem.cs.meta delete mode 100644 Tools/DialogueSystem/TMP_Animated.cs delete mode 100644 Tools/DialogueSystem/TMP_Animated.cs.meta diff --git a/Tools/DialogueSystem/DialogueSystem.cs b/Tools/DialogueSystem/DialogueSystem.cs deleted file mode 100644 index 5e35cc3..0000000 --- a/Tools/DialogueSystem/DialogueSystem.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Collections.Generic; -using TMPro; -using UnityEngine; -using UnityEngine.UI; - -public class DialogueSystem : MonoBehaviour{ - - public static DialogueSystem instance; - - public GameObject nameField = default; - public TextMeshProUGUI nameText = default; - public TMP_Animated dialogue = default; - public Image faceImage = default; - - Queue sentences; - bool talking; - Animator anim; - - void Awake(){ - instance = this; - sentences = new Queue(); - anim = GetComponent(); - } - - /// Start or continue the dialogue - /// This function returns false if the dialogue has ended. - /// - public bool Dialogue(Dialogue dialogue){ - if(!talking){ - if (dialogue.displayName){ - nameText.text = dialogue.characterName; - nameField.SetActive(true); - nameText.gameObject.SetActive(true); - }else{ - nameField.SetActive(false); - nameText.gameObject.SetActive(false); - } - - if (dialogue.characterImage) - faceImage.sprite = dialogue.characterImage; - else - faceImage.sprite = null; - - sentences.Clear(); - if(dialogue.sentences.Length != 0){ - foreach (string sentence in dialogue.sentences){ - sentences.Enqueue(sentence); - } - }else{ - sentences.Enqueue("I am error. No text has been added"); - } - talking = true; - - if(sentences.Count == 0){ - talking = false; - return false; - } - - string sentenceToShow = sentences.Dequeue(); - this.dialogue.ReadText(sentenceToShow); - anim.SetBool("Talking", true); - return true; - }else{ - if (sentences.Count == 0){ - talking = false; - anim.SetBool("Talking", false); - return false; - } - - string sentenceToShow = sentences.Dequeue(); - this.dialogue.ReadText(sentenceToShow); - return true; - } - } -} diff --git a/Tools/DialogueSystem/DialogueSystem.cs.meta b/Tools/DialogueSystem/DialogueSystem.cs.meta deleted file mode 100644 index 8211dcb..0000000 --- a/Tools/DialogueSystem/DialogueSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: caad12703fd5c3349acc637253734ac9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Tools/DialogueSystem/TMP_Animated.cs b/Tools/DialogueSystem/TMP_Animated.cs deleted file mode 100644 index 904041b..0000000 --- a/Tools/DialogueSystem/TMP_Animated.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Collections; -using UnityEngine; -using UnityEngine.Events; - -namespace TMPro{ - [System.Serializable] public class TextRevealEvent : UnityEvent { } - [System.Serializable] public class DialogueEvent : UnityEvent { } - - public class TMP_Animated : TextMeshProUGUI{ - - float speed = 20; - - public TextRevealEvent onTextReveal; - public DialogueEvent onDialogueFinish; - - void Update(){ - /*if(Application.isPlaying) - this.Animate();*/ - } - - public void ReadText(string newText){ - text = string.Empty; - - string[] subTexts = newText.Split('<', '>'); - - string displayText = ""; - for (int i = 0; i < subTexts.Length; i++){ - if (i % 2 == 0) - displayText += subTexts[i]; - else if (!isCustomTag(subTexts[i].Replace(" ", ""))) - displayText += $"<{subTexts[i]}>"; - } - - bool isCustomTag(string tag){ - return tag.StartsWith("speed=") || tag.StartsWith("pause=") || tag.StartsWith("wave") || tag.StartsWith("rainbow") || tag.StartsWith("shake"); - } - - text = displayText; - maxVisibleCharacters = 0; - StartCoroutine(Read()); - - IEnumerator Read(){ - int subCounter = 0; - int visibleCounter = 0; - while(subCounter < subTexts.Length){ - if(subCounter % 2 == 1){ - yield return EvaluateTag(subTexts[subCounter].Replace(" ", "")); - }else{ - while(visibleCounter < subTexts[subCounter].Length){ - onTextReveal.Invoke(subTexts[subCounter][visibleCounter]); - visibleCounter++; - maxVisibleCharacters++; - //this.Animate(); - - yield return new WaitForSeconds(text[maxVisibleCharacters - 1] == ' ' ? 0 : (1f / speed)); - } - visibleCounter = 0; - } - subCounter++; - } - yield return null; - - WaitForSeconds EvaluateTag(string tag){ - if (tag.Length > 0){ - if (tag.StartsWith("speed=")){ - speed = float.Parse(tag.Split('=')[1]); - }else if (tag.StartsWith("pause=")){ - return new WaitForSeconds(float.Parse(tag.Split('=')[1])); - } - } - return null; - } - - onDialogueFinish.Invoke(); - } - } - } -} diff --git a/Tools/DialogueSystem/TMP_Animated.cs.meta b/Tools/DialogueSystem/TMP_Animated.cs.meta deleted file mode 100644 index 8231160..0000000 --- a/Tools/DialogueSystem/TMP_Animated.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f713d84a3ae882945800780459e26170 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 2fd6421f253b4ef1a19526541f9ffc0c, type: 3} - userData: - assetBundleName: - assetBundleVariant: