feat(Dialogue): 实现基本的对话系统

This commit is contained in:
2025-10-23 15:46:17 +08:00
parent 4ef8430c6b
commit f6f523e609
29 changed files with 1398 additions and 86 deletions

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using Core;
using Script.Gameplay.Input;
using Script.Gameplay.Player;
using TMPro;
using UnityEngine;
namespace UI
{
// 负责显示玩家对话内容的UI组件
public class PlayerDialogueViewer : UIBase
{
[SerializeField] private TMP_Text dialogueText;
[SerializeField] private GameObject panel;
private bool isShowingPanel = false;
private PlayerDialogueController playerDialogueController;
private InputManager inputManager;
protected override void Awake()
{
base.Awake();
inputManager = InputManager.Instance;
ControllerLocator.Instance.TryGetWait<PlayerDialogueController>(OnGetPlayerDialogueController);
}
private void OnGetPlayerDialogueController(PlayerDialogueController controller)
{
playerDialogueController = controller;
playerDialogueController.RegisterDialogueViewer(this);
}
public void ReceiveDialogue(string content)
{
if(!isShowingPanel) OpenPanel();
dialogueText.text = content;
}
private void OpenPanel()
{
isShowingPanel = true;
Show();
}
public void ClosePanel()
{
isShowingPanel = false;
Hide();
}
}
}