101 lines
3.7 KiB
C#
101 lines
3.7 KiB
C#
using System.Collections;
|
|
using Cielonos.MainGame.Buffs.Character;
|
|
using Cielonos.MainGame.Characters;
|
|
using Cielonos.MainGame.UI;
|
|
using Lean.Pool;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Inventory.Collection
|
|
{
|
|
public partial class ThermalDetonator : SupportEquipmentBase
|
|
{
|
|
private const float DescentDuration = 4f;
|
|
private const float SpawnHeight = 24f;
|
|
}
|
|
|
|
public partial class ThermalDetonator
|
|
{
|
|
public override void OnPress()
|
|
{
|
|
if (!functionSm.mainFunction.IsAvailable())
|
|
{
|
|
PlayerCanvas.SupportEquipmentsUIArea[this].CanNotUseOutlineAnimation();
|
|
return;
|
|
}
|
|
|
|
CharacterBase target = CombatManager.EnemySm.GetBestEnemyWithLockonFirst(50f);
|
|
if (target == null)
|
|
{
|
|
PlayerCanvas.SupportEquipmentsUIArea[this].NoTargetOutlineAnimation();
|
|
return;
|
|
}
|
|
|
|
Vector3 groundPosition = target.transform.position;
|
|
StartCoroutine(DetonatorSequence(groundPosition));
|
|
|
|
functionSm.mainFunction.Execute();
|
|
PlayerCanvas.SupportEquipmentsUIArea[this].UseOutlineAnimation();
|
|
}
|
|
}
|
|
|
|
public partial class ThermalDetonator
|
|
{
|
|
/// <summary>
|
|
/// 获取最优目标:优先返回锁定目标,其次返回最近敌人。
|
|
/// </summary>
|
|
private CharacterBase GetOptimalTarget()
|
|
{
|
|
LockTargetSubmodule lockModule = player.viewSc.lockTargetModule;
|
|
if (lockModule.isLocking && lockModule.lockTarget != null)
|
|
{
|
|
return lockModule.lockTarget;
|
|
}
|
|
|
|
return CombatManager.EnemySm.GetBestEnemy(25f);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 热爆弹完整序列:生成 indicator → 生成并下落 sphere → 爆炸。
|
|
/// </summary>
|
|
private IEnumerator DetonatorSequence(Vector3 groundPosition)
|
|
{
|
|
GameObject indicatorInstance = vfxData.SpawnVFX("Indicator", player, groundPosition, Quaternion.identity);
|
|
Vector3 sphereEndPosition = groundPosition + Vector3.up * 2f;
|
|
Vector3 sphereStartPosition = groundPosition + Vector3.up * (SpawnHeight + 2);
|
|
GameObject sphereInstance = vfxData.SpawnVFX("Sphere", player, sphereStartPosition, Quaternion.identity);
|
|
|
|
float elapsed = 0f;
|
|
while (elapsed < DescentDuration)
|
|
{
|
|
elapsed += player.selfTimeSm.DeltaTime;
|
|
float t = Mathf.Clamp01(elapsed / DescentDuration);
|
|
sphereInstance.transform.position = Vector3.Lerp(sphereStartPosition, sphereEndPosition, t);
|
|
yield return null;
|
|
}
|
|
|
|
LeanPool.Despawn(sphereInstance);
|
|
GenerateExplosion(sphereEndPosition);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 在指定位置生成爆炸区域,造成伤害并施加 Burn。
|
|
/// </summary>
|
|
private void GenerateExplosion(Vector3 position)
|
|
{
|
|
GameObject explosionInstance = vfxData.SpawnVFX("Explosion", player, position, Quaternion.identity);
|
|
NormalArea blastArea = explosionInstance.GetComponentInChildren<NormalArea>();
|
|
|
|
blastArea.Initialize<NormalArea>(player, this, Fraction.Enemy)
|
|
.SetAttackSubmodule<NormalArea>(attackData["Explosion"])
|
|
.SetTimeSubmodule<NormalArea>(1f, 0f)
|
|
.SetHitSubmodule<NormalArea>();
|
|
|
|
int burnStack = attackData["Explosion"].GetSubmodule<AttackUnit.ParameterSubmodule>().GetParameter<int>("Buff_Burn_Stack");
|
|
blastArea.hitSm.AddHitEvent((hitTarget, hitPosition) =>
|
|
{
|
|
new Burn(burnStack).Apply(hitTarget, player, this);
|
|
});
|
|
}
|
|
}
|
|
}
|