using Entitas; using UnityEngine; using Game; public class RecoverSystem : IExecuteSystem, IInitializeSystem { private IGroup _entities; public void Initialize() { _entities = Util.GetGroup(GameMatcher.Hp); } public void Execute() { foreach (var entity in _entities) { UpdateRecover(entity); } } public static void UpdateRecover(GameEntity entity) { var hp = entity.hp; if (!hp.IsAlive) { return; } //护盾恢复 if (hp.ShieldRecoverTimeMax == 0) return; if (hp.ShieldRecoverTime > 0) { hp.ShieldRecoverTime -= Time.deltaTime; if (hp.ShieldRecoverTime < 0) { hp.ShieldRecoverTime = 0; } } else { var newShield = hp.Shield.Value + hp.ShieldRecover * Time.deltaTime; hp.Shield.Value = Mathf.Min(hp.ShieldMax.Value, newShield); } } }