so i coded this up but not entirely sure its correct but the goal is to grab the string out of the dictionary along with the int and if they match the input then return true if not return false
public Dictionary<string,int> upgradesDictionary = new Dictionary<string,int>(){
{"Scoreboard",0},
};
public bool HasUpgrade(string upgradeName,int upgradeLevel){
foreach(string upgrade in upgradesDictionary){
foreach (int level in upgradesDictionary) {
if (upgradeName == upgrade) {
if (upgradeLevel == level) {
return true;
} else {
return false;
}
}
}
}
return false;
}
That shouldn’t even compile…I’m guessing what you want to do is get the int associated with the string value of upgradeName and see if it matches upgradeLevel?
int val;
if (upgradesDictionary.TryGetValue(upgradeName, out val))
{
return val == upgradeLevel;
}
return false;