You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.4 KiB

using System.Numerics;
using UnityEngine;
namespace Skill_V2
{
[CreateAssetMenu(fileName = "SpawnBullet", menuName = "ScriptableObject/Skill/SkillSequence/SpawnBullet")]
public class SpawnBullet : SkillSequence
{
[SerializeField] StraightBullet bulletPrefab;
StraightBullet bulletInstance;
BigInteger skillDmg;
public override void Enter()
{
bulletInstance = Instantiate(bulletPrefab, Owner.CenterPivot, UnityEngine.Quaternion.identity);
bulletInstance.OnEnterCollider += HandleCollide;
if (TargetFinder.TryFindNearest(Owner.CenterPivot, Owner.TargetTags, out var target))
{
bulletInstance.Fire((target as Entity).CenterPivotTransform);
}
else
{
bulletInstance.HeadDirection = Owner.LookDirection;
bulletInstance.Fire();
}
skillDmg = Owner.GetSkillDamage();
IsDone = true;
}
public override void Stop()
{
if (bulletInstance != null)
{
Destroy(bulletInstance.gameObject);
}
bulletInstance = null;
}
private void HandleCollide(Entity other)
{
if (other.HasTagsAny(Owner.TargetTags) && other is IBattleEntity target)
{
BattleMgr.Instance.SendDamage(target, skillDmg, 0, 0);
}
}
}
}