public void NewItem_Click(object sender, RoutedEventArgs e) { var results = childWindowProvider.ShowAddEditCraftingMaterialWindow( this, null, null, name => materialItems.Any(x => StringComparer.OrdinalIgnoreCase.Equals(x.Name, name))); if (results == null) { return; } var newItem = new CraftingMaterial { Name = results.Value.MaterialName, SourceType = results.Value.SourceType, Location = results.Value.Location }; materialItems.Add(newItem); Notify(nameof(MaterialItems)); ResizeGridViewColumns(); }
/// <inheritdoc /> public Item Convert(ItemDTO value, object state) { var entity = new CraftingMaterial(); this.Merge(entity, value, state); return(entity); }
private AddEditCraftingMaterialWindow GetSubject(string suggestedName, CraftingMaterial editMaterial = null) { return(new AddEditCraftingMaterialWindow( notificationService, suggestedName, editMaterial, existingNamePredicate)); }
public void removeMaterial(CraftingMaterial m) { if (materialTypes[m.type] > 0) { materialTypes[m.type]--; materials.Remove(m); } }
private void OnTriggerEnter(Collider other) { CraftingMaterial material = other.GetComponent <CraftingMaterial>(); if (material != null) { crafting.addMaterial(material); } }
private void Start() { var allSomeEnumValues = (CraftingMaterial[])CraftingMaterial.GetValues(typeof(CraftingMaterial)); // Prefill our list so we can add values to it foreach (var item in allSomeEnumValues) { container.Add(0f); } }
public EquipmentItem(EquipmentBlueprint a_blue, CraftingMaterial a_craft) { blueprint = a_blue; material = a_craft; CraftUpdate(); itemType = ItemType.Equipable; stackSize = 1; useable = true; consumable = false; }
public WeaponItem(WeaponBlueprint a_blue, CraftingMaterial a_craft) { blueprint = a_blue; material = a_craft; CraftUpdate(); itemType = ItemType.Weapon; stackSize = 1; useable = true; consumable = false; }
private void AddMaterial(CraftingMaterial addedMat) { currentMaterials.Add(addedMat.getMaterialId()); Destroy(addedMat); if (currentMaterials.Count >= 2) { MixMaterials(); currentMaterials = new List <CraftingMaterialID>(); } }
private void CreateMaterialPrefab(CraftingMaterial material) { var materialCount = recipe.materialList.FindAll(m => m == material).Count; var materialObj = Instantiate(materialPrefab, materials.transform.position, Quaternion.identity); materialObj.transform.parent = materials.transform; var materialObjIcon = materialObj.transform.GetChild(0); var materialObjText = materialObj.transform.GetChild(1); materialObjIcon.GetComponent <Image>().sprite = material.icon; materialObjText.GetComponent <TextMeshProUGUI>().text = materialCount.ToString(); }
public override void Start() { item = new CraftingMaterial(name: materialName, itemType: materialItemType, ItemID: materialItemID, slotSpace: 1, craftingType: materialCraftingType); }
public static int MaterialDbInsert(CraftingMaterial _weap) { string _fill = "', '"; string _name; int _dura, _wght; _name = _weap.GetName(); _dura = _weap.GetDura(); _wght = _weap.GetWeight(); string values = "('" + _name + _fill + _dura + _fill + _wght + "')"; string locations = "(MaterialName, Durability, Weight)"; string cmdText = "INSERT INTO Materials " + locations + " VALUES" + values; MySqlCommand _cmd = _masterConnect.CreateCommand(); _cmd.CommandText = cmdText; _cmd.ExecuteNonQuery(); _cmd.CommandText = "SELECT * FROM thefellnightprison.Materials Where MaterialName = '" + _name + "' AND Durability = '" + _dura + "' AND Weight = '" + _wght + "'"; MySqlDataReader _reader = _cmd.ExecuteReader(); _reader.Read(); string thing = _reader["idWeapons"].ToString(); _reader.Close(); return Convert.ToInt32(thing); }
// Load the monster.txt drop file. private void LoadDropFile(bool edit) { var lines = (edit == false) ? File.ReadAllLines(Path.Combine(Settings.DropPath, String.Format("{0}.txt", listBoxMonsters.SelectedItem)), Encoding.GetEncoding("euc-kr")) : textBoxDropList.Lines; for (int i = 0; i < lines.Length; i++) { if (lines[i].StartsWith(";Gold")) { if (lines[i + 1].StartsWith("1/")) { var workingLine = lines[i + 1].Split(' '); GoldOdds = workingLine[0].Remove(0, 2); Gold = workingLine[2]; break; } else { GoldOdds = "0"; Gold = "0"; } } } string[] Headers = new string[34] { ";Weapons", ";Armours", ";Helmets", ";Necklaces", ";Bracelets", ";Rings", ";Amulets", ";Belts", ";Boots", ";Stones", ";Torches", ";Potions", ";Ores", ";Meat", ";Crafting Materials", ";Scrolls", ";Gems", ";Mount", ";Books", ";Nothing", ";Script", ";Reins", ";Bells", ";Saddle", ";Ribbon", ";Mask", ";Food", ";Hook", ";Float", ";Bait", ";Finder", ";Reel", ";Fish", ";Quest" }; for (int i = 0; i < Headers.Length; i++) { for (int j = 0; j < lines.Length; j++) { if (lines[j].StartsWith(Headers[i])) { for (int k = j + 1; k < lines.Length; k++) { if (lines[k].StartsWith(";")) { break; } var workingLine = lines[k].Split(' '); if (workingLine.Length < 2) { continue; } var quest = ""; if (workingLine.Length > 2 && workingLine[2] == "Q") { quest = workingLine[2]; } DropItem newDropItem = new DropItem { Odds = workingLine[0], Name = workingLine[1], Quest = quest }; switch (i) { case 0: Weapon.Add(newDropItem); break; case 1: Armour.Add(newDropItem); break; case 2: Helmet.Add(newDropItem); break; case 3: Necklace.Add(newDropItem); break; case 4: Bracelet.Add(newDropItem); break; case 5: Ring.Add(newDropItem); break; case 6: Amulet.Add(newDropItem); break; case 7: Belt.Add(newDropItem); break; case 8: Boot.Add(newDropItem); break; case 9: Stone.Add(newDropItem); break; case 10: Torch.Add(newDropItem); break; case 11: Potion.Add(newDropItem); break; case 12: Ore.Add(newDropItem); break; case 13: Meat.Add(newDropItem); break; case 14: CraftingMaterial.Add(newDropItem); break; case 15: Scrolls.Add(newDropItem); break; case 16: Gem.Add(newDropItem); break; case 17: Mount.Add(newDropItem); break; case 18: Book.Add(newDropItem); break; case 19: Nothing.Add(newDropItem); break; case 20: Script.Add(newDropItem); break; case 21: Reins.Add(newDropItem); break; case 22: Bells.Add(newDropItem); break; case 23: Saddle.Add(newDropItem); break; case 24: Ribbon.Add(newDropItem); break; case 25: Mask.Add(newDropItem); break; case 26: Food.Add(newDropItem); break; case 27: Hook.Add(newDropItem); break; case 28: Float.Add(newDropItem); break; case 29: Bait.Add(newDropItem); break; case 30: Finder.Add(newDropItem); break; case 31: Reel.Add(newDropItem); break; case 32: Fish.Add(newDropItem); break; case 33: Quest.Add(newDropItem); break; default: break; } } } } } }
// Add the item to the drop list private void buttonAdd_Click(object sender, EventArgs e) { int dropChance; int.TryParse(textBoxItemOdds.Text, out dropChance); if (dropChance < 1) { dropChance = 1; } string quest = QuestOnlyCheckBox.Checked ? "Q" : ""; try { switch (tabControlSeperateItems.SelectedTab.Tag.ToString()) { case "Weapon": Weapon.Add(new DropItem { Name = listBoxWeapon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Armour": Armour.Add(new DropItem { Name = listBoxArmour.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Helmet": Helmet.Add(new DropItem { Name = listBoxHelmet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Necklace": Necklace.Add(new DropItem { Name = listBoxNecklace.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Bracelet": Bracelet.Add(new DropItem { Name = listBoxBracelet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ring": Ring.Add(new DropItem { Name = listBoxRing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Amulet": Amulet.Add(new DropItem { Name = listBoxAmulet.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Belt": Belt.Add(new DropItem { Name = listBoxBelt.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Boots": Boot.Add(new DropItem { Name = listBoxBoot.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Stone": Stone.Add(new DropItem { Name = listBoxStone.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Torch": Torch.Add(new DropItem { Name = listBoxTorch.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Potion": Potion.Add(new DropItem { Name = listBoxPotion.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ore": Ore.Add(new DropItem { Name = listBoxOre.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Meat": Meat.Add(new DropItem { Name = listBoxMeat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "CraftingMaterial": CraftingMaterial.Add(new DropItem { Name = listBoxCraftingMaterial.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance) }); break; case "Scroll": Scrolls.Add(new DropItem { Name = listBoxScroll.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Gem": Gem.Add(new DropItem { Name = listBoxGem.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Mount": Mount.Add(new DropItem { Name = listBoxMount.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Book": Book.Add(new DropItem { Name = listBoxBook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Nothing": Nothing.Add(new DropItem { Name = listBoxNothing.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Script": Script.Add(new DropItem { Name = listBoxScript.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Reins": Reins.Add(new DropItem { Name = listBoxReins.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Bells": Bells.Add(new DropItem { Name = listBoxBells.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Saddle": Saddle.Add(new DropItem { Name = listBoxSaddle.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Ribbon": Ribbon.Add(new DropItem { Name = listBoxRibbon.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Mask": Mask.Add(new DropItem { Name = listBoxMask.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Food": Food.Add(new DropItem { Name = listBoxFood.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", dropChance), Quest = quest }); break; case "Hook": Hook.Add(new DropItem { Name = listBoxHook.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Float": Float.Add(new DropItem { Name = listBoxFloat.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Bait": Bait.Add(new DropItem { Name = listBoxBait.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Finder": Finder.Add(new DropItem { Name = listBoxFinder.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Reel": Reel.Add(new DropItem { Name = listBoxReel.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Fish": Fish.Add(new DropItem { Name = listBoxFish.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; case "Quest": Quest.Add(new DropItem { Name = listBoxQuest.SelectedItem.ToString().Replace(" ", string.Empty), Odds = string.Format("1/{0}", textBoxItemOdds.Text), Quest = quest }); break; } UpdateDropFile(); } catch { //No item selected when trying to add an item to the drop } }
public AddEditCraftingMaterialWindow(INotificationService notificationService, string suggestedName = null, CraftingMaterial editMaterial = null, Func <string, bool> nameAlreadyExists = null) { this.notificationService = notificationService; if (editMaterial == null) { MaterialName = suggestedName ?? ""; SelectedSourceType = SourceTypes.First(); } else { MaterialName = editMaterial.Name; SelectedSourceType = SourceTypes.FirstOrDefault(x => x.Value == editMaterial.SourceType) ?? SourceTypes.First(); Location = editMaterial.Location; } this.nameAlreadyExists = (nameAlreadyExists ?? (_ => false)); DataContext = this; InitializeComponent(); SetResourceReference(BackgroundProperty, SystemColors.ControlBrushKey); if (editMaterial == null) { Title = "New Crafting Material"; } cbxSourceType.ItemsSource = SourceTypes; txtMaterialName.Focus(); }
public static CraftingMaterial ReadMaterialDb(int id) { MySqlCommand _cmd = _masterConnect.CreateCommand(); _cmd.CommandText = "SELECT * FROM thefellnightprison.Materials Where idMaterial = '" + id + "'"; MySqlDataReader _reader = _cmd.ExecuteReader(); _reader.Read(); CraftingMaterial _mat = new CraftingMaterial(Convert.ToInt32(_reader["idMaterials"].ToString()), _reader["MaterialName"].ToString(), Convert.ToInt32(_reader["Durability"].ToString()), Convert.ToInt32(_reader["Weight"].ToString()) ); _reader.Close(); return _mat; }
public static SaveDataResults FromJson(string jsonString) { var saveData = JsonConvert.DeserializeObject <SaveData>(jsonString); var materialsList = saveData.AllCraftingMaterials .Select(x => { return(new CraftingMaterial { Name = x.Name, SourceType = x.SourceType, Location = x.Location }); }) .ToList(); Func <Guid, CraftingItemData> lookupCraftingItem = id => saveData.AllCraftingItems.FirstOrDefault(x => x.Id == id); Func <Guid, CraftingMaterialData> lookupCraftingMaterial = id => saveData.AllCraftingMaterials.FirstOrDefault(x => x.Id == id); CraftingItem convertCraftingItem(CraftingItemData item) { if (item == null) { throw new InvalidOperationException("Cannot convert null crafting item data."); } var craftingItem = new CraftingItem { Name = item.Name, SourceType = item.SourceType }; var materials = item.Materials ?? Enumerable.Empty <CountedCraftingItemData>().ToList(); craftingItem.SetMaterials( materials .Select(x => { ICraftingMaterial craftingMaterial; if (x.IsMaterial) { var material = lookupCraftingMaterial(x.ItemId); if (material == null) { throw new InvalidOperationException($"Cannot find saved material with id '{x.ItemId}'."); } craftingMaterial = new CraftingMaterial { Name = material.Name, SourceType = material.SourceType, Location = material.Location }; } else { var craftingItem = lookupCraftingItem(x.ItemId); if (craftingItem == null) { throw new InvalidOperationException($"Cannot find saved crafting item with id '{x.ItemId}'."); } craftingMaterial = convertCraftingItem(craftingItem); } return(new SpecifiedCraftingMaterial { Material = craftingMaterial, Count = x.Count }); })); return(craftingItem); }; var itemsList = saveData.AllCraftingItems .Select(item => convertCraftingItem(item)) .ToList(); var listedItemsList = saveData.ListedItems .Select(item => { var itemData = lookupCraftingItem(item.ItemId); if (itemData == null) { throw new InvalidOperationException($"Cannot find saved crafting item with id '{item.ItemId}'."); } var craftingItem = itemsList.FirstOrDefault(x => StringComparer.OrdinalIgnoreCase.Equals(x.Name, itemData.Name)); if (craftingItem == null) { throw new InvalidOperationException($"Cannot find rendered crafting item with name '{itemData.Name}'."); } return(new SpecifiedCraftingItem { Item = craftingItem, Count = item.Count }); }) .ToList(); return(new SaveDataResults { DefinedCraftingMaterials = materialsList, DefinedCraftingItems = itemsList, CraftingItems = listedItemsList }); }
public void addMaterial(CraftingMaterial m) { materialTypes[m.type]++; materials.Add(m); }
// Implement this method in a buddy class to set properties that are specific to 'CraftingMaterial' (if any) partial void Merge(CraftingMaterial entity, ItemDTO dto, object state);
// Update is called once per frame void Update() { // update screen ui while (circularDrive.outAngle - currentAngle > ANGLE_DIFF) { currentAngle += ANGLE_DIFF; moveOutlineDown(); } while (currentAngle - circularDrive.outAngle > ANGLE_DIFF) { currentAngle -= ANGLE_DIFF; moveOutlineUp(); } // Check recipes // HARD CODING YEAAAAAAA string text = ""; if (materialTypes[CraftingMaterial.MaterialType.Apple] > 0) { text += ENABLED_COLOR; recipesCraftable[(int)Recipes.AppleSeed] = true; } else { text += DISABLED_COLOR; recipesCraftable[(int)Recipes.AppleSeed] = false; } text += "Apple -> Apple Seed" + COLOR_END + "\n"; if (materialTypes[CraftingMaterial.MaterialType.Wood] > 0) { text += ENABLED_COLOR; recipesCraftable[(int)Recipes.Fertilizer] = true; } else { text += DISABLED_COLOR; recipesCraftable[(int)Recipes.Fertilizer] = false; } text += "Wood -> Fertilizer" + COLOR_END + "\n"; if (materialTypes[CraftingMaterial.MaterialType.Corn] > 0) { text += ENABLED_COLOR; recipesCraftable[(int)Recipes.Biodiesel] = true; } else { text += DISABLED_COLOR; recipesCraftable[(int)Recipes.Biodiesel] = false; } text += "Corn -> Biodiesel" + COLOR_END + "\n"; if (materialTypes[CraftingMaterial.MaterialType.Berry] > 0) { text += ENABLED_COLOR; recipesCraftable[(int)Recipes.SolarPanel] = true; } else { text += DISABLED_COLOR; recipesCraftable[(int)Recipes.SolarPanel] = false; } text += "Berries -> Solar Panel" + COLOR_END; screenText.text = text; if (!craftSwitch && Mathf.Approximately(craftButtonLinearDrive.linearMapping.value, 1f)) { // TODO: change to craft selected recipe ONLY IF enough material present if (recipesCraftable[selectedRecipeIndex]) { // The correct way to do this would be to make a Recipe class that has a dictionary of material types and quantities // as well as an output product. // I'm not doing it the correct way. switch ((Recipes)(selectedRecipeIndex)) { case Recipes.AppleSeed: { CraftingMaterial mat = materials.Find(m => m.type == CraftingMaterial.MaterialType.Apple); removeMaterial(mat); Destroy(mat.gameObject); } break; case Recipes.Fertilizer: { CraftingMaterial mat = materials.Find(m => m.type == CraftingMaterial.MaterialType.Wood); removeMaterial(mat); Destroy(mat.gameObject); } break; case Recipes.Biodiesel: { CraftingMaterial mat = materials.Find(m => m.type == CraftingMaterial.MaterialType.Corn); removeMaterial(mat); Destroy(mat.gameObject); } break; case Recipes.SolarPanel: { CraftingMaterial mat = materials.Find(m => m.type == CraftingMaterial.MaterialType.Berry); removeMaterial(mat); Destroy(mat.gameObject); } break; default: break; } GameObject instance = Instantiate(craftingProductPrefabs[selectedRecipeIndex]); instance.transform.position = productOutput.position; craftSwitch = true; } } else if (craftButtonLinearDrive.linearMapping.value < 0.5f) { craftSwitch = false; } }
void RecieveMaterial(string id, string name, string dura, string weight) { Debug.Log("Recieve Material"); CraftingMaterial _temp = new CraftingMaterial(Convert.ToInt32(id), name, Convert.ToInt32(dura), Convert.ToInt32(weight)); GameObject controller = GameObject.FindGameObjectWithTag("GameController"); controller.GetComponent<ControllerV2>().carryData.player.InvMaterials.Add(_temp); }