I am trying to pull a stored int out of an enum based on the enum
public enum HeartRates
{
HEAVY_DAMAGE = 150,
MEDIUM_DAMAGER = 130,
LIGHT_DAMAGE = 110,
FULL = 90,
}
public void SetBPM(HeartRates rate)
{
flatLine = false;
//BeatsPerMinute = (int)rate;
Debug.Log(rate);
}
In another Script:
public void CaculateBPM()
{
int health = agentInfo.agentStats.currentHealth;
int maxHealth = agentInfo.agentStats.maxHealth;
if (health > 0)
{
float percentage = (4f / maxHealth) * health;
int refNumber = Mathf.FloorToInt(percentage);
//if at 100% health to enable last selection in the enum
if(refNumber == 4)
{
refNumber = 3;
}
heartRateMonitor.SetBPM((HeartRates)refNumber);
}
}
if i remove the = something from the enum then i am able to log out the value of the enum eg passing 0 in will log out “HEAVY_DAMAGE”. However when i add the values to the enums i just get its position within the enum when i use debug.log(rate) or debug.log((int)rate) and not the assigned value. So Medium_Damage would log out 1 instead of 130. any ideas where im going wrong with this. all references i can find online suggest that doing (int)the_value should work fine.
Thanks