80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using Febucci.UI.Core;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class BlockPuzzleScreen : MonoBehaviour
|
|
{
|
|
[Header("详情界面")]
|
|
[SerializeField] private GameObject detailRoot;
|
|
[SerializeField] private TMP_Text titleText;
|
|
[SerializeField] private TMP_Text propInfo;
|
|
[SerializeField] private TMP_Text detailContent;
|
|
|
|
[Header("Log界面")]
|
|
[SerializeField] private TypewriterCore logText;
|
|
|
|
// --------------------------------- 详情展示 ---------------------------------
|
|
|
|
public void ShowDetail(BlockShapeData data)
|
|
{
|
|
ShowDetail();
|
|
|
|
titleText.text = data.shapeName;
|
|
propInfo.text = ShapePropertyToString(data.shapeProperties);
|
|
detailContent.text = data.shapeDescription;
|
|
}
|
|
|
|
private string ShapePropertyToString(ShapeProperty[] properties)
|
|
{
|
|
string result = "|";
|
|
foreach (var property in properties)
|
|
{
|
|
var sign = property.value > 0 ? "+" : "-";
|
|
result += $" {property.property}: {sign}{property.value} |";
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public void AddLog(string log)
|
|
{
|
|
ShowLog();
|
|
|
|
var oldText = logText.TextAnimator.textFull;
|
|
if (!string.IsNullOrEmpty(oldText))
|
|
{
|
|
oldText = oldText.Replace("<notype>", "").Replace("</notype>", "");
|
|
}
|
|
|
|
var newLog = $"{oldText}\n{log}";
|
|
logText.ShowText(newLog);
|
|
}
|
|
|
|
public void ClearLog()
|
|
{
|
|
logText.TextAnimator.SetText("");
|
|
}
|
|
|
|
// --------------------------------- 显示控制 ---------------------------------
|
|
public void ShowLog()
|
|
{
|
|
logText.gameObject.SetActive(true);
|
|
detailRoot.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void ShowDetail()
|
|
{
|
|
logText.gameObject.SetActive(false);
|
|
detailRoot.gameObject.SetActive(true);
|
|
}
|
|
|
|
public void HideAll()
|
|
{
|
|
logText.gameObject.SetActive(false);
|
|
detailRoot.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|