NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Effect/Logic/BulletFlyLogic.cs

44 lines
1.1 KiB
C#
Raw Normal View History

2023-10-19 15:00:19 +08:00
namespace Gameplay.Effect
2023-08-22 19:08:45 +08:00
{
using UnityEngine;
public class BulletFlyLogic: BaseEffectLogic
{
private Vector3 _startPos;
private Vector3 _endPos;
private float _flyTime;
2023-10-19 15:00:19 +08:00
public void Ctor(Vector3 startPos,
Vector3 endPos,
float flyTime)
2023-08-22 19:08:45 +08:00
{
_startPos = startPos;
_endPos = endPos;
_flyTime = flyTime;
}
protected override void _OnLogicUpdate(float dt)
{
base._OnLogicUpdate(dt);
2024-01-26 12:53:17 +08:00
if (passTime >= _flyTime)
{
effect.Destroy();
return;
}
2023-10-19 15:00:19 +08:00
if (effect == null || effect.transform == null) return;
2023-08-22 19:08:45 +08:00
var progress = Mathf.Clamp01(passTime / _flyTime);
var pos = Vector3.Lerp(_startPos, _endPos, progress);
effect.transform.position = pos;
// DebugUtil.Log("BulletFlyLogic _OnLogicUpdate pos:" + pos + "passTime:" + passTime + "_flyTime:" + _flyTime
// + "startPos:" + _startPos + "endPos:" + _endPos);
2024-01-26 12:53:17 +08:00
2023-08-22 19:08:45 +08:00
}
}
}