public void CommodityCountChangeHelper(int commodityType, Data data, int count) { if(data.GetDataType() == 2) { if(commodityType == 0) { int resourceCount = GetResourceCount((ResourceData)data); int newResourceValue = Math.Max(resourceCount + count, 0); if(count >= 1) { int resourceCap = GetResourceCap((ResourceData)data); if (resourceCount < resourceCap) { if (newResourceValue > resourceCap) { newResourceValue = resourceCap; } } } SetResourceCount((ResourceData)data, newResourceValue); } } }
public void CommodityCountChangeHelper(int commodityType, Data data, int count) { if(data.GetDataType() == 2) { if(commodityType == 0) { int resourceCount = GetResourceCount((ResourceData)data); int newResourceValue = Math.Max(resourceCount + count, 0); if(count >= 1) { int resourceCap = GetResourceCap((ResourceData)data); if (resourceCount < resourceCap) { if (newResourceValue > resourceCap) { newResourceValue = resourceCap; } } } Debugger.WriteLine(string.Format("Old Resources: {0} New Resources: {1} Resource Cap: {2}", GetResourceCount((ResourceData)data), newResourceValue, GetResourceCap((ResourceData)data)), null, 5); SetResourceCount((ResourceData)data, newResourceValue); } } }