You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using Entitas;
|
|
using UnityEngine;
|
|
using Game;
|
|
public class RecoverSystem : IExecuteSystem, IInitializeSystem
|
|
{
|
|
private IGroup<GameEntity> _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);
|
|
}
|
|
}
|
|
|
|
} |