//Dealing with the player stat dictionary public int getStat(string resourceName) { if (!ShipResources.ContainsKey(resourceName)) { ShipResources.Add(resourceName, 0); } //returns the value of the given stat return(ShipResources[resourceName]); }
public void setStat(string resourceName, int Value) { if (ShipResources.ContainsKey(resourceName)) { ShipResources[resourceName] = Value; } else { //If the stat doesnt exist and we are setting it, lets just create it ShipResources.Add(resourceName, Value); } // }
public void changeStat(string resourceName, int statChange) { if (ShipResources.ContainsKey(resourceName)) { ShipResources[resourceName] = getStat(resourceName) + statChange; if (ShipResources[resourceName] < 0) { ShipResources[resourceName] = 0; } } else { //If the stat doesnt exist and we are setting it, lets just create it ShipResources.Add(resourceName, statChange); } // }