101 lines
2.8 KiB
C#
101 lines
2.8 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections.Generic;
|
|
using System.Collections;
|
|
using DG.Tweening;
|
|
using TMPro;
|
|
using AibisDream;
|
|
using Yarn.Unity;
|
|
using System;
|
|
|
|
public class ClueBoardManager : MonoBehaviour
|
|
{
|
|
// 单例实例
|
|
public static ClueBoardManager Instance { get; private set; }
|
|
|
|
public Canvas clueBoardUI; // ClueBoard UI的GameObject
|
|
public GameObject iamgePointer; // ClueBoard UI的GameObject
|
|
[SerializeField] private Button toggleButton; // 开启/关闭ClueBoard的按钮
|
|
private RectTransform clueBoardRectTransform; // ClueBoard的RectTransform
|
|
private List<ClueSlotBase> clueSlots = new List<ClueSlotBase>(); // 当前存在的所有ClueSlot
|
|
private int currentStep = 0; // 当前步骤编号
|
|
|
|
private int maxStep = 3; // 当前步骤编号
|
|
private bool isBoardOpen = false;
|
|
private Vector2 hiddenPosition; // ClueBoard隐藏时的位置
|
|
private Vector2 visiblePosition; // ClueBoard显示时的位置
|
|
|
|
public event Action OnClueBoardOpen;
|
|
public event Action OnClueBoardClose;
|
|
|
|
[YarnCommand("wait_for_ClueBoard_close")]
|
|
public IEnumerator WaitForClose()
|
|
{
|
|
// 这里等待关闭按钮点击事件
|
|
while (isBoardOpen)
|
|
{
|
|
yield return null; // 每帧检查一次
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (Instance != null && Instance != this)
|
|
{
|
|
Destroy(gameObject); // 确保单例唯一性
|
|
return;
|
|
}
|
|
Instance = this;
|
|
//DontDestroyOnLoad(gameObject); // 如果需要跨场景保留
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
clueBoardRectTransform = clueBoardUI.transform.GetComponent<RectTransform>();
|
|
clueBoardUI.enabled = false;
|
|
iamgePointer.GetComponent<Image>().enabled = false;
|
|
|
|
toggleButton.onClick.AddListener(ToggleClueBoard); // 绑定按钮事件
|
|
}
|
|
|
|
// 开启或关闭 ClueBoard
|
|
private void ToggleClueBoard()
|
|
{
|
|
Debug.Log("触发打开关闭诊疗面板");
|
|
if (isBoardOpen)
|
|
{
|
|
CloseClueBoard();
|
|
}
|
|
else
|
|
{
|
|
OpenClueBoard();
|
|
}
|
|
}
|
|
|
|
[YarnCommand("OpenClueBoard")]
|
|
public void OpenClueBoard()
|
|
{
|
|
clueBoardUI.enabled = true;
|
|
iamgePointer.GetComponent<Image>().enabled = true;
|
|
isBoardOpen = true;
|
|
OnClueBoardOpen?.Invoke();
|
|
// MouseCursorManager.Instance.ClueBoardIn();
|
|
}
|
|
|
|
[YarnCommand("CloseClueBoard")]
|
|
public void CloseClueBoard()
|
|
{
|
|
isBoardOpen = false;
|
|
clueBoardUI.enabled = false;
|
|
iamgePointer.GetComponent<Image>().enabled = false;
|
|
OnClueBoardClose?.Invoke();
|
|
// MouseCursorManager.Instance.ClueBoardOut();
|
|
}
|
|
|
|
[YarnCommand("SkipClueBoard")]
|
|
public void SkipClueBoard()
|
|
{
|
|
DialogController.Instance.StartDialogNode("SkipClueBoard");
|
|
}
|
|
}
|