Files
Cielonos/Assets/Scripts/MainGame/Items/MainWeapons/Polychrome/Polychrome_AttackAreas.cs
SoulliesOfficial 39b43680a9 爆更
2026-07-18 03:16:20 -04:00

140 lines
6.3 KiB
C#

using Cielonos.MainGame.Characters;
using Cielonos.MainGame.Effects.Feedback;
using SLSUtilities.General;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Cielonos.MainGame.Inventory.Collections
{
public partial class Polychrome
{
private NormalArea CreateBaseSlash(string vfxName, AttackUnit attackUnit, float timeDuration = 1f, float hitActiveDuration = 0.04f)
{
NormalArea slash = vfxData.SpawnVFX(vfxName, player).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackUnit)
.SetTimeSubmodule<NormalArea>(timeDuration, hitActiveDuration, 0.04f)
.SetHitSubmodule<NormalArea>();
return slash;
}
private NormalArea GenerateFarSlash(string vfxName, AttackUnit attackUnit, Enemy target)
{
NormalArea slash = target != null
? vfxData.SpawnVFX(vfxName, player, target.CenterPoint).GetComponentInChildren<NormalArea>()
: vfxData.SpawnVFX(vfxName, player, player.transform, new Vector3(0, 1.5f, 3f)).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackUnit)
.SetTimeSubmodule<NormalArea>(1f, 0.04f, 0.04f)
.SetHitSubmodule<NormalArea>();
slash.hitSm.AddHitSound(AK.EVENTS.POLYCHROME_LIGHTATTACKHIT);
Vector3 hitShakeAmplitude = vfxData.Get(vfxName).slashScreenPosition.normalized * 0.12f;
slash.eventSm.onAttackFinished.Add("Polychrome_HitShakeFeedback", new PrioritizedAction<CharacterBase, Attack.Result>((_, result) =>
{
if (!result.HasOutcome(Attack.Outcome.Hit)) return;
PlayHitShakeFeedback("HeavyHit", hitShakeAmplitude);
}));
return slash;
}
private NormalArea GenerateNormalSlash(string vfxName, AttackUnit attackUnit, string hitFeedback)
{
NormalArea slash = CreateBaseSlash(vfxName, attackUnit, 1f, 0.02f);
slash.SetImpulseSubmodule().WithRepulsion(2f);
float magnitude = hitFeedback == "SingleNormalHit" ? 0.08f : 0.04f;
slash.hitSm.AddHitSound(AK.EVENTS.POLYCHROME_LIGHTATTACKHIT);
Vector3 hitShakeAmplitude = vfxData.Get(vfxName).slashScreenPosition.normalized * magnitude;
slash.eventSm.onAttackFinished.Add("Polychrome_HitShakeFeedback", new PrioritizedAction<CharacterBase, Attack.Result>((_, result) =>
{
if (!result.HasOutcome(Attack.Outcome.Hit)) return;
PlayHitShakeFeedback(hitFeedback, hitShakeAmplitude);
}));
return slash;
}
private NormalArea GenerateHeavySlash(string vfxName, AttackUnit attackUnit)
{
NormalArea slash;
if (_hasPhotonDissociator)
{
slash = CreatePhotonDissociatorHeavySlash(vfxName, attackUnit);
}
else
{
slash = CreateBaseSlash(vfxName, attackUnit, 1f, 0.04f);
slash.SetImpulseSubmodule(1f).WithRepulsion(5f);
}
slash.hitSm.AddHitSound(AK.EVENTS.POLYCHROME_HEAVYATTACKLHIT);
Vector3 hitShakeAmplitude = vfxData.Get(vfxName).slashScreenPosition.normalized * 0.16f;
slash.eventSm.onAttackFinished.Add("Polychrome_HitShakeFeedback", new PrioritizedAction<CharacterBase, Attack.Result>((_, result) =>
{
if (!result.HasOutcome(Attack.Outcome.Hit)) return;
PlayHitShakeFeedback("HeavyHit", hitShakeAmplitude);
}));
return slash;
}
private NormalArea GenerateDisruptionSlash(string vfxName, AttackUnit attackUnit)
{
NormalArea slash = CreateBaseSlash(vfxName, attackUnit, 1f, 0.04f);
slash.SetImpulseSubmodule().WithRepulsion(5f);
slash.hitSm.AddHitSound(AK.EVENTS.POLYCHROME_HEAVYATTACKLHIT);
Vector3 hitShakeAmplitude = vfxData.Get(vfxName).slashScreenPosition.normalized * 0.16f;
slash.eventSm.onAttackFinished.Add("Polychrome_HitShakeFeedback", new PrioritizedAction<CharacterBase, Attack.Result>((_, result) =>
{
if (!result.HasOutcome(Attack.Outcome.Hit)) return;
PlayHitShakeFeedback("HeavyHit", hitShakeAmplitude);
}));
slash.eventSm.onAttackFinished.Add("Polychrome_BreakthroughFeedback", new PrioritizedAction<CharacterBase, Attack.Result>((_, result) =>
{
if (!result.HasOutcome(Attack.Outcome.Breakthrough)) return;
feedbackSc.PlayFeedback("Breakthrough");
}));
return slash;
}
private NormalArea GenerateUltimateSlash(string vfxName, AttackUnit attackUnit)
{
NormalArea slash = vfxData.SpawnVFX(vfxName, player).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackUnit)
.SetTimeSubmodule<NormalArea>(2f, 0.02f, 0.24f)
.SetHitSubmodule<NormalArea>(0.07f, 3);
slash.hitSm.AddHitSound(AK.EVENTS.POLYCHROME_HEAVYATTACKLHIT);
Vector3 hitShakeAmplitude = new Vector3(Random.value, Random.value, Random.value).normalized * 0.16f;
slash.eventSm.onAttackFinished.Add("Polychrome_HitShakeFeedback", new PrioritizedAction<CharacterBase, Attack.Result>((_, result) =>
{
if (result.HasOutcome(Attack.Outcome.Hit))
{
PlayHitShakeFeedback("UltimateAttackHit", hitShakeAmplitude);
Debug.Log($"Ultimate Slash finished");
}
}));
return slash;
}
private void PlayHitShakeFeedback(string feedbackName, Vector3 amplitude)
{
feedbackSc.PlayFeedback(feedbackName, runtimeFeedback =>
{
CameraPositionShakeAction positionShakeAction = runtimeFeedback.Action<CameraPositionShakeAction>("Camera");
if (positionShakeAction != null)
{
positionShakeAction.amplitude = amplitude;
}
});
}
}
}