(client) feat:健康给予,路径优化,结算界面,商店界面 (#60)

Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com>
Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/60
This commit is contained in:
2025-10-10 14:08:23 +08:00
parent 9a797479ff
commit 16b49f3d3a
1900 changed files with 114053 additions and 34157 deletions

View File

@@ -1,50 +1,48 @@
using Base;
using TMPro;
using UnityEngine;
namespace Prefab
{
/// <summary>
/// 临时动画文本组件,用于在指定时间内逐帧显示一系列文本动画。
/// 该组件假设 TemporaryAnimator 实现了 ITickable 接口,因此可以在游戏循环中接收更新。
/// 临时动画文本组件,用于在指定时间内逐帧显示一系列文本动画。
/// 该组件假设 TemporaryAnimator 实现了 ITickable 接口,因此可以在游戏循环中接收更新。
/// </summary>
public class TemporaryAnimatorText : TemporaryAnimator
{
/// <summary>
/// 用于显示动画文本的 TMP_Text 组件。
/// 允许在编辑器中赋值,以增加灵活性和鲁棒性。
/// 用于显示动画文本的 TMP_Text 组件。
/// 允许在编辑器中赋值,以增加灵活性和鲁棒性。
/// </summary>
[SerializeField] public TMP_Text text;
public RectTransform rectTransform;
/// <summary>
/// 当前播放的动画帧索引
/// </summary>
private int currentFrameIndex = 0;
/// <summary>
/// 存储所有动画帧文本的字符串数组。每个元素代表一帧动画内容。
/// 存储所有动画帧文本的字符串数组。每个元素代表一帧动画内容
/// </summary>
private string[] animationsKey;
/// <summary>
/// 每帧动画的持续时间。根据帧率FPS计算得出
/// 当前播放的动画帧索引
/// </summary>
private int currentFrameIndex;
/// <summary>
/// 每帧动画的持续时间。根据帧率FPS计算得出。
/// </summary>
private float frameDuration;
/// <summary>
/// 用于跟踪当前帧已持续时间的计时器。
/// 用于跟踪当前帧已持续时间的计时器。
/// </summary>
private float timer;
/// <summary>
/// 初始化动画文本组件。
/// 初始化动画文本组件。
/// </summary>
/// <param name="s">包含所有动画帧文本的字符串,多个帧之间用逗号分隔。</param>
/// <param name="fps">动画播放的帧率Frames Per Second。</param>
public void Init(string s, float fps=3)
public void Init(string s, float fps = 3)
{
// 如果文本组件未赋值,尝试在子对象中查找。
// 如果仍未找到,则记录错误并提前退出。
@@ -54,7 +52,7 @@ namespace Prefab
if (!text)
{
Debug.LogError("TemporaryAnimatorText: 未在子对象中找到或未指定 TMP_Text 组件。动画无法进行。", this);
return; // 提前退出 Init 方法,避免后续操作使用未初始化的 text
}
}
@@ -64,7 +62,7 @@ namespace Prefab
if (string.IsNullOrEmpty(s))
{
Debug.LogWarning("TemporaryAnimatorText: 输入的动画字符串为空或为 null。动画将显示空字符串或停止。", this);
animationsKey = new string[] { "" }; // 确保 animationsKey 不为 null 且至少包含一个空字符串元素
animationsKey = new[] { "" }; // 确保 animationsKey 不为 null 且至少包含一个空字符串元素
}
else
{
@@ -73,7 +71,7 @@ namespace Prefab
if (animationsKey.Length == 0)
{
Debug.LogWarning("TemporaryAnimatorText: 输入的动画字符串导致动画帧数组为空。动画将显示空字符串或停止。", this);
animationsKey = new string[] { "" };
animationsKey = new[] { "" };
}
}
@@ -82,11 +80,11 @@ namespace Prefab
if (fps <= 0)
{
Debug.LogError("TemporaryAnimatorText: FPS 必须是大于 0 的正值。将动画帧持续时间设置为 1 秒。", this);
this.frameDuration = 1f; // 默认每帧1秒实际效果是动画暂停或非常慢
frameDuration = 1f; // 默认每帧1秒实际效果是动画暂停或非常慢
}
else
{
this.frameDuration = 1f / fps;
frameDuration = 1f / fps;
}
// 重新初始化动画时,将当前帧索引重置为第一帧。
@@ -94,21 +92,16 @@ namespace Prefab
// 在 animationsKey 准备好后,设置初始文本为第一帧的内容。
if (text && animationsKey.Length > 0)
{
text.text = animationsKey[currentFrameIndex];
}
// 如果动画帧数组为空,但文本组件存在,则清空文本显示。
else if (text)
{
text.text = "";
}
else if (text) text.text = "";
// 重置计时器,从零开始计算新帧的持续时间。
timer = 0f;
}
/// <summary>
/// 每帧更新动画显示。该方法将在游戏循环中被 Clock 调用。
/// 每帧更新动画显示。该方法将在游戏循环中被 Clock 调用。
/// </summary>
public override void Tick()
{
@@ -122,10 +115,8 @@ namespace Prefab
// 检查动画帧数组是否已初始化或为空。
// 如果没有动画帧,则无需更新,直接返回。
if (animationsKey == null || animationsKey.Length == 0)
{
// Debug.LogWarning("TemporaryAnimatorText: 动画键未初始化或为空。跳过 Tick 更新。", this); // 这条日志已被注释掉,避免频繁输出不必要的警告
return; // 没有动画帧,直接返回
}
// 增加计时器。
timer += Time.deltaTime;
@@ -140,14 +131,10 @@ namespace Prefab
currentFrameIndex += 1;
// 如果当前帧索引超出动画帧数组的范围,则循环回到第一帧。
if (currentFrameIndex >= animationsKey.Length)
{
currentFrameIndex = 0;
}
if (currentFrameIndex >= animationsKey.Length) currentFrameIndex = 0;
// 更新文本组件显示为当前帧的文本内容。
text.text = animationsKey[currentFrameIndex];
}
}
}