|  |  |  | using Entitas; | 
					
						
							|  |  |  | using UnityEngine; | 
					
						
							|  |  |  | using Game; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | [Game] | 
					
						
							|  |  |  | public class HpComponent : IComponent | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public MetaData<float> Hp = new MetaData<float>(); | 
					
						
							|  |  |  |     public MetaData<float> HpMax = new MetaData<float>(); | 
					
						
							|  |  |  |     public MetaData<float> Shield = new MetaData<float>(); | 
					
						
							|  |  |  |     public MetaData<float> ShieldMax = new MetaData<float>(); | 
					
						
							|  |  |  |     public MetaData<float> Stun = new MetaData<float>(); | 
					
						
							|  |  |  |     public MetaData<float> StunMax = new MetaData<float>(); | 
					
						
							|  |  |  |     public MetaData<bool> IsDamaged = new MetaData<bool>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public Shape HitBoxShape; //受击框形状 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public Vector3 LastDamageDir = Vector3.zero; | 
					
						
							|  |  |  |     public EHitLevel LastDamageLevel = EHitLevel.None; | 
					
						
							|  |  |  |     public int LastDmg = 0; //伤害显示合并 | 
					
						
							|  |  |  |     public float ShieldRecoverTimeMax = 0; //护盾恢复延迟 | 
					
						
							|  |  |  |     public float ShieldRecoverTime = 0; //护盾恢复延迟当前值 | 
					
						
							|  |  |  |     public float ShieldRecover = 0; //护盾恢复速度(点/秒) | 
					
						
							|  |  |  |     public float StunRecoverTimeMax = 0; //眩晕恢复延迟 | 
					
						
							|  |  |  |     public float StunRecoverTime = 0; //眩晕恢复延迟当前值 | 
					
						
							|  |  |  |     public float StunRecover = 0; //眩晕恢复速度(点/秒) | 
					
						
							|  |  |  |     public float DmgShowTime = 0; | 
					
						
							|  |  |  |     public bool IsAlive = true; | 
					
						
							|  |  |  |     public bool IsDying = false; | 
					
						
							|  |  |  |     public float DyingTime = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Game | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public abstract partial class Util | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         public static void EntityDie(GameEntity entity) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             Util.EntityStopMove(entity.ID()); | 
					
						
							|  |  |  |             entity.hp.IsAlive = false; | 
					
						
							|  |  |  |             entity.view.Material.SetColor("_FlashColor", new Color(0.5f, 0.5f, 0.5f, 1f)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void EntityReborn(GameEntity entity) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             entity.hp.IsAlive = true; | 
					
						
							|  |  |  |             entity.hp.Hp.Value = entity.hp.HpMax.Value; | 
					
						
							|  |  |  |             entity.animation.ResetMsg = true; | 
					
						
							|  |  |  |             entity.view.Material.SetColor("_FlashColor", new Color(1f, 1f, 1f, 1f)); | 
					
						
							|  |  |  |             entity.view.GameObjectLogic.SetActive(true); | 
					
						
							|  |  |  |             entity.OnCreate(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ClearHp(GameEntity entity) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var hp = entity.hp; | 
					
						
							|  |  |  |             hp.LastDmg = 0; | 
					
						
							|  |  |  |             hp.DmgShowTime = 0; | 
					
						
							|  |  |  |             hp.IsAlive = true; | 
					
						
							|  |  |  |             hp.IsDying = false; | 
					
						
							|  |  |  |             hp.DyingTime = 0; | 
					
						
							|  |  |  |             hp.IsDamaged.Value = false; | 
					
						
							|  |  |  |             hp.LastDamageDir = Vector3.zero; | 
					
						
							|  |  |  |             hp.LastDamageLevel = EHitLevel.None; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } |