First lets get this formatted correctly… use code tags:
public void UseAbility ()
{
ScoreManagerScript scoreManagerScript = ScoreManager.transform.GetComponent<ScoreManagerScript>();
if (CoolDown <= 0)
{
Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, AOE);
for (int i =0; i<MaxAOEHit; i++)
{
foreach (Collider2D c in colliders)
{
if (c.GetComponent<CombinationScript>())
{
CombinationScript combinationScript = c.transform.GetComponent<CombinationScript>();
AbilityPower = IAbilityPower + IAbilityPower + combinationScript.Power;
}
}
}
if (scoreManagerScript.Mana >= ManaCost && scoreManagerScript.Money >= MoneyCost&&scoreManagerScript.Power>=PowerCost)
{
scoreManagerScript.Mana = scoreManagerScript.Mana-ManaCost;
scoreManagerScript.Money = scoreManagerScript.Money-MoneyCost;
scoreManagerScript.Power = scoreManagerScript.Power - PowerCost;
tempPower = tempPower + PowerEffectOnUse * AbilityPower * PowerScale;
tempMana = tempMana + ManaEffectOnUse * AbilityPower * PowerScale;
tempMoney = tempMoney + MoneyEffectOnUse * AbilityPower * PowerScale;
tempMana = Mathf.Floor(tempMana);
tempPower = Mathf.Floor(tempPower);
tempMoney = Mathf.Floor(tempMoney);
scoreManagerScript.Mana = scoreManagerScript.Mana+tempMana;
scoreManagerScript.Power = scoreManagerScript.Power+tempPower;
scoreManagerScript.PowerC = scoreManagerScript.Power;
scoreManagerScript.Money = scoreManagerScript.Money+tempMoney;
}
}
Next you say:
FloorToInt really just is Floor with a cast to int. Literally:
Next Floor nor Round is going to round up into the thousands place from the ones place. That’s just not how they work by default (there are overloads for Math.Round that allow places… but you’re not using those).
So the problem isn’t necessarily in the round/floor methods. If those bugged we’d ALL know about it since they’re very common methods used by everyone constantly. Bugs in such staple functions would be recognized at large immediately.
So the problem is in the surrounding code and what you get as inputs and outputs versus what you expect from inputs and outputs.
We don’t know what you want… so what you should do is start up your debugger, put in a break point, and then follow these line by line and see what occurs mathematically. Especially since a lot of these variables aren’t even scoped to the code you shown us… we don’t know where these numbers come from.
Debug and come back with more specifics about your findings from the debugging.