#Im bad at coding

1 messages · Page 1 of 1 (latest)

spare nebula
#

If anyone could help me figure this out that would be much appreciated

#

The debug logs only display 0s and an occasional 1

inner nexus
#

could you please use the correct format so it would be a bit easier to read:

``cs Code ``

#

three of the 3'

spare nebula
#

@inner nexus fixed

inner nexus
#

ty gimme a sec ill go and find out for you what the issue is

spare nebula
#

Thank you

inner nexus
#

Controller.instance.data.productionUpgradeLevels.Count 's Count is 5000?

spare nebula
#

No it's 11

inner nexus
#

ok. well it looks to me like you are missing a return function or any function end the loop

spare nebula
#

so I need to end it in a return; ?

inner nexus
#

yeah but you'd need to adjust the code a bit otherwise it will return at 3

#

gimme a sec ill write something up

spare nebula
#

ty

inner nexus
#
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

spare nebula
#

and how will this fix my issue?

inner nexus
#

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

spare nebula
#

so now it displays 1 if the level is anything above 0

#

for all of the upgrades

#

which isnt what i want

inner nexus
#

oh yeah remove the last break;

spare nebula
#

now instead of 5000 im getting 2500

inner nexus
#

what is Controller.instance.ProPower?

spare nebula
#
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;
    }```
inner nexus
#
else if (data.clickUpgradeLevels[clickUpgradePos] > 0)
            {
                total = (Math.Pow(2, data.clickUpgradeLevels[clickUpgradePos]) * UpgradeManager.instance.productionUpgradeBasePower[proPos]);
            }```
#

take a look at that part

spare nebula
#

i dont see whats wrong

inner nexus
#

well something in the equation is going wrong. because it is the only time you are multiplying

spare nebula
#

well in the first if i only want the base power

inner nexus
#

maybe if you chance the Math.Pow(2) to Math.Pow(1)?

spare nebula
#

why?

#

this is working fine this isnt the issue

#

well at least i dont think it is

inner nexus
#

well that is the code that is called when you get 2500 right?

spare nebula
#

yeah

inner nexus
#

then something in the equation goes wrong

#

how much should the power increment you level up?

spare nebula
#

when you level up it should incriment buy however much the base power is

#

but i also have other upgrades that alter the power

inner nexus
#

because what i would do is:

public float[] Increment

public void SetPowerLevel()
{
   Tool.instance.PowerLevel = Tool.instance.baseLevel * Increment[Tool.instance.ToolLevel];
}

#

can also be done with doubles ofcourse

spare nebula
#

okay thanks

#

i have to go right no

#

but thank you for helping