From e143f4e7c93909cf1698d37a0ebde9cfdd05d5bf Mon Sep 17 00:00:00 2001 From: Nicola Sovic Date: Sun, 3 Jul 2022 12:12:15 +0200 Subject: [PATCH] Added shield items for all classes, finalised item display in inventory, v1.3.0 --- Assets/IMG/Aseprite/Inv_Orb.aseprite | Bin 0 -> 631 bytes Assets/IMG/Aseprite/Inv_Orb.aseprite.meta | 7 ++++ Assets/IMG/Aseprite/Inv_SmallShield.aseprite | Bin 0 -> 631 bytes .../Aseprite/Inv_SmallShield.aseprite.meta | 7 ++++ Assets/Resources/Equipment.meta | 8 ++++ .../Equipment}/Inv_Amulet.png | Bin .../Equipment}/Inv_Amulet.png.meta | 0 .../Equipment}/Inv_Boots.png | Bin .../Equipment}/Inv_Boots.png.meta | 0 .../Equipment}/Inv_Chest.png | Bin .../Equipment}/Inv_Chest.png.meta | 0 .../Equipment}/Inv_Helmet.png | Bin .../Equipment}/Inv_Helmet.png.meta | 0 .../Equipment}/Inv_Ring.png | Bin .../Equipment}/Inv_Ring.png.meta | 0 .../Equipment}/Inv_Shoulders.png | Bin .../Equipment}/Inv_Shoulders.png.meta | 0 Assets/Resources/Equipment/Mage.meta | 8 ++++ Assets/Resources/Equipment/Thief.meta | 8 ++++ Assets/Resources/Equipment/Warrior.meta | 8 ++++ Assets/Scripts/Inventory.cs | 22 ++++++---- Assets/Scripts/InventorySlot.cs | 37 +++++++++++++++++ Assets/Scripts/Item.cs | 38 ++++++++++++++++++ Assets/Scripts/Items/ItemPlace.cs | 4 +- 24 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 Assets/IMG/Aseprite/Inv_Orb.aseprite create mode 100644 Assets/IMG/Aseprite/Inv_Orb.aseprite.meta create mode 100644 Assets/IMG/Aseprite/Inv_SmallShield.aseprite create mode 100644 Assets/IMG/Aseprite/Inv_SmallShield.aseprite.meta create mode 100644 Assets/Resources/Equipment.meta rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Amulet.png (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Amulet.png.meta (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Boots.png (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Boots.png.meta (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Chest.png (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Chest.png.meta (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Helmet.png (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Helmet.png.meta (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Ring.png (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Ring.png.meta (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Shoulders.png (100%) rename Assets/{IMG/Inventory => Resources/Equipment}/Inv_Shoulders.png.meta (100%) create mode 100644 Assets/Resources/Equipment/Mage.meta create mode 100644 Assets/Resources/Equipment/Thief.meta create mode 100644 Assets/Resources/Equipment/Warrior.meta diff --git a/Assets/IMG/Aseprite/Inv_Orb.aseprite b/Assets/IMG/Aseprite/Inv_Orb.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..ed2fe4764d783f2b78cfc00495409079e9db7e2c GIT binary patch literal 631 zcmcJNPbdUY9LIlyY30I6Iqgf5o7qXU+1gSr)LpLz3pHQ&#h-b#bW{edAFh7v z<3H++ufM;TeyT}8J2RmC$hx>2)*VXybb@s|{!)u{sy;Z}6M?C42<8)m@NS_SmiJSz za z!0g5rOgj#oNW|gtP!1m2HY|@P;r03{%oj#rZr;)k2WayCyJEp1I05>&BaSu7_#%rb znm8he9cp+Xg%LWQi`H16KtACl6H6w6q!AVLl2jwC6$%oN(V4ZmMHO;+F;#U-b1ACj bU5nMd=X3uOWVXMKE6pvny+1x3X%*ueLpLz3pHQ&#h-b#bW{edAFh7v z<3H++ufM;TeyT}8J2RmC$hx>2)*VXybb@s|{!)u{sy;Z}6M?C42<8)m@NS_SmiJSz za z!0g5rOgj#oNW|gtP!1m2HY|@P;r03{%oj#rZr;)k2WayCyJEp1I05>&BaSu7_#%rb znm8he9cp+Xg%LWQi`H16KtACl6H6w6q!AVLl2jwC6$%oN(V4ZmMHO;+F;#U-b1ACj bU5nMd=X3uOWVXMKE6pvny+1x3X%*ue().setItem(item); itemAdded = true; - slots[j].GetComponent().color = Color.red; + slots[j].GetComponent().color = item.rarityColor; + slots[j].GetComponent().texture = item.image; break; } } @@ -80,15 +81,19 @@ namespace Assets.Scripts private void checkInventoryColors() { + Item item; for (int i = 0; i < slots.Length; i++) { - if (slots[i].GetComponent().getItem() != null) + item = slots[i].GetComponent().getItem(); + if (item != null) { - slots[i].GetComponent().color = Color.red; + slots[i].GetComponent().color = item.rarityColor; + slots[i].GetComponent().texture = item.image; } else { slots[i].GetComponent().color = Color.white; + slots[i].GetComponent().texture = null; } } } @@ -96,6 +101,7 @@ namespace Assets.Scripts private void checkEquipColors() { GameObject slot = head; + Item item; for (int i = 0; i < 8; i++) { switch (i) @@ -125,9 +131,11 @@ namespace Assets.Scripts slot = ring; break; } - if (slot.GetComponent().getEquip() != null) + item = slot.GetComponent().getEquip(); + if (item != null) { - slot.GetComponent().color = Color.red; + slot.GetComponent().color = item.rarityColor; + slot.GetComponent().texture = item.image; } else { @@ -150,9 +158,9 @@ namespace Assets.Scripts { switch (place) { - case ItemPlace.SHIELD: + case ItemPlace.LEFTHAND: return leftHand.GetComponent().getEquip(); - case ItemPlace.WEAPON: + case ItemPlace.RIGHTHAND: return rightHand.GetComponent().getEquip(); case ItemPlace.HELMET: return head.GetComponent().getEquip(); diff --git a/Assets/Scripts/InventorySlot.cs b/Assets/Scripts/InventorySlot.cs index 44248ac..b006b5a 100644 --- a/Assets/Scripts/InventorySlot.cs +++ b/Assets/Scripts/InventorySlot.cs @@ -18,6 +18,7 @@ namespace Assets.Scripts private void Start() { tooltip = GameObject.Find("TooltipHandler").GetComponent(); + loadImages(); } public void updateCurrentBag(int currentBag) @@ -154,5 +155,41 @@ namespace Assets.Scripts { equip = null; } + + private void loadImages() + { + Texture image = null; + switch (place) + { + case ItemPlace.LEFTHAND: + image = Resources.Load("Equipment/" + GameObject.Find("Player").GetComponent().getClass().classname + "/Inv_LeftHand"); + break; + case ItemPlace.RIGHTHAND: + image = Resources.Load("Equipment/" + GameObject.Find("Player").GetComponent().getClass().classname + "/Inv_RightHand"); + break; + case ItemPlace.HELMET: + image = Resources.Load("Equipment/Inv_Helmet"); + break; + case ItemPlace.BOOTS: + image = Resources.Load("Equipment/Inv_Boots"); + break; + case ItemPlace.SHOULDER: + image = Resources.Load("Equipment/Inv_Shoulder"); + break; + case ItemPlace.AMULET: + image = Resources.Load("Equipment/Inv_Amulet"); + break; + case ItemPlace.RING: + image = Resources.Load("Equipment/Inv_Ring"); + break; + case ItemPlace.ARMOR: + image = Resources.Load("Equipment/Inv_Chest"); + break; + } + if (image != null) + { + gameObject.GetComponent().texture = image; + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/Item.cs b/Assets/Scripts/Item.cs index e165af6..b382e16 100644 --- a/Assets/Scripts/Item.cs +++ b/Assets/Scripts/Item.cs @@ -11,6 +11,8 @@ namespace Assets.Scripts ItemPlace place; string itemName; Dictionary attributes; + public Texture image; + public Color32 rarityColor; public Item(int luck) { @@ -41,6 +43,7 @@ namespace Assets.Scripts } itemName = itemName.ToLower(); itemName = char.ToUpper(itemName[0]) + itemName.Substring(1); + loadImage(); } private void calculateRarity(int luck) @@ -49,18 +52,22 @@ namespace Assets.Scripts if (number + luck < 74) { rarity = ItemRarity.COMMON; + rarityColor = new Color32(0,255,20,255); } else if (number + luck >= 75 && number + luck < 104) { rarity = ItemRarity.RARE; + rarityColor = new Color32(0,100,255, 255); } else if (number + luck >= 105 && number + luck < 113) { rarity = ItemRarity.EPIC; + rarityColor = new Color32(255,0,230, 255); } else if (number + luck >= 114) { rarity = ItemRarity.LEGENDARY; + rarityColor = new Color32(255,230,0, 255); } } @@ -199,6 +206,37 @@ namespace Assets.Scripts } return displayText; } + + private void loadImage() + { + switch (place) + { + case ItemPlace.LEFTHAND: + image = Resources.Load("Equipment/" + GameObject.Find("Player").GetComponent().getClass().classname + "/Inv_LeftHand"); + break; + case ItemPlace.RIGHTHAND: + image = Resources.Load("Equipment/" + GameObject.Find("Player").GetComponent().getClass().classname + "/Inv_RightHand"); + break; + case ItemPlace.HELMET: + image = Resources.Load("Equipment/Inv_Helmet"); + break; + case ItemPlace.BOOTS: + image = Resources.Load("Equipment/Inv_Boots"); + break; + case ItemPlace.SHOULDER: + image = Resources.Load("Equipment/Inv_Shoulder"); + break; + case ItemPlace.AMULET: + image = Resources.Load("Equipment/Inv_Amulet"); + break; + case ItemPlace.RING: + image = Resources.Load("Equipment/Inv_Ring"); + break; + case ItemPlace.ARMOR: + image = Resources.Load("Equipment/Inv_Chest"); + break; + } + } } } \ No newline at end of file diff --git a/Assets/Scripts/Items/ItemPlace.cs b/Assets/Scripts/Items/ItemPlace.cs index 8879cd0..d2d7922 100644 --- a/Assets/Scripts/Items/ItemPlace.cs +++ b/Assets/Scripts/Items/ItemPlace.cs @@ -10,8 +10,8 @@ namespace Assets.Scripts { HELMET, SHOULDER, - WEAPON, - SHIELD, + RIGHTHAND, + LEFTHAND, RING, AMULET, ARMOR,