/// <summary> /// 체력을 최대 체력만큼 회복합니다. <see cref="EHealthEvent"/>는 <see cref="EHealthEvent.Reset"/>입니다 /// </summary> public void DoReset(IDictionary <string, object> mapMsg) { int iHPMax = _iHP_MAX; EHealthEvent eEvent = ExecuteLogic(EHealthEvent.Reset, ref iHPMax, ref mapMsg); _iHP_Current = iHPMax; OnHealthEvent?.Invoke(new OnHealthEventMsg(this, mapMsg, eEvent, 0, 0)); }
/// <summary> /// 체력을 회복시킵니다. <see cref="EHealthEvent"/>는 <see cref="EHealthEvent.Recovery"/>입니다 /// </summary> public void DoRecovery(int iRecoveryAmount, IDictionary <string, object> mapMsg) { if (_iHP_Current == _iHP_MAX) { return; } int iOriginalValue = iRecoveryAmount; EHealthEvent eEvent = ExecuteLogic(EHealthEvent.Recovery, ref iRecoveryAmount, ref mapMsg); _iHP_Current += iRecoveryAmount; OnHealthEvent?.Invoke(new OnHealthEventMsg(this, mapMsg, eEvent, iOriginalValue, iRecoveryAmount)); }
/* protected - [abstract & virtual] */ // ========================================================================== // #region Private private EHealthEvent ExecuteLogic(EHealthEvent eEvent, ref int iHPMax, ref IDictionary <string, object> mapMsg) { if (mapMsg == null) { mapMsg = const_mapMsg_Empty; } IEnumerable <IHealthCalculateLogic> arrLogic; if (_mapHealthLogic.TryGetValue(eEvent, out arrLogic)) { foreach (var pLogic in arrLogic) { pLogic.CalculateHealth(this, const_mapMsg_Empty, ref eEvent, ref iHPMax); } } return(eEvent); }
/// <summary> /// 체력을 해당 양만큼 감소시킵니다. <see cref="EHealthEvent"/>는 <see cref="EHealthEvent.Damaged"/> 혹은 <see cref="EHealthEvent.Dead"/>입니다. /// </summary> /// <param name="iDamageAmount"></param> public void DoDamage(int iDamageAmount, IDictionary <string, object> mapMsg) { if (_iHP_Current <= 0) { return; } int iOriginalValue = iDamageAmount; EHealthEvent eEvent = ExecuteLogic(EHealthEvent.Damaged, ref iDamageAmount, ref mapMsg); _iHP_Current -= iDamageAmount; if (_iHP_Current <= 0) { _iHP_Current = 0; eEvent = EHealthEvent.Dead; } OnHealthEvent?.Invoke(new OnHealthEventMsg(this, mapMsg, eEvent, iOriginalValue, iDamageAmount)); }
public OnHealthEventMsg(Health pHealth, IDictionary <string, object> mapMsg, EHealthEvent eHealthEvent, int iChangedHP_Origin, int iChangedHP_Calculated) { this.pHealth = pHealth; this.mapMsg = mapMsg; this.eHealthEvent = eHealthEvent; this.iChangedHP_Origin = iChangedHP_Origin; this.iChangedHP_Calculated = iChangedHP_Calculated; }