Add basic Health implementation
This commit is contained in:
parent
266842afd4
commit
3c402eb09d
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
using Seraphina.Core;
|
||||
|
||||
namespace Seraphina
|
||||
{
|
||||
public class Health
|
||||
{
|
||||
public HitPoint Current { get; set; }
|
||||
public HitPoint Max { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The percentage of health remaining.
|
||||
/// </summary>
|
||||
public double Percent => Current.Value * 100.0 / Max.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if the owner of this health component is incapacitated, ie, has <= 0 HP left.
|
||||
/// </summary>
|
||||
public bool IsIncapacitated => Current <= 0;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the missing amount of HitPoint on this component. Returns 0 if overhealed.
|
||||
/// </summary>
|
||||
public HitPoint Missing => Current > Max ? 0 : Max - Current;
|
||||
|
||||
public Color GetColor() => PlayerHealthColor.GetColor(Current, Max);
|
||||
|
||||
public (int num, int remainder) Div(int numerator, int denominator)
|
||||
{
|
||||
var result = Current.Value * numerator / denominator;
|
||||
|
||||
return (result, Current.Value - result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue