51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
|
|
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();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|