Files
Cielonos/Assets/Scripts/MainGame/Items/MainWeapons/Polychrome.cs
SoulliesOfficial d15957c719 更新
2025-12-17 04:19:38 -05:00

338 lines
15 KiB
C#

using Cielonos.MainGame.Characters;
using Cielonos.MainGame.Characters.Buffs;
using SLSUtilities.FunctionalAnimation;
using Unity.Cinemachine;
using UnityEngine;
namespace Cielonos.MainGame.Inventory
{
public partial class Polychrome : MainWeaponBase
{
public float perfectBlockedTimer;
protected override void Update()
{
base.Update();
perfectBlockedTimer -= player.selfTimeSm.DeltaTime;
}
public override void OnEquipped()
{
RegisterFunctionsToAnimSc(
LightAttack0, LightAttack1, LightAttack2, LightAttack3,
TripleAttack_0, TripleAttack_1, TripleAttack_2,
DisruptAttack, HeavyAttack, RunAttack, ParryAttack, StayBlocking);
}
public override void OnPrimaryPress()
{
if (player.inputSc.IsHoldingSpecialA && functionSm["TripleAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.ResetCombo();
functionSm["TripleAttack"].Execute();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("TripleAttack", target, 1f);
//player.viewSc.cameraRotationSm.TriggerCameraRecenter(player.transform.forward);
return;
}
if (player.landMovementSc.isSprinting && functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.ResetCombo();
functionSm["LightAttack"].Execute();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(8);
PlayTargetedAnimation("RunAttack", target, 1f);
//player.viewSc.cameraRotationSm.TriggerCameraRecenter(player.transform.forward);
return;
}
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.NextCombo("L");
functionSm["LightAttack"].Execute();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("LightAttack" + comboSm.GetCurrentNodeName(), target, 1f);
//player.viewSc.cameraRotationSm.TriggerCameraRecenter(player.transform.forward);
}
}
public override void OnSecondaryPress()
{
if (perfectBlockedTimer > 0f && functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability(DisruptionType.ForcedAction))
{
perfectBlockedTimer = 0f;
comboSm.ResetCombo();
functionSm["HeavyAttack"].Execute();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("ParryAttack", target, 1f);
//player.viewSc.cameraRotationSm.TriggerCameraRecenter(player.transform.forward);
return;
}
if (player.inputSc.IsHoldingSpecialA &&
functionSm["DisruptAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.ResetCombo();
functionSm["DisruptAttack"].Execute();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("DisruptAttack", target, 1f);
//player.viewSc.cameraRotationSm.TriggerCameraRecenter(player.transform.forward);
return;
}
if (functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
{
comboSm.ResetCombo();
functionSm["HeavyAttack"].Execute();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("HeavyAttack", target, 1f);
//player.viewSc.cameraRotationSm.TriggerCameraRecenter(player.transform.forward);
}
}
public override void OnSpecialBPress()
{
if (functionSm["Block"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability(DisruptionType.ForcedAction))
{
comboSm.ResetCombo();
CharacterBase target = BattleManager.EnemySm.GetNearestEnemy(5);
PlayTargetedAnimation("Block", target, 2f, true, null, 1f, 0.1f, true);
SetBlock();
player.movementSc.canMove.Modify(false);
player.movementSc.canRotate.Modify(false);
}
}
public override void OnSpecialBRelease()
{
if (fullBodyFuncAnimSm.currentRuntimeFuncAnim is { animationName: "Block" })
{
fullBodyFuncAnimSm.Stop(DisruptionType.ForcedAction);
}
RemoveBlock();
player.movementSc.canMove.Modify(true);
player.movementSc.canRotate.Modify(true);
}
}
public partial class Polychrome
{
private void LightAttack0() => GenerateNormalSlash("LightAttack0", new Vector3(1f, 0.6f, 0).normalized * 0.1f);
private void LightAttack1() => GenerateNormalSlash("LightAttack1", new Vector3(-1f, -0.6f, 0).normalized * 0.1f);
private void LightAttack2() => GenerateNormalSlash("LightAttack2", new Vector3(-1f, 0.6f, 0).normalized * 0.1f);
private void LightAttack3() => GenerateNormalSlash("LightAttack3", Vector3.right * 0.1f);
private void TripleAttack_0() => GenerateFastSlash("TripleAttack_0", new Vector3(1f, 0.6f, 0).normalized * 0.2f);
private void TripleAttack_1() => GenerateFastSlash("TripleAttack_1", new Vector3(-1f, -0.6f, 0).normalized * 0.2f);
private void TripleAttack_2() => GenerateFastSlash("TripleAttack_2", Vector3.right * 0.2f);
private void HeavyAttack() => GenerateHeavySlash("HeavyAttack", new Vector3(1f, 0.6f, 0).normalized * 0.4f);
private void RunAttack() => GenerateMoveSlash("RunAttack", new Vector3(1f, 0.6f, 0).normalized * 0.1f, player.transform.forward * 10f);
private void ParryAttack() => GenerateParrySlash("ParryAttack", new Vector3(-1f, -0.6f, 0).normalized * 0.4f);
private void DisruptAttack() => GenerateDisruptSlash("DisruptAttack", new Vector3(1f, 0, 0).normalized * 0.4f);
}
public partial class Polychrome
{
private NormalArea GenerateNormalSlash(string vfxName, Vector3 swingForce)
{
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["LightAttack"])
.SetTimeSubmodule<NormalArea>(1f, 0.04f)
.SetHitSubmodule<NormalArea>()
.SetForceSubmodule<NormalArea>(3f, true);
slash.hitSm
.AddHitSound("NormalHit")
.AddHitEvent((enemy, hitPosition) =>
{
feedbackSc["NormalHit"].Play();
player.selfTimeSm.ModifyTimeScale(0.06f);
enemy.selfTimeSm.ModifyTimeScale(0.06f);
new ElectronicDisturbance(2).Apply(enemy);
});
Swing("Swing", "Swing", swingForce);
return slash;
}
private NormalArea GenerateFastSlash(string vfxName, Vector3 swingForce)
{
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["LightAttack"])
.SetTimeSubmodule<NormalArea>(1f, 0.04f)
.SetHitSubmodule<NormalArea>()
.SetForceSubmodule<NormalArea>(3f, true);
slash.hitSm
.AddHitSound("NormalHit")
.AddHitEvent((enemy, hitPosition) =>
{
feedbackSc["NormalHit"].Play();
player.selfTimeSm.ModifyTimeScale(0.06f);
enemy.selfTimeSm.ModifyTimeScale(0.06f);
new ElectronicDisturbance(2).Apply(enemy);
if (enemy.statusSm.HasStatus(StatusType.Incapacitation))
{
slash.attackSm.modifiedAttackValue.damage *= 5f;
}
});
Swing("Swing", "Swing", swingForce);
return slash;
}
private NormalArea GenerateHeavySlash(string vfxName, Vector3 swingForce)
{
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["HeavyAttack"])
.SetTimeSubmodule<NormalArea>(1f, 0.04f, 0.16f)
.SetHitSubmodule<NormalArea>()
.SetForceSubmodule<NormalArea>(3f, true);
slash.hitSm
.AddHitSound("HeavyHit")
.AddHitEvent((enemy, hitPosition) =>
{
feedbackSc["HeavyHit"].Play();
player.selfTimeSm.ModifyTimeScale(0.12f);
enemy.selfTimeSm.ModifyTimeScale(0.12f);
player.viewSc.cameraDistance.currentValue -= 2f;
new ElectronicDisturbance(5).Apply(enemy);
});
Swing("Swing", "Swing", swingForce);
return slash;
}
private NormalArea GenerateParrySlash(string vfxName, Vector3 swingForce)
{
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["ParryAttack"])
.SetTimeSubmodule<NormalArea>(1f, 0.04f)
.SetHitSubmodule<NormalArea>()
.SetForceSubmodule<NormalArea>(3f, true);
slash.hitSm
.AddHitSound("HeavyHit")
.AddHitEvent((enemy, hitPosition) =>
{
feedbackSc["HeavyHit"].Play();
player.selfTimeSm.ModifyTimeScale(0.12f);
enemy.selfTimeSm.ModifyTimeScale(0.12f);
new ElectronicDisturbance(5).Apply(enemy);
});
Swing("Swing", "Swing", swingForce);
return slash;
}
private NormalArea GenerateDisruptSlash(string vfxName, Vector3 swingForce)
{
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["DisruptAttack"])
.SetTimeSubmodule<NormalArea>(1f, 0.04f)
.SetHitSubmodule<NormalArea>()
.SetForceSubmodule<NormalArea>(3f, true);
slash.hitSm
.AddHitSound("HeavyHit")
.AddHitEvent((enemy, hitPosition) =>
{
feedbackSc["HeavyHit"].Play();
player.selfTimeSm.ModifyTimeScale(0.12f);
enemy.selfTimeSm.ModifyTimeScale(0.12f);
new ElectronicDisturbance(5).Apply(enemy);
});
Swing("Swing", "Swing", swingForce);
return slash;
}
private void GenerateMoveSlash(string vfxName, Vector3 swingForce, Vector3 moveVelocity)
{
NormalArea slash = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
slash.Initialize<NormalArea>(player, this, Fraction.Enemy)
.SetAttackSubmodule<NormalArea>(attackData["LightAttack"])
.SetTimeSubmodule<NormalArea>(1f, 0.04f)
.SetHitSubmodule<NormalArea>()
.SetForceSubmodule<NormalArea>(3f, true)
.SetLinearDirectionMoveModule<NormalArea>(moveVelocity.normalized, moveVelocity.magnitude, -20f, false);
slash.hitSm
.AddHitSound("NormalHit")
.AddHitEvent((enemy, hitPosition) =>
{
feedbackSc["NormalHit"].Play();
player.selfTimeSm.ModifyTimeScale(0.06f);
enemy.selfTimeSm.ModifyTimeScale(0.06f);
new ElectronicDisturbance(2).Apply(enemy);
});
Swing("Swing", "Swing", swingForce);
}
string parryAnimName = "ParryL";
private void SetBlock()
{
BlockSource blockSource = blockData.CreateBlockSource(player, this);
blockSource.onNormalBlock = (attackArea) =>
{
PostProcessingManager.Instance.chromaticAberrationSm.ModifyIntensity(0.2f);
PostProcessingManager.Instance.radialBlurSm.ModifyBlurRadius(0.2f);
parryAnimName = parryAnimName == "ParryL" ? "ParryR" : "ParryL";
animationSc.fullBodyFuncAnimSm.Play(parryAnimName, 1, 0);
if (attackArea is NormalArea)
{
new ElectronicDisturbance(2).Apply(attackArea.creator);
}
};
blockSource.onPerfectBlock = (attackArea) =>
{
PostProcessingManager.Instance.chromaticAberrationSm.ModifyIntensity(0.5f);
PostProcessingManager.Instance.radialBlurSm.ModifyBlurRadius(0.5f);
parryAnimName = parryAnimName == "ParryL" ? "ParryR" : "ParryL";
animationSc.fullBodyFuncAnimSm.Play(parryAnimName, 1, 0);
perfectBlockedTimer = 0.5f;
if (attackArea is NormalArea)
{
new ElectronicDisturbance(10).Apply(attackArea.creator);
}
};
player.reactionSc.blockSm.ApplyBlock(blockSource);
//blockDisposable?.Dispose();
}
private void StayBlocking()
{
if (player.inputSc.IsHoldingSpecialB)
{
player.movementSc.canMove.Modify(true);
player.movementSc.canRotate.Modify(true);
OnSpecialBPress();
}
}
private void RemoveBlock()
{
player.reactionSc.blockSm.RemoveBlock(blockData.blockName);
}
}
}