137 lines
4.3 KiB
C#
137 lines
4.3 KiB
C#
using System.Collections.Generic;
|
|
using Cielonos.MainGame.Characters;
|
|
using SLSUtilities.General;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Inventory.Collections
|
|
{
|
|
public partial class FutureWand : MainWeaponBase
|
|
{
|
|
private bool _isHoldingAttack;
|
|
|
|
public CharacterBase currentTarget;
|
|
|
|
private NormalArea _activeSpinArea;
|
|
|
|
private VFXObject _spinAreaChargeVFX;
|
|
private int _spinAreaUpgradeCount = 0;
|
|
|
|
private Transform Muzzle => viewObjects["Wand"].functionalParts["Muzzle"].transform;
|
|
|
|
public override void OnEquipped()
|
|
{
|
|
base.OnEquipped();
|
|
RegisterFunctionsToAnimSc();
|
|
viewObjects["Wand"].SetFadeAnim(0.5f);
|
|
|
|
// 订阅玩家受击事件,在受击时中断施法并召回 SpinArea
|
|
player.eventSm.onGetHit.TryAdd(nameof(FutureWand), new PrioritizedAction<AttackAreaBase>(OnPlayerGetHit));
|
|
}
|
|
|
|
public override void OnUnequipped()
|
|
{
|
|
// 注销受击事件,避免内存泄漏
|
|
player.eventSm.onGetHit.Remove(nameof(FutureWand));
|
|
|
|
RecallActiveSpinArea();
|
|
base.OnUnequipped();
|
|
}
|
|
|
|
public override void OnSwitchIn()
|
|
{
|
|
if(!player.inputSc.IsMoving) PlayTargetedAnimation("Equip");
|
|
}
|
|
|
|
public override void OnSwitchOut()
|
|
{
|
|
base.OnSwitchOut();
|
|
RecallActiveSpinArea();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 轻攻击(普攻)输入处理
|
|
/// </summary>
|
|
public override void OnPrimaryPress()
|
|
{
|
|
// 判定是否满足特殊蓄力攻击条件
|
|
if (!_isHoldingAttack && player.inputSc.IsHoldingSpecialA)
|
|
{
|
|
if (PlayHoldAttackStart(currentTarget))
|
|
{
|
|
_isHoldingAttack = true;
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 常规地面轻攻击连击
|
|
if (functionSm["LightAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
|
|
{
|
|
currentTarget = CombatManager.EnemySm.GetNearestEnemy(25f);
|
|
string nextNodeName = comboSm.main.GetNextNodeName("L");
|
|
if (PlayNormalAttackL(currentTarget, nextNodeName))
|
|
{
|
|
comboSm.main.NextCombo("L");
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 轻攻击释放处理
|
|
/// </summary>
|
|
public override void OnPrimaryRelease()
|
|
{
|
|
if (_isHoldingAttack)
|
|
{
|
|
string animName = player.animationSc.fullBodyFuncAnimSm.currentRuntimeFuncAnim?.animationName;
|
|
if (animName == "HoldAttackLoop" || animName == "HoldAttackStart")
|
|
{
|
|
PlayHoldAttackEnd();
|
|
}
|
|
RecallActiveSpinArea();
|
|
}
|
|
|
|
_isHoldingAttack = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重攻击输入处理
|
|
/// </summary>
|
|
public override void OnSecondaryPress()
|
|
{
|
|
if (_isHoldingAttack) return;
|
|
|
|
// 常规地面重攻击连击
|
|
if (functionSm["HeavyAttack"].IsAvailable() && fullBodyFuncAnimSm.CheckPlayability())
|
|
{
|
|
currentTarget = CombatManager.EnemySm.GetNearestEnemy(25f);
|
|
string nextNodeName = comboSm.main.GetNextNodeName("R");
|
|
if (PlayNormalAttackR(currentTarget, nextNodeName))
|
|
{
|
|
comboSm.main.NextCombo("R");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class FutureWand
|
|
{
|
|
/// <summary>
|
|
/// 玩家受击回调:中断当前的蓄力行为,并收回飞盘法阵
|
|
/// </summary>
|
|
private void OnPlayerGetHit(AttackAreaBase attackArea)
|
|
{
|
|
if (_isHoldingAttack)
|
|
{
|
|
string animName = player.animationSc.fullBodyFuncAnimSm.currentRuntimeFuncAnim?.animationName;
|
|
if (animName == "HoldAttackLoop" || animName == "HoldAttackStart")
|
|
{
|
|
PlayHoldAttackEnd();
|
|
}
|
|
_isHoldingAttack = false;
|
|
}
|
|
|
|
RecallActiveSpinArea();
|
|
}
|
|
}
|
|
}
|