mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 06:57:12 +08:00
(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:
@@ -9,17 +9,15 @@ namespace Prefab
|
||||
[Tooltip("动画持续时间。当小于或等于0时,动画将无限持续,物体不会自动销毁。")]
|
||||
public float lifeTime = 3;
|
||||
|
||||
private float _timer; // 每次启用时会重置为0
|
||||
|
||||
// 使用属性限制外部只能获取和一次性设置动画函数
|
||||
[Tooltip("定义X轴偏移的函数 (时间 -> X偏移量)")]
|
||||
public Func<float, float> GetXPosition { get; private set; }
|
||||
|
||||
[Tooltip("定义Y轴偏移的函数 (时间 -> Y偏移量)")]
|
||||
public Func<float, float> GetYPosition { get; private set; }
|
||||
|
||||
private Vector3 _originalPosition;
|
||||
|
||||
private float _timer; // 每次启用时会重置为0
|
||||
|
||||
// 使用属性限制外部只能获取和一次性设置动画函数
|
||||
[Tooltip("定义X轴偏移的函数 (时间 -> X偏移量)")] public Func<float, float> GetXPosition { get; private set; }
|
||||
|
||||
[Tooltip("定义Y轴偏移的函数 (时间 -> Y偏移量)")] public Func<float, float> GetYPosition { get; private set; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_originalPosition = transform.localPosition; // 初始位置只需在组件生命周期中获取一次
|
||||
@@ -57,15 +55,12 @@ namespace Prefab
|
||||
transform.localPosition = new Vector3(xPos, yPos, _originalPosition.z);
|
||||
|
||||
// 只有当lifeTime > 0时才判断是否需要销毁
|
||||
if (lifeTime > 0 && _timer >= lifeTime)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
if (lifeTime > 0 && _timer >= lifeTime) Destroy(gameObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置动画的X和Y轴位移函数。
|
||||
/// 此方法通常在实例化TemporaryAnimator后立即调用以配置其动画行为。
|
||||
/// 设置动画的X和Y轴位移函数。
|
||||
/// 此方法通常在实例化TemporaryAnimator后立即调用以配置其动画行为。
|
||||
/// </summary>
|
||||
/// <param name="getXPosFunc">时间到X轴位移的函数。</param>
|
||||
/// <param name="getYPosFunc">时间到Y轴位移的函数。</param>
|
||||
@@ -75,4 +70,4 @@ namespace Prefab
|
||||
GetYPosition = getYPosFunc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user