public void UpdateUseButton() { useButton_button.interactable = selectedItem.canUseInMenu; if (!selectedItem.canUseInMenu) { useButton_button.interactable = false; } else { PlayerController player = GameController.PlayerCtrl; PlayerController.ActiveWeapon w = null; switch (selectedItem.ItemName) { case "Short Sword": w = player.GetWeapon(typeof(ShortSword)); break; case "Broad Sword": w = player.GetWeapon(typeof(BroadSword)); break; case "Katana": w = player.GetWeapon(typeof(Katana)); break; } if (w != null) { useButton_button.interactable = w.isUnlocked && w.weapon.Sheathe() && player.currentWeapon != w.weapon; } } useButton_text.text = selectedItem.GetUseButtonText(); }
private void TryEquipSword(Type t) { PlayerController player = GameController.PlayerCtrl; PlayerController.ActiveWeapon w = player.GetWeapon(t); if (w.weapon.Sheathe()) { player.SetWeapon(w.weapon); } }
public void Crafted() { PlayerController player = GameController.PlayerCtrl; switch (itemName) { case "Short Sword": var a = player.GetWeapon(typeof(ShortSword)); var b = a.weapon; b.ApplyUpgrade(); CraftingMenu.Instance.UpdateCraftButton(); CraftingMenu.Instance.UpdateUseButton(); break; case "Broad Sword": PlayerController.ActiveWeapon broadSword = player.GetWeapon(typeof(BroadSword)); if (broadSword.isUnlocked) { broadSword.weapon.ApplyUpgrade(); } else { broadSword.isUnlocked = true; } CraftingMenu.Instance.UpdateCraftButton(); CraftingMenu.Instance.UpdateUseButton(); break; case "Katana": PlayerController.ActiveWeapon katana = player.GetWeapon(typeof(Katana)); if (katana.isUnlocked) { katana.weapon.ApplyUpgrade(); } else { katana.isUnlocked = true; } CraftingMenu.Instance.UpdateCraftButton(); CraftingMenu.Instance.UpdateUseButton(); break; case "Armor": case "Red Potion": case "Blue Potion": case "Green Potion": case "Yellow Potion": case "Dagger": case "Bomb": Number_inv++; break; } }