MAJOR: Re-organize entire project

This commit is contained in:
2022-08-15 11:56:39 -07:00
parent 1e4c73ea1e
commit 49b14df1af
322 changed files with 3010 additions and 33674 deletions

View File

@@ -0,0 +1,70 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
namespace Scampz.GameJam
{
public class DialogueManager : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI nameText;
[SerializeField]
private TextMeshProUGUI dialogueText;
public float TextSpeed = 0.1f;
public static DialogueManager Instance { get; private set; }
public Queue<string> sentences;
private void Awake()
{
if (Instance == null)
Instance = this;
}
public void Start()
{
sentences = new Queue<string>();
}
public void StartDialogue(Dialogue dialogue)
{
nameText.text = dialogue.name;
sentences.Clear();
foreach (var sentence in dialogue.sentences)
sentences.Enqueue(sentence);
DisplayNextSentence();
}
public void DisplayNextSentence()
{
if (!sentences.Any())
EndDialogue();
var sentence = sentences.Dequeue();
StopAllCoroutines();
StartCoroutine(TypeSentence(sentence));
}
private IEnumerator TypeSentence(string sentence)
{
dialogueText.text = string.Empty;
foreach (var letter in sentence.ToCharArray())
{
dialogueText.text += letter;
yield return null;
yield return new WaitForSecondsRealtime(TextSpeed);
}
}
private void EndDialogue()
{
// do nothing currently
}
}
}