/// <summary> /// Try and use the resourse and return how mnya more resoures are needed /// </summary> /// <param name="req"></param> /// <returns></returns> public int ResourceAvailable(Requirement req) { int needed = req.GetRequired(); if (needed < 1) { // Debug.Log(" 13 "); return 0; } for (int i = 0; i < req.GetRequired(); i++) { if (allResources[req.resourcePos].numOf < 1) { // Debug.Log(" 12 "); return needed; } if (i <= req.requiredDay) { allResources[req.resourcePos].numOf--; //Debug.Log(req.resourcePos + " " + req.requiredDay); needed--; } else { if ((allResources[req.resourcePos].user == ResourceUser.Shelter && allResources[req.resourcePos].numOf > shelters.Count * req.requiredDay) || (allResources[req.resourcePos].user == ResourceUser.Human && allResources[req.resourcePos].numOf > shelters.Count * req.requiredDay)) { allResources[req.resourcePos].numOf--; needed--; } else { // Debug.Log(" 11 "); return needed; } } } // Debug.Log(" 10 "); return needed; }