public KeyValuePair <int, int> TryToCraft(Dictionary <int, int> items) { KeyValuePair <int, int> nothing = new KeyValuePair <int, int>(-1, -1); if (items.Keys.Count < ItemsRequired.Count) { return(nothing); } foreach (KeyValuePair <int, int> item in items) { bool found = false; foreach (KeyValuePair <int, int> itemsR in ItemsRequired) { if (itemsR.Key == item.Key && item.Value >= itemsR.Value) { found = true; break; } } if (!found) { return(nothing); } } return(Crafted.First()); }
public bool IsViable() { var map = new Dictionary <string, int>(); foreach (Block curBlock in inputs) { if (curBlock != null) { int count; if (map.TryGetValue(curBlock.BlockType, out count)) { map[curBlock.BlockType] += 1; } else { map.Add(curBlock.BlockType, 1); } } } bool result = true; foreach (var pair in map) { if (pair.Value > Inventory.GetCount(pair.Key)) { result = false; } } return(result); }
private void Crafting() { var inventory = GameController.Instance.Player.Inventory; if (!this.Recipe.CanCreate(inventory)) { return; } var productItem = this.Recipe.ProductItemSpec; Craft.Crafting(inventory, this.Recipe); UniRxEvent.GlobalBroker.Publish(Crafted.Get(productItem.Hash)); }
public Recipe(Crafted newResult, Block[,] newInputs) { inputs = newInputs; result = newResult; result.SetRecipe(this); }