mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 05:37:11 +08:00
(client) feat:支持定义实体的碰撞体大小和偏移;建筑支持定义实体建筑和瓦片建筑,建筑支持指定按钮回调;添加存档管理器;Dev支持设置是否暂停;实体允许定义事件组;添加基地界面 (#57)
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/57
This commit is contained in:
@@ -261,6 +261,7 @@ namespace Base
|
||||
_frameTimer = 0f;
|
||||
_isOneShot = false; // 设置新精灵时,取消一次性播放模式
|
||||
_isPaused = false; // 默认开始播放
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Prefab
|
||||
{
|
||||
public class TemporaryAnimator : MonoBehaviour, ITick
|
||||
{
|
||||
[Tooltip("动画持续时间")]
|
||||
[Tooltip("动画持续时间。当小于或等于0时,动画将无限持续,物体不会自动销毁。")]
|
||||
public float lifeTime = 3;
|
||||
|
||||
private float _timer; // 每次启用时会重置为0
|
||||
@@ -41,25 +41,28 @@ namespace Prefab
|
||||
{
|
||||
_timer += Time.deltaTime;
|
||||
|
||||
// 钳制当前动画时间,确保最后一帧使用精确的lifeTime值
|
||||
// 避免动画函数接收到超出预期范围的时间参数
|
||||
var currentAnimationTime = Mathf.Min(_timer, lifeTime);
|
||||
var shouldDestroy = _timer >= lifeTime; // 判断是否达到销毁条件
|
||||
// 如果lifeTime > 0,则钳制动画时间;否则(无限持续),直接使用_timer
|
||||
var currentAnimationTime = lifeTime > 0 ? Mathf.Min(_timer, lifeTime) : _timer;
|
||||
|
||||
// 调用委托获取X和Y轴的偏移量,如果委托未设置则使用当前位置的对应轴值
|
||||
// 有委托时:原始位置 + 偏移量;无委托时:当前位置的对应轴值
|
||||
var xPos = GetXPosition != null ? _originalPosition.x + GetXPosition.Invoke(currentAnimationTime) : transform.localPosition.x;
|
||||
var yPos = GetYPosition != null ? _originalPosition.y + GetYPosition.Invoke(currentAnimationTime) : transform.localPosition.y;
|
||||
// 调用委托获取X和Y轴的偏移量,如果委托未设置则使用当前位置的对应轴值
|
||||
// 有委托时:原始位置 + 偏移量;无委托时:当前位置的对应轴值
|
||||
var xPos = GetXPosition != null
|
||||
? _originalPosition.x + GetXPosition.Invoke(currentAnimationTime)
|
||||
: transform.localPosition.x;
|
||||
var yPos = GetYPosition != null
|
||||
? _originalPosition.y + GetYPosition.Invoke(currentAnimationTime)
|
||||
: transform.localPosition.y;
|
||||
|
||||
// 应用计算后的值到物体位置,保持原始Z轴不变
|
||||
transform.localPosition = new Vector3(xPos, yPos, _originalPosition.z);
|
||||
|
||||
// 如果达到销毁条件,在完成最后一帧动画更新后销毁物体
|
||||
if (shouldDestroy)
|
||||
// 只有当lifeTime > 0时才判断是否需要销毁
|
||||
if (lifeTime > 0 && _timer >= lifeTime)
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置动画的X和Y轴位移函数。
|
||||
/// 此方法通常在实例化TemporaryAnimator后立即调用以配置其动画行为。
|
||||
@@ -72,4 +75,4 @@ namespace Prefab
|
||||
GetYPosition = getYPosFunc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user