public void RemoveBuff(PassiveStatChange psc) { float hpProportion = 0.0f; float mpProportion = 0.0f; PlayerScript player = PlayerScript.instance; if (buffs.Find (x => x == psc) == null) return ; if (psc.con != 0 || psc.pCon != 0) hpProportion = player.current_hp / (float)player.hpMax; if (psc.intel != 0 || psc.pIntel != 0) mpProportion = player.current_mana / (float)player.manaMax; buffs.Remove(psc); if (psc.hp != 0 || psc.pHp != 0) player.current_hp = Mathf.Clamp (player.current_hp - psc.hp, 0, int.MaxValue); if (psc.mana != 0 || psc.pMp != 0) player.current_mana = Mathf.Clamp (player.current_mana - psc.mana, 0, int.MaxValue); if (psc.con != 0 || psc.pCon != 0) player.current_hp = Mathf.RoundToInt (Mathf.Clamp (player.hpMax * hpProportion, 0, int.MaxValue)); if (psc.intel != 0 || psc.pIntel != 0) player.current_mana = Mathf.RoundToInt (Mathf.Clamp (player.manaMax * mpProportion, 0, int.MaxValue)); }
public void AddBuff(PassiveStatChange psc) { float hpProportion = 0.0f; float mpProportion = 0.0f; PlayerScript player = PlayerScript.instance; if (psc.con != 0 || psc.pCon != 0) hpProportion = player.current_hp / (float)player.hpMax; if (psc.intel != 0 || psc.pIntel != 0) mpProportion = player.current_mana / (float)player.manaMax; buffs.Add (psc); if (psc.hp != 0 || psc.pHp != 0) player.current_hp = Mathf.Clamp (player.current_hp + psc.hp, 0, int.MaxValue); if (psc.mana != 0 || psc.pMp != 0) player.current_mana = Mathf.Clamp (player.current_mana + psc.mana, 0, int.MaxValue); if (psc.con != 0 || psc.pCon != 0) player.current_hp = Mathf.RoundToInt (Mathf.Clamp (player.hpMax * hpProportion, 0, int.MaxValue)); if (psc.intel != 0 || psc.pIntel != 0) player.current_mana = Mathf.RoundToInt (Mathf.Clamp (player.manaMax * mpProportion, 0, int.MaxValue)); }