分化屏幕dialog与对话框dialog

This commit is contained in:
2024-09-18 11:59:51 +08:00
parent 7257c39577
commit 5e7e7bbb0e
7 changed files with 33 additions and 10 deletions

View File

@@ -0,0 +1,7 @@
namespace Dialog
{
public class BoxDialog
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 78f180e85e3a4ef095495b2760268559
timeCreated: 1726626993

View File

@@ -13,8 +13,9 @@ namespace Data
public readonly string Animation; public readonly string Animation;
public readonly string Character; public readonly string Character;
public readonly string DialogEvent; public readonly string DialogEvent;
public readonly string DialogEventArg;
public Dialog(int index, string content, string type, string animation, string character, string dialogEvent) public Dialog(int index, string content, string type, string animation, string character, string dialogEvent, string dialogEventArg)
{ {
Index = index; Index = index;
Content = content; Content = content;
@@ -22,6 +23,7 @@ namespace Data
Animation = animation; Animation = animation;
Character = character; Character = character;
DialogEvent = dialogEvent; DialogEvent = dialogEvent;
DialogEventArg = dialogEventArg;
} }
} }
@@ -58,7 +60,6 @@ namespace Data
private void LoadCsv(string path) private void LoadCsv(string path)
{ {
var lines = File.ReadAllLines(path); var lines = File.ReadAllLines(path);
print(lines);
for (var i = 1; i < lines.Length; i++) for (var i = 1; i < lines.Length; i++)
{ {
var values = lines[i].Split(','); var values = lines[i].Split(',');
@@ -69,7 +70,8 @@ namespace Data
values[2], values[2],
values[3], values[3],
values[4], values[4],
values[5] values[5],
values[6]
); );
_dialog.Add(dialog); _dialog.Add(dialog);

View File

@@ -1,5 +1,5 @@
using System.Collections; using System.Collections;
using Data; using Dialog;
using Event; using Event;
using Event.EventArgs; using Event.EventArgs;
using TMPro; using TMPro;
@@ -20,7 +20,8 @@ namespace UI
public float printTime; public float printTime;
public float maxPrintTime=10; public float maxPrintTime=10;
public bool isTime2Break; public bool isTime2Break;
private string _eventToBeExc;
private string _eventArg;
private void Update() private void Update()
{ {
@@ -29,8 +30,12 @@ namespace UI
if (printTime > maxPrintTime) if (printTime > maxPrintTime)
{ {
isTime2Break = true; isTime2Break = true;
StartCoroutine(Delay());
}
if (_currentText == introduceText)
{
return;
} }
if (_currentText == introduceText) return;
_timer += Time.deltaTime; _timer += Time.deltaTime;
if (!(_timer >= typingSpeed)) return; if (!(_timer >= typingSpeed)) return;
_timer = 0f; _timer = 0f;
@@ -38,7 +43,13 @@ namespace UI
textMeshPro.text = _currentText; textMeshPro.text = _currentText;
_currentIndex++; _currentIndex++;
} }
// 沟槽的生命周期
private IEnumerator Delay()
{
yield return new WaitForSeconds(1f);
EventManager.Instance.DialogEventSwitch(_eventToBeExc,_eventArg);
}
private void Start() private void Start()
{ {
EventManager.Instance.DialogPop += StartPrinting; EventManager.Instance.DialogPop += StartPrinting;
@@ -73,13 +84,13 @@ namespace UI
private void StartPrinting(DialogPopArgs e) private void StartPrinting(DialogPopArgs e)
{ {
if(!e.IsScreenDialog) return; if(!DialogManager.Instance.GetDialogByIndex(e.Index).Type.Equals("screen")) return;
if(printTime != 0) return; if(printTime != 0) return;
_start = true; _start = true;
_currentText = ""; _currentText = "";
introduceText = DialogManager.Instance.GetDialogByIndex(e.Index).Content; introduceText = DialogManager.Instance.GetDialogByIndex(e.Index).Content;
_eventToBeExc = DialogManager.Instance.GetDialogByIndex(e.Index).DialogEvent;
_eventArg = DialogManager.Instance.GetDialogByIndex(e.Index).DialogEventArg;
_currentIndex = 0; _currentIndex = 0;
_timer = 0f; _timer = 0f;
textMeshPro.fontSize = 80; textMeshPro.fontSize = 80;