How can i keep the structure like this, if the tickValue is static?
public float GetMoneyPerSec()
{
float tick = 0;
foreach (UpgradeManager item in items)
{
tick += item.tickValue;
}
return tick;
}
How can i keep the structure like this, if the tickValue is static?
public float GetMoneyPerSec()
{
float tick = 0;
foreach (UpgradeManager item in items)
{
tick += item.tickValue;
}
return tick;
}
This error means your
UpgradeManager
looks as followsremove the
static
keyword and it will work in the context you have in your question.If you want to use it in a static context you need to access it as follows, but then you can not use it in an instanced object (new UpgradeManager() creates an instance)
so using it in your example.
but what you may have wanted to do is this