#Im bad at coding
1 messages · Page 1 of 1 (latest)
If anyone could help me figure this out that would be much appreciated
The debug logs only display 0s and an occasional 1
could you please use the correct format so it would be a bit easier to read:
``cs Code ``
three of the 3'
@inner nexus fixed
ty gimme a sec ill go and find out for you what the issue is
Thank you
Controller.instance.data.productionUpgradeLevels.Count 's Count is 5000?
No it's 11
ok. well it looks to me like you are missing a return function or any function end the loop
so I need to end it in a return; ?
yeah but you'd need to adjust the code a bit otherwise it will return at 3
gimme a sec ill write something up
ty
public void DisplayPower()
{
for (int i = 0; i < Controller.instance.data.productionUpgradeLevels.Count; i++)
{
if (Controller.instance.data.productionUpgradeLevels[i] <= 1)
{
displayPower = productionUpgradeBasePower[i];
Debug.Log(Controller.instance.ProPower(i));
break;
}
else if(Controller.instance.data.productionUpgradeLevels[i] >= displayPower)
{
displayPower = Controller.instance.ProPower(i);
Debug.Log(Controller.instance.ProPower(i));
break;
}
}
}
try something along the lines of this
i replaced return with break
and how will this fix my issue?
because now it is checkign if the current productionUpgradeLevels is higher than the displaypower
i think i am grabbing the right data here. i am not sure what the controller class holds
so now it displays 1 if the level is anything above 0
for all of the upgrades
which isnt what i want
oh yeah remove the last break;
now instead of 5000 im getting 2500
what is Controller.instance.ProPower?
public double ProPower(int proPos)
{
double total = 0;
int clickUpgradePos = proPos + 1;
if (data.productionUpgradeLevels[proPos] > 0 && data.clickUpgradeLevels[clickUpgradePos] == 0)
{
total = UpgradeManager.instance.productionUpgradeBasePower[proPos];
}
else if (data.clickUpgradeLevels[clickUpgradePos] > 0)
{
total = (Math.Pow(2, data.clickUpgradeLevels[clickUpgradePos]) * UpgradeManager.instance.productionUpgradeBasePower[proPos]);
}
return total;
}```
else if (data.clickUpgradeLevels[clickUpgradePos] > 0)
{
total = (Math.Pow(2, data.clickUpgradeLevels[clickUpgradePos]) * UpgradeManager.instance.productionUpgradeBasePower[proPos]);
}```
take a look at that part
i dont see whats wrong
well something in the equation is going wrong. because it is the only time you are multiplying
well in the first if i only want the base power
maybe if you chance the Math.Pow(2) to Math.Pow(1)?
well that is the code that is called when you get 2500 right?
yeah
then something in the equation goes wrong
how much should the power increment you level up?
when you level up it should incriment buy however much the base power is
but i also have other upgrades that alter the power