89 lines
2.5 KiB
C#
89 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using AibisDream.Framework;
|
|
using AibisDream.Kit;
|
|
using AibisDream.Utility;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class TaskScreen : MonoBehaviour, IDialogView
|
|
{
|
|
#region 索引
|
|
|
|
private Transform _taskListParent;
|
|
private GameObject _taskItemPrefab;
|
|
private readonly Dictionary<string, LocalizedText> _taskDict = new();
|
|
|
|
#endregion
|
|
|
|
private void Awake()
|
|
{
|
|
_taskListParent = transform.Find("Record");
|
|
_taskItemPrefab = ResourceKit.LoadAssetSync<GameObject>(ConstRef.TaskItemName);
|
|
}
|
|
|
|
#region 对话框功能实现
|
|
|
|
public void ShowLine(string dialogLine, CharacterVo character, Action nextStep, string lineId, bool isAutoSkip = false)
|
|
{
|
|
var taskItem = Instantiate(_taskItemPrefab, _taskListParent);
|
|
// 设置本地化数据
|
|
var localize = taskItem.GetComponent<LocalizedText>();
|
|
localize.SetLocalizedText(DialogController.Instance.GetCurLocalizedTableName(), lineId);
|
|
_taskDict[lineId] = localize;
|
|
|
|
EnumEventSystem.Global.Send(DialogEventEnum.LineShown);
|
|
EnumEventSystem.Global.Send(DialogEventEnum.LineEnd);
|
|
nextStep.Invoke();
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(_taskListParent.GetComponent<RectTransform>());
|
|
}
|
|
|
|
public void ShowOptions(DialogOption[] dialogueOptions)
|
|
{
|
|
Debug.Log("Task 面板不能显示选项");
|
|
}
|
|
|
|
public void HideDialog()
|
|
{
|
|
// 无法隐藏
|
|
}
|
|
|
|
public bool TrySkipLine(bool isForceSkip = false)
|
|
{
|
|
// 直接继续不跳过
|
|
return true;
|
|
}
|
|
|
|
public void NextStep()
|
|
{
|
|
// 这里不能手动跳到下一行
|
|
}
|
|
|
|
public void OnLocalizationChanged(string value)
|
|
{
|
|
// TODO 有需要可以调整文本
|
|
}
|
|
|
|
#endregion
|
|
|
|
public void CompleteTask(string lineId)
|
|
{
|
|
if (_taskDict.Remove(lineId, out var taskItem))
|
|
{
|
|
Destroy(taskItem.gameObject);
|
|
}
|
|
}
|
|
|
|
public void ClearTasks()
|
|
{
|
|
foreach (var task in _taskDict)
|
|
{
|
|
Destroy(task.Value.gameObject);
|
|
}
|
|
_taskDict.Clear();
|
|
}
|
|
}
|
|
}
|