Removed old scripts

This commit is contained in:
Gerard Gascón 2022-09-15 17:32:04 +02:00 committed by GitHub
parent 0e8b8b1835
commit 9f9dedba98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 175 deletions

View file

@ -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<string> sentences;
bool talking;
Animator anim;
void Awake(){
instance = this;
sentences = new Queue<string>();
anim = GetComponent<Animator>();
}
/// <summary>Start or continue the dialogue
/// <para>This function returns false if the dialogue has ended.</para>
/// </summary>
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;
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: caad12703fd5c3349acc637253734ac9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,78 +0,0 @@
using System.Collections;
using UnityEngine;
using UnityEngine.Events;
namespace TMPro{
[System.Serializable] public class TextRevealEvent : UnityEvent<char> { }
[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();
}
}
}
}

View file

@ -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: