多轮审查和修复
This commit is contained in:
@@ -4,7 +4,7 @@ using BaseGames.Combat;
|
||||
namespace BaseGames.Player
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家战斗组件(Phase 1 实现)。
|
||||
/// 玩家战斗组件。
|
||||
/// 架构 05_PlayerModule §5:HitBox 直接挂在 Player Prefab 子节点上,不经过 WeaponInstance。
|
||||
/// 节点:[HitBoxGround]、[HitBoxUp]、[HitBoxDown]、[HitBoxAir]。
|
||||
/// </summary>
|
||||
@@ -18,12 +18,53 @@ namespace BaseGames.Player
|
||||
[SerializeField] private HitBox _hitBoxDown;
|
||||
[SerializeField] private HitBox _hitBoxAir;
|
||||
|
||||
// ── HitBox 激活(由 AttackState / Animancer 帧事件调用)─────────────
|
||||
private PlayerStats _stats;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_stats = GetComponentInParent<PlayerStats>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (_weaponManager != null)
|
||||
_weaponManager.OnWeaponChanged += RefreshWeaponData;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_weaponManager != null)
|
||||
_weaponManager.OnWeaponChanged -= RefreshWeaponData;
|
||||
}
|
||||
|
||||
private void RefreshWeaponData(WeaponSO weapon)
|
||||
{
|
||||
// 武器切换时可在此更新 HitBox 默认尺寸等
|
||||
}
|
||||
|
||||
// ── 连击段伤害来源切换 ────────────────────────────────────────────────
|
||||
/// <summary>
|
||||
/// 根据当前连招段切换 HitBox 的 DamageSource(由 AttackState 在每段开始时调用)。
|
||||
/// </summary>
|
||||
public void SetComboSegmentSource(int comboIndex)
|
||||
{
|
||||
WeaponSO w = _weaponManager?.ActiveWeapon;
|
||||
if (w == null) return;
|
||||
|
||||
DamageSourceSO src = comboIndex switch
|
||||
{
|
||||
0 => w.attack1Source,
|
||||
1 => w.attack2Source,
|
||||
2 => w.attack3Source,
|
||||
_ => w.attack1Source,
|
||||
};
|
||||
_hitBoxGround?.SetDamageSource(src);
|
||||
}
|
||||
|
||||
// ── HitBox 激活(由 State / AnimationEvent 调用)─────────────────────
|
||||
public void EnableWeaponHitBox(AttackDirection dir)
|
||||
{
|
||||
var source = _weaponManager != null
|
||||
? _weaponManager.ActiveWeapon?.GetSourceByDir(dir)
|
||||
: null;
|
||||
var source = _weaponManager?.ActiveWeapon?.GetSourceByDir(dir);
|
||||
GetHitBox(dir)?.Activate(source, transform);
|
||||
}
|
||||
|
||||
@@ -38,8 +79,12 @@ namespace BaseGames.Player
|
||||
_hitBoxAir?.Deactivate();
|
||||
}
|
||||
|
||||
/// <summary>命中回调(Phase 2 §2.3 补全:增加灵力)。</summary>
|
||||
internal void OnHitConfirmed(DamageInfo info) { /* Phase 2:增加灵力 */ }
|
||||
/// <summary>命中确认回调:增加灵力(由 HurtBox.ReceiveDamage 步骤 7 的 HitConfirmed 事件订阅)。</summary>
|
||||
public void OnHitConfirmed(DamageInfo info)
|
||||
{
|
||||
int gain = _weaponManager?.ActiveWeapon?.soulPowerGain ?? 10;
|
||||
_stats?.AddSoulPower(gain);
|
||||
}
|
||||
|
||||
private HitBox GetHitBox(AttackDirection dir) => dir switch
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user