public virtual void RecieveDamage(int damage, Entity subject) { CurrentHP -= (int)(damageRecieveCoef * damage); OnDamagedAmount?.Invoke((int)(damageRecieveCoef * damage), MaxHP, subject); OnHpModified?.Invoke((float)CurrentHP / MaxHP); if (CurrentHP <= 0) { CurrentHP = 0; OnZeroHP?.Invoke(); } }
void Start() { OnHpModified?.Invoke((float)CurrentHP / MaxHP); }
// Start is called before the first frame update private void Awake() { entity = GetComponent <Entity>(); entity.OnInit += () => { MaxHP = entity.Data.MaxHP; CurrentHP = MaxHP; OnHpModified?.Invoke((float)CurrentHP / MaxHP); }; }