66 lines
1.6 KiB
C#
66 lines
1.6 KiB
C#
using System;
|
|
using AibisDream.Framework;
|
|
using AibisDream.Kit;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class CenterOption : MonoBehaviour, IDialogView
|
|
{
|
|
#region 索引
|
|
|
|
public GameObject choiceButtonPrefab;
|
|
|
|
#endregion
|
|
|
|
private void Awake()
|
|
{
|
|
EnumEventSystem.Global.Register<DialogEventEnum, DialogText>(DialogEventEnum.OptionSelected,
|
|
_ => HideDialog());
|
|
}
|
|
|
|
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, bool isAutoSkip = false)
|
|
{
|
|
Debug.Log("CenterOption只显示选项");
|
|
}
|
|
|
|
public void ShowOptions(DialogOption[] dialogueOptions)
|
|
{
|
|
gameObject.SetActive(true);
|
|
|
|
// 销毁原来的按钮
|
|
foreach (Transform child in transform)
|
|
{
|
|
Destroy(child.gameObject);
|
|
}
|
|
|
|
// 生成新按钮
|
|
foreach (var option in dialogueOptions)
|
|
{
|
|
if (!option.IsAvailable) continue;
|
|
|
|
var choiceInstance = Instantiate(choiceButtonPrefab, transform);
|
|
choiceInstance.GetComponentInChildren<TMP_Text>().text = option.Line;
|
|
choiceInstance.GetComponent<Button>().onClick.AddListener(option.Select);
|
|
}
|
|
}
|
|
|
|
public void HideDialog()
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
public bool TrySkipLine()
|
|
{
|
|
// 无法跳过
|
|
return true;
|
|
}
|
|
|
|
public void NextStep()
|
|
{
|
|
// 无法继续
|
|
}
|
|
}
|
|
} |