chore: initial commit

This commit is contained in:
2026-05-08 11:04:00 +08:00
commit f55d2a57c3
6278 changed files with 866081 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
using UnityEngine;
namespace BaseGames.Enemies
{
/// <summary>
/// 敌人运行时数值组件(架构 07_EnemyModule §2
/// 由 EnemyBase.Awake() 通过 Initialize(EnemyStatsSO) 注入配置。
/// </summary>
public class EnemyStats : MonoBehaviour
{
private EnemyStatsSO _config;
public int MaxHP { get; private set; }
public int CurrentHP { get; private set; }
public int Defense { get; private set; }
public float AttackCooldownTimer { get; private set; }
/// <summary>每帧由 EnemyBase 更新(读取玩家位置后写入)。</summary>
public float DistanceToPlayer { get; set; }
public void Initialize(EnemyStatsSO so)
{
_config = so;
MaxHP = so.MaxHP;
CurrentHP = so.MaxHP;
Defense = so.Defense;
}
public void TakeDamage(int amount)
{
CurrentHP = Mathf.Max(0, CurrentHP - amount);
}
public void TickAttackCooldown(float dt)
{
if (AttackCooldownTimer > 0f)
AttackCooldownTimer -= dt;
}
public void ResetAttackCooldown()
{
AttackCooldownTimer = _config != null ? _config.AttackCooldown : 1f;
}
}
}