63 lines
2.2 KiB
C#
63 lines
2.2 KiB
C#
using System;
|
|
using Cielonos.MainGame.Buffs.Character;
|
|
using Cielonos.MainGame.Characters;
|
|
using Cielonos.MainGame.UI;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Inventory.Collections
|
|
{
|
|
public partial class FusionInjector : SupportEquipmentBase
|
|
{
|
|
private Transform _muzzle;
|
|
|
|
public override void OnObtained()
|
|
{
|
|
base.OnObtained();
|
|
_muzzle = player.bodyPartsSc.AuxiliaryDrone.center;
|
|
}
|
|
|
|
public override void OnPress()
|
|
{
|
|
if (functionSm.mainFunction.IsAvailable())
|
|
{
|
|
CharacterBase target = CombatManager.EnemySm.GetBestEnemyWithLockonFirst(50f);
|
|
GenerateProjectile("Projectile", target, 100f, _muzzle);
|
|
functionSm.mainFunction.Execute();
|
|
PlayerCanvas.SupportEquipmentsUIArea[this].UseOutlineAnimation();
|
|
}
|
|
else
|
|
{
|
|
PlayerCanvas.SupportEquipmentsUIArea[this].CanNotUseOutlineAnimation();
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class FusionInjector
|
|
{
|
|
private void GenerateProjectile(string vfxName, CharacterBase target, float speed, Transform muzzle = null)
|
|
{
|
|
muzzle ??= this._muzzle;
|
|
vfxData.SpawnMuzzleVFX(vfxName, player, muzzle);
|
|
Projectile projectile = vfxData.SpawnVFX(vfxName, player, muzzle).GetComponentInChildren<Projectile>();
|
|
|
|
Vector3 direction = player.transform.forward;
|
|
if (target != null)
|
|
{
|
|
direction = (target.centerPoint.position - projectile.transform.position).normalized;
|
|
}
|
|
|
|
projectile.Initialize(player, this, false, 1, Fraction.Enemy)
|
|
.SetAttackSubmodule<Projectile>(attackData[vfxName])
|
|
.SetTimeSubmodule<Projectile>(10f)
|
|
.SetHitSubmodule<Projectile>()
|
|
.SetLinearDirectionMoveModule<Projectile>(direction, speed)
|
|
.SetRaycastSubmodule<Projectile>(default, 0.25f, 0.5f);
|
|
projectile.SetImpulseSubmodule().WithDynamicForce(5f);
|
|
|
|
projectile.hitSm.AddHitEvent((hitTarget, hitPosition) =>
|
|
{
|
|
new Fusion(20).Apply(hitTarget, player, this);
|
|
});
|
|
}
|
|
}
|
|
} |