Added shield items for all classes, finalised item display in inventory, v1.3.0

This commit is contained in:
Nicola Sovic 2022-07-03 12:12:15 +02:00
parent 6631a9f9dc
commit e143f4e7c9
24 changed files with 138 additions and 9 deletions

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3f6be14d1694eb4408591d1e68a5cfff
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2bf51c089eab8374081e48c57ff1db8a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d4b27d99cb613ad4c88565f07da83e76
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 481 B

After

Width:  |  Height:  |  Size: 481 B

View File

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

View File

Before

Width:  |  Height:  |  Size: 505 B

After

Width:  |  Height:  |  Size: 505 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 384 B

After

Width:  |  Height:  |  Size: 384 B

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9e9270ba6468bb041994fbff1ba9e266
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bcaeb0ed29c00804a9e7c9a28cf8c0f9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 26391f484fb6d0848aa88175939e6ad6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -51,7 +51,8 @@ namespace Assets.Scripts
{
slots[j].GetComponent<InventorySlot>().setItem(item);
itemAdded = true;
slots[j].GetComponent<RawImage>().color = Color.red;
slots[j].GetComponent<RawImage>().color = item.rarityColor;
slots[j].GetComponent<RawImage>().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<InventorySlot>().getItem() != null)
item = slots[i].GetComponent<InventorySlot>().getItem();
if (item != null)
{
slots[i].GetComponent<RawImage>().color = Color.red;
slots[i].GetComponent<RawImage>().color = item.rarityColor;
slots[i].GetComponent<RawImage>().texture = item.image;
}
else
{
slots[i].GetComponent<RawImage>().color = Color.white;
slots[i].GetComponent<RawImage>().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<InventorySlot>().getEquip() != null)
item = slot.GetComponent<InventorySlot>().getEquip();
if (item != null)
{
slot.GetComponent<RawImage>().color = Color.red;
slot.GetComponent<RawImage>().color = item.rarityColor;
slot.GetComponent<RawImage>().texture = item.image;
}
else
{
@ -150,9 +158,9 @@ namespace Assets.Scripts
{
switch (place)
{
case ItemPlace.SHIELD:
case ItemPlace.LEFTHAND:
return leftHand.GetComponent<InventorySlot>().getEquip();
case ItemPlace.WEAPON:
case ItemPlace.RIGHTHAND:
return rightHand.GetComponent<InventorySlot>().getEquip();
case ItemPlace.HELMET:
return head.GetComponent<InventorySlot>().getEquip();

View File

@ -18,6 +18,7 @@ namespace Assets.Scripts
private void Start()
{
tooltip = GameObject.Find("TooltipHandler").GetComponent<TooltipHandler>();
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<Texture>("Equipment/" + GameObject.Find("Player").GetComponent<Player>().getClass().classname + "/Inv_LeftHand");
break;
case ItemPlace.RIGHTHAND:
image = Resources.Load<Texture>("Equipment/" + GameObject.Find("Player").GetComponent<Player>().getClass().classname + "/Inv_RightHand");
break;
case ItemPlace.HELMET:
image = Resources.Load<Texture>("Equipment/Inv_Helmet");
break;
case ItemPlace.BOOTS:
image = Resources.Load<Texture>("Equipment/Inv_Boots");
break;
case ItemPlace.SHOULDER:
image = Resources.Load<Texture>("Equipment/Inv_Shoulder");
break;
case ItemPlace.AMULET:
image = Resources.Load<Texture>("Equipment/Inv_Amulet");
break;
case ItemPlace.RING:
image = Resources.Load<Texture>("Equipment/Inv_Ring");
break;
case ItemPlace.ARMOR:
image = Resources.Load<Texture>("Equipment/Inv_Chest");
break;
}
if (image != null)
{
gameObject.GetComponent<RawImage>().texture = image;
}
}
}
}

View File

@ -11,6 +11,8 @@ namespace Assets.Scripts
ItemPlace place;
string itemName;
Dictionary<string, int> 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<Texture>("Equipment/" + GameObject.Find("Player").GetComponent<Player>().getClass().classname + "/Inv_LeftHand");
break;
case ItemPlace.RIGHTHAND:
image = Resources.Load<Texture>("Equipment/" + GameObject.Find("Player").GetComponent<Player>().getClass().classname + "/Inv_RightHand");
break;
case ItemPlace.HELMET:
image = Resources.Load<Texture>("Equipment/Inv_Helmet");
break;
case ItemPlace.BOOTS:
image = Resources.Load<Texture>("Equipment/Inv_Boots");
break;
case ItemPlace.SHOULDER:
image = Resources.Load<Texture>("Equipment/Inv_Shoulder");
break;
case ItemPlace.AMULET:
image = Resources.Load<Texture>("Equipment/Inv_Amulet");
break;
case ItemPlace.RING:
image = Resources.Load<Texture>("Equipment/Inv_Ring");
break;
case ItemPlace.ARMOR:
image = Resources.Load<Texture>("Equipment/Inv_Chest");
break;
}
}
}
}

View File

@ -10,8 +10,8 @@ namespace Assets.Scripts
{
HELMET,
SHOULDER,
WEAPON,
SHIELD,
RIGHTHAND,
LEFTHAND,
RING,
AMULET,
ARMOR,