private void InitHpMp() { var initHp = (int)(this.baseProp.hpMax * this.baseInfo.hpPercent + 0.5f); this.hp = MathTools.Clamp(initHp, 1, hpMax); var initMp = (int)(this.baseProp.hpMax * this.baseInfo.hpPercent + 0.5f); this.mp = MathTools.Clamp(initMp, 1, mpMax); }
public void ChangeHp(int value) { if (!dead) { hp = MathTools.Clamp(hp + value, 0, hpMax); if (hp == 0) { this.dead = true; } battle.recorder.PushHpChange(this); } }
public void TestClampInt(int x, int min, int max, int expected) { Assert.AreEqual(expected, MathTools.Clamp(x, min, max)); }