角色能力,存档

This commit is contained in:
2026-05-19 11:50:21 +08:00
parent d25f237e76
commit 2dcb7a961a
136 changed files with 36035 additions and 27551 deletions

View File

@@ -12,6 +12,7 @@ namespace BaseGames.Player
[SerializeField] private WeaponManager _weaponManager;
private PlayerStats _stats;
private PlayerMovement _movement;
private WeaponHitBoxInstance _currentHitBoxInstance;
/// <summary>下劈 HitBox 命中确认事件(供 DownAttackState 订阅 pogo 弹跳逻辑)。</summary>
@@ -19,7 +20,8 @@ namespace BaseGames.Player
private void Awake()
{
_stats = GetComponentInParent<PlayerStats>();
_stats = GetComponentInParent<PlayerStats>();
_movement = GetComponentInParent<PlayerMovement>();
}
private void OnEnable()
@@ -52,30 +54,17 @@ namespace BaseGames.Player
private void HandleDownHitConfirmed(DamageInfo info) => OnDownHitConfirmed?.Invoke(info);
// ── 连击段伤害来源切换 ────────────────────────────────────────────────
/// <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,
};
_weaponManager.ActiveHitBoxInstance?.SetDamageSource(AttackDirection.Ground, src);
}
// ── HitBox 激活(由 State / AnimationEvent 调用)─────────────────────
public void EnableWeaponHitBox(AttackDirection dir)
/// <summary>
/// 激活 HitBox。
/// hitBoxId 非空时按 Id 精确激活 Prefab 中对应子节点;空 = 方向默认。
/// source 为 null 时回退到 WeaponSO.GetSourceByDir(dir)(方向第 0 段)。
/// </summary>
public void EnableWeaponHitBox(AttackDirection dir,
string hitBoxId = "", DamageSourceSO source = null)
{
var source = _weaponManager?.ActiveWeapon?.GetSourceByDir(dir);
_weaponManager?.ActiveHitBoxInstance?.Activate(dir, source, transform);
source ??= _weaponManager?.ActiveWeapon?.GetSourceByDir(dir);
_weaponManager?.ActiveHitBoxInstance?.Activate(dir, source, transform, hitBoxId);
}
public void DisableWeaponHitBox(AttackDirection dir)
@@ -89,6 +78,12 @@ namespace BaseGames.Player
{
int gain = _weaponManager?.ActiveWeapon?.soulPowerGain ?? 10;
_stats?.AddSoulPower(gain);
// 攻击命中反嵈:向攻击反方向施加微小后退冲量,增强打击感
if (_movement?.Rb != null && info.KnockbackDirection.x != 0f)
_movement.Rb.AddForce(
new UnityEngine.Vector2(UnityEngine.Mathf.Sign(-info.KnockbackDirection.x) * 2f, 0f),
UnityEngine.ForceMode2D.Impulse);
}
}
}