61 lines
1.3 KiB
C#
61 lines
1.3 KiB
C#
using Gameplay.Pool;
|
|
|
|
namespace Gameplay.Weapon
|
|
{
|
|
using Effect;
|
|
using UnityEngine;
|
|
|
|
public class WeaponLine: IPoolData
|
|
{
|
|
|
|
public EffectPlayingData effect;
|
|
|
|
public bool needRemove;
|
|
|
|
public Vector3 endPos;
|
|
public float flySpeed;
|
|
|
|
public void StartFly(Vector3 end, float inFlySpeed)
|
|
{
|
|
endPos = end;
|
|
flySpeed = inFlySpeed;
|
|
}
|
|
|
|
public void ViewUpdate(float dt)
|
|
{
|
|
if (effect == null) return;
|
|
if (needRemove) return;
|
|
var moveDistance = flySpeed * dt;
|
|
var toEnd = endPos - effect.transform.position;
|
|
toEnd.y = 0;
|
|
var distance = toEnd.magnitude;
|
|
if (distance <= moveDistance)
|
|
{
|
|
effect.transform.position = endPos;
|
|
needRemove = true;
|
|
return;
|
|
}
|
|
var dir = toEnd.normalized;
|
|
effect.transform.position += dir * moveDistance;
|
|
}
|
|
|
|
public void DestroyEffect()
|
|
{
|
|
if (effect == null)
|
|
{
|
|
return;
|
|
}
|
|
effect.Destroy();
|
|
effect = null;
|
|
}
|
|
|
|
public void OnGet()
|
|
{
|
|
needRemove = false;
|
|
}
|
|
public void OnReturn()
|
|
{
|
|
}
|
|
}
|
|
}
|