Files
zeling_v2/Assets/_Game/Scripts/Player/SpringSystem.cs
2026-05-19 11:50:21 +08:00

44 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
using BaseGames.Core.Events;
namespace BaseGames.Player
{
/// <summary>
/// 灵泉充能系统(架构 05_PlayerModule §7
/// 订阅 EVT_EnemyDied 事件,每次击杀调用 PlayerStats.AddKillPoints()
/// 积分达到阈值时由 PlayerStats 内部自动增加 SpringCharge 并重置积分。
/// 使用灵泉UseSpring由 PlayerController 处理输入、SpringState 执行动画与消耗。
/// </summary>
public class SpringSystem : MonoBehaviour
{
[SerializeField] private PlayerStats _stats;
[SerializeField] private StringEventChannelSO _onEnemyDied; // EVT_EnemyDied
private EventSubscription _sub;
private bool _subscribed;
private void OnEnable()
{
if (_onEnemyDied != null)
{
_sub = _onEnemyDied.Subscribe(OnEnemyDied);
_subscribed = true;
}
}
private void OnDisable()
{
if (_subscribed)
{
_sub.Dispose();
_subscribed = false;
}
}
private void OnEnemyDied(string _enemyId)
{
_stats?.AddKillPoints(1);
}
}
}