Added complete crafting to the game. Next step would be research and buildings. Updated DSL with Setup to work with dynamic loading.
This commit is contained in:
@@ -32,9 +32,9 @@ public class Inventory
|
||||
{
|
||||
bool canCraft = true;
|
||||
Item item;
|
||||
foreach(Ingredient ingredient in neededIngredients)
|
||||
foreach (Ingredient ingredient in neededIngredients)
|
||||
{
|
||||
item = items.Find(x => x.data.Id == ingredient.item && x.currentAmount >= ingredient.amount * amount);
|
||||
item = items.Find(x => x.data.Id == ingredient.Item && x.currentAmount >= ingredient.Amount * amount);
|
||||
if (item == null)
|
||||
{
|
||||
canCraft = false;
|
||||
@@ -43,4 +43,13 @@ public class Inventory
|
||||
}
|
||||
return canCraft;
|
||||
}
|
||||
|
||||
public void RemoveItem(string id, int amount)
|
||||
{
|
||||
Item item = items.Find(x => x.data.Id == id && x.currentAmount >= amount);
|
||||
if (item != null)
|
||||
{
|
||||
item.currentAmount -= amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user