91 lines
3.6 KiB
C#
91 lines
3.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections;
|
|
using Cielonos.MainGame.Buffs.Character;
|
|
using Cielonos.MainGame.Characters;
|
|
using Cielonos.MainGame.UI;
|
|
using Lean.Pool;
|
|
using SLSUtilities.WwiseAssistance;
|
|
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(List<PlayerInputModifierType> modifiers = default)
|
|
{
|
|
if (!functionSm.mainFunction.IsAvailable())
|
|
{
|
|
PlayerCanvas.SupportEquipmentsUIArea[this].CanNotUseOutlineAnimation();
|
|
return;
|
|
}
|
|
|
|
CharacterBase target = CombatManager.EnemySm.Query(50f).LockonFirst();
|
|
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>
|
|
/// 热爆弹完整序列:生成 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);
|
|
uint indicatorPlayID = AudioManager.Post(AK.EVENTS.GENERIC_AOE_INDICATING, groundPosition).playingID;
|
|
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;
|
|
}
|
|
AudioManager.Stop(indicatorPlayID, 0.5f);
|
|
LeanPool.Despawn(sphereInstance);
|
|
GenerateExplosion(sphereEndPosition);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 在指定位置生成爆炸区域,造成伤害并施加 Burn。
|
|
/// </summary>
|
|
private void GenerateExplosion(Vector3 position)
|
|
{
|
|
AudioManager.Post(AK.EVENTS.THERMALDETONATOR_EXPLOSION, 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, 0.04f)
|
|
.SetHitSubmodule<NormalArea>();
|
|
|
|
int burnStack = attackData["Explosion"].GetSubmodule<AttackUnit.ParameterSubmodule>().GetParameter<int>("Buff_Burn_Stack");
|
|
blastArea.eventSm.onHit.Add((hitTarget, hitPosition) =>
|
|
{
|
|
new Burn(burnStack).Apply(hitTarget, player, this);
|
|
});
|
|
}
|
|
}
|
|
}
|