283 lines
11 KiB
C#
283 lines
11 KiB
C#
using System.Collections.Generic;
|
|
using Cielonos.MainGame.Buffs.Character;
|
|
using Cielonos.MainGame.Characters;
|
|
using Cielonos.MainGame.UI;
|
|
using SLSUtilities.FunctionalAnimation;
|
|
using SLSUtilities.General;
|
|
using SLSUtilities.WwiseAssistance;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters.Inventory.Collections
|
|
{
|
|
public partial class FutureWand : MainWeaponBase
|
|
{
|
|
private bool _isHoldingAttack;
|
|
|
|
public CharacterBase currentTarget;
|
|
public override void OnEquipped()
|
|
{
|
|
base.OnEquipped();
|
|
RegisterFunctionsToAnimSc();
|
|
if(!player.inputSc.IsMoving) PlayTargetedAnimation("Equip");
|
|
viewObjects["Wand"].SetFadeAnim(0.5f);
|
|
PlayerCanvas.MainWeaponUIArea.displayer.SetFrameOutline(1);
|
|
}
|
|
|
|
public override void OnPrimaryPress()
|
|
{
|
|
if (!_isHoldingAttack && player.inputSc.IsHoldingSpecialA)
|
|
{
|
|
PlayTargetedAnimation("HoldAttackStart", currentTarget);
|
|
_isHoldingAttack = true;
|
|
return;
|
|
}
|
|
|
|
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
|
|
{
|
|
comboSm.main.NextCombo("L");
|
|
functionSm["LightAttack"].Execute();
|
|
currentTarget = BattleManager.EnemySm.GetNearestEnemy(25f);
|
|
if (currentTarget != null)
|
|
{
|
|
PlayTargetedAnimation("Attack" + comboSm.main.GetCurrentNodeName(), currentTarget, 5f);
|
|
}
|
|
else
|
|
{
|
|
PlayTargetedAnimation("Attack" + comboSm.main.GetCurrentNodeName());
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnPrimaryRelease()
|
|
{
|
|
if (_isHoldingAttack)
|
|
{
|
|
string animName = player.animationSc.fullBodyFuncAnimSm.currentRuntimeFuncAnim?.animationName;
|
|
if(animName == "HoldAttackLoop" || animName == "HoldAttackStart")
|
|
{
|
|
PlayTargetedAnimation("HoldAttackEnd");
|
|
}
|
|
}
|
|
|
|
_isHoldingAttack = false;
|
|
}
|
|
|
|
public override void OnSecondaryPress()
|
|
{
|
|
if (_isHoldingAttack) return;
|
|
|
|
if (functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
|
|
{
|
|
comboSm.main.NextCombo("R");
|
|
functionSm["HeavyAttack"].Execute();
|
|
currentTarget = BattleManager.EnemySm.GetNearestEnemy(25f);
|
|
|
|
if (currentTarget != null)
|
|
{
|
|
PlayTargetedAnimation("Attack" + comboSm.main.GetCurrentNodeName(), currentTarget, 5f);
|
|
}
|
|
else
|
|
{
|
|
PlayTargetedAnimation("Attack" + comboSm.main.GetCurrentNodeName());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class FutureWand
|
|
{
|
|
private void FAPF_GenerateBoltOnWand(RuntimeFuncAnim rtFuncAnim)
|
|
{
|
|
CustomFunction.PC_StringStringFloat p = rtFuncAnim.GetParams<CustomFunction.PC_StringStringFloat>();
|
|
GenerateProjectile(p.str0, attackData[p.str1], currentTarget, p.float0);
|
|
}
|
|
|
|
private void FAPF_GenerateBoltOnHand(RuntimeFuncAnim rtFuncAnim)
|
|
{
|
|
CustomFunction.PC_StringStringFloat p = rtFuncAnim.GetParams<CustomFunction.PC_StringStringFloat>();
|
|
GenerateProjectile(p.str0, attackData[p.str1], currentTarget, p.float0, true, player.bodyPartsSc.leftHand);
|
|
}
|
|
|
|
private void FAPF_GenerateUltimateBeam(RuntimeFuncAnim rtFuncAnim)
|
|
{
|
|
CustomFunction.PC_StringString p = rtFuncAnim.GetParams<CustomFunction.PC_StringString>();
|
|
GenerateUltimateBeam(p.str0, attackData[p.str1]);
|
|
}
|
|
|
|
private void FAPF_GenerateGroundArea(RuntimeFuncAnim rtFuncAnim)
|
|
{
|
|
CustomFunction.PC_StringString p = rtFuncAnim.GetParams<CustomFunction.PC_StringString>();
|
|
GenerateGroundArea(p.str0, attackData[p.str1]);
|
|
}
|
|
|
|
private void FAPF_GenerateMultipleBolts(RuntimeFuncAnim rtFuncAnim)
|
|
{
|
|
CustomFunction.PC_StringStringFloat p = rtFuncAnim.GetParams<CustomFunction.PC_StringStringFloat>();
|
|
List<CharacterBase> targets = BattleManager.EnemySm.GetEnemiesInRadius(player.transform.position, 25f);
|
|
if (targets.Count > 0) vfxData.SpawnMuzzleVFX(p.str0, muzzle);
|
|
foreach (CharacterBase target in targets)
|
|
{
|
|
GenerateProjectile(p.str0, attackData[p.str1], target, p.float0, false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class FutureWand
|
|
{
|
|
private Transform muzzle => viewObjects["Wand"].functionalParts["Muzzle"].transform;
|
|
}
|
|
|
|
public partial class FutureWand
|
|
{
|
|
private void GenerateProjectile(string vfxName, AttackUnit attackUnit,
|
|
CharacterBase target, float speed, bool hasMuzzleEffect = true, Transform muzzle = null)
|
|
{
|
|
if (hasMuzzleEffect)
|
|
{
|
|
muzzle ??= this.muzzle;
|
|
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
|
|
}
|
|
|
|
Projectile projectile = vfxData.SpawnVFX(vfxName).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>(attackUnit)
|
|
.SetTimeSubmodule<Projectile>(10f)
|
|
.SetHitSubmodule<Projectile>()
|
|
.SetAdaptiveTraceMoveModule<Projectile>(target, speed, 5f, 20f, 20f, direction, detectRadius: 25f)
|
|
.SetRaycastSubmodule<Projectile>(default, 0.25f, 0.5f)
|
|
.SetForceSubmodule<Projectile>(2f);
|
|
|
|
if (vfxName == "NormalBolt")
|
|
{
|
|
projectile.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_WEAKATTACKHIT);
|
|
AudioManager.Post(AK.EVENTS.FUTUREWAND_NORMALBOLTRELEASE, projectile.gameObject);
|
|
}
|
|
else if (vfxName == "CubicBolt")
|
|
{
|
|
projectile.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_MEDIUMATTACKHIT);
|
|
AudioManager.Post(AK.EVENTS.FUTUREWAND_CUBICBOLTRELEASE, projectile.gameObject);
|
|
}
|
|
|
|
int fusionStack = attackUnit.GetSubmodule<AttackUnit.ParameterSubmodule>().GetParameter<int>("Buff_Fusion_Stack");
|
|
projectile.hitSm.AddHitEvent((enemy, hitPosition) =>
|
|
{
|
|
new Fusion(fusionStack).Apply(enemy);
|
|
SubscribeFusionExplode(enemy);
|
|
});
|
|
}
|
|
|
|
private void GenerateGroundArea(string vfxName, AttackUnit attackUnit)
|
|
{
|
|
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
|
|
NormalArea area = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
|
|
|
|
area.Initialize<NormalArea>(player, this, Fraction.Enemy)
|
|
.SetAttackSubmodule<NormalArea>(attackUnit)
|
|
.SetTimeSubmodule<NormalArea>(3f, 0.2f, 0.8f)
|
|
.SetHitSubmodule<NormalArea>(0.1f, 4)
|
|
.SetForceSubmodule<NormalArea>(4f, false);
|
|
area.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_WEAKATTACKHIT);
|
|
AudioManager.Post(AK.EVENTS.FUTUREWAND_GROUNDAREA, area.gameObject);
|
|
|
|
if (HasExtender<BlackHoleDisplacer>()) //扩展器测试
|
|
{
|
|
area.SetLinearDirectionMoveModule<NormalArea>(player.transform.forward, 0f, 25f, false, true, false);
|
|
}
|
|
|
|
int fusionStack = attackUnit.GetSubmodule<AttackUnit.ParameterSubmodule>().GetParameter<int>("Buff_Fusion_Stack");
|
|
area.hitSm.AddHitEvent((enemy, hitPosition) =>
|
|
{
|
|
new Fusion(fusionStack).Apply(enemy);
|
|
SubscribeFusionExplode(enemy);
|
|
});
|
|
}
|
|
|
|
private void GenerateUltimateBeam(string vfxName, AttackUnit attackUnit)
|
|
{
|
|
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
|
|
NormalArea area = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
|
|
|
|
area.Initialize<NormalArea>(player, this, Fraction.Enemy)
|
|
.SetAttackSubmodule<NormalArea>(attackUnit)
|
|
.SetTimeSubmodule<NormalArea>(5f, 0.6f)
|
|
.SetHitSubmodule<NormalArea>()
|
|
.SetForceSubmodule<NormalArea>(8f, false);
|
|
area.hitSm.AddHitSound(AK.EVENTS.FUTUREWAND_MEDIUMATTACKHIT);
|
|
|
|
AudioManager.Post(AK.EVENTS.FUTUREWAND_ULTIMATEBEAMPOWERUP, area.gameObject);
|
|
area.timeSm.AddScheduleAction(() =>
|
|
{
|
|
AudioManager.Post(AK.EVENTS.FUTUREWAND_ULTIMATEBEAMSHOOT);
|
|
feedbackSc.PlayFeedback("UltimateBeamShoot");
|
|
}, 0f);
|
|
}
|
|
|
|
private void GenerateSquareExpandingAura(string vfxName)
|
|
{
|
|
vfxData.SpawnMuzzleVFX(vfxName, muzzle);
|
|
NormalArea area = vfxData.SpawnVFX(vfxName).GetComponentInChildren<NormalArea>();
|
|
|
|
area.Initialize<NormalArea>(player, this, Fraction.Enemy)
|
|
.SetAttackSubmodule<NormalArea>(attackData["SquareAura"])
|
|
.SetTimeSubmodule<NormalArea>(4f, 0.2f, 2.8f)
|
|
.SetHitSubmodule<NormalArea>()
|
|
.SetTransformSubmodule<NormalArea>();
|
|
|
|
//audioContainer.PlaySoundFX("SquareAura", area.gameObject, true);
|
|
|
|
area.transformSm.ApplyScaleMove(Vector3.one, Vector3.one * 50, 1f, EaseType.OutQuart);
|
|
area.updateAction = () =>
|
|
{
|
|
if (area.timeSm.enablingTimer > 3f)
|
|
{
|
|
return;
|
|
}
|
|
|
|
List<Projectile> toBeRemoved = new List<Projectile>();
|
|
|
|
foreach (Projectile projectile in BattleManager.AttackAreaSm.enemyAttackAreas.activeProjectiles)
|
|
{
|
|
if (area.areaCollider.IsPointInside(projectile.topParent.transform.position))
|
|
{
|
|
toBeRemoved.Add(projectile);
|
|
}
|
|
}
|
|
|
|
foreach (Projectile projectile in toBeRemoved)
|
|
{
|
|
projectile.Explode();
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
public partial class FutureWand
|
|
{
|
|
private const string FUSION_EXPLODE_KEY = nameof(FutureWand);
|
|
|
|
/// <summary>
|
|
/// 订阅目标身上 Fusion Buff 的引爆事件,当引爆来源为 FutureWand 时执行专属效果。
|
|
/// 字典 Key 天然去重,无需手动 -= +=。
|
|
/// </summary>
|
|
private void SubscribeFusionExplode(CharacterBase enemy)
|
|
{
|
|
Fusion fusion = enemy.buffSm.GetBuff<Fusion>();
|
|
if (fusion == null) return;
|
|
|
|
fusion.onExploded[FUSION_EXPLODE_KEY] = new PrioritizedAction<Fusion, AttackAreaBase>(OnFusionExploded);
|
|
}
|
|
|
|
private void OnFusionExploded(Fusion fusion, AttackAreaBase triggerArea)
|
|
{
|
|
if (triggerArea == null || triggerArea.itemSource != this) return;
|
|
new Decay(50).Apply(fusion.attachedCharacter);
|
|
}
|
|
}
|
|
}
|