Files
Cielonos/Assets/Scripts/MainGame/Items/MainWeapons/FutureWand/FutureWand.cs

137 lines
4.3 KiB
C#
Raw Normal View History

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