using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
public class StraightBulletCurve : BulletCurve
|
{
|
private Vector2 start;
|
private Vector2 end;
|
|
public StraightBulletCurve(BattleObject caster, SkillConfig skillConfig, EffectPlayer bulletEffect, RectTransform target, Action<int, List<HB427_tagSCUseSkill.tagSCUseSkillHurt>> onHit)
|
: base(caster, skillConfig, bulletEffect, target, onHit) { }
|
|
public override void Reset()
|
{
|
base.Reset();
|
start = WorldToLocalAnchoredPosition(bulletTrans.position);
|
end = WorldToLocalAnchoredPosition(target.position);
|
}
|
|
public override void Run()
|
{
|
if (finished) return;
|
elapsed += Time.deltaTime;
|
float t = Mathf.Clamp01(elapsed / duration);
|
Vector2 pos = Vector2.Lerp(start, end, t);
|
bulletTrans.anchoredPosition = pos;
|
|
Vector2 dir = end - start;
|
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - 90f;
|
bulletTrans.localRotation = Quaternion.Euler(0, 0, angle);
|
|
if (t >= 1f)
|
{
|
finished = true;
|
onHit?.Invoke(0, null);
|
}
|
}
|
}
|