Added images for left and right hand, added new item-hover display, added item drag animation, v1.3.0

This commit is contained in:
Nicola Sovic
2022-07-03 15:06:05 +02:00
parent e143f4e7c9
commit e002a76690
25 changed files with 1224 additions and 124 deletions

View File

@@ -16,17 +16,34 @@ namespace Assets.Scripts
public GameObject amulet;
public GameObject leftHand;
public GameObject rightHand;
public GameObject dragImage;
public GameObject itemDisplay;
public GameObject[] bags;
public GameObject[] slots;
Dictionary<string, int> statBoost;
public int currentBag = -1;
GameObject startDrag;
TooltipHandler tooltip;
// Start is called before the first frame update
void Start()
{
statBoost = new Dictionary<string, int>();
statBoost.Add("HP", 0);
statBoost.Add("MP", 0);
statBoost.Add("HPR", 0);
statBoost.Add("MPR", 0);
statBoost.Add("STR", 0);
statBoost.Add("DEX", 0);
statBoost.Add("INT", 0);
statBoost.Add("LCK", 0);
tooltip = GameObject.Find("TooltipHandler").GetComponent<TooltipHandler>();
itemDisplay.transform.localScale = new Vector3(0,0,0);
changeCurrentBag(0);
}
@@ -41,15 +58,14 @@ namespace Assets.Scripts
{
if (item != null)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;You got an item!");
bool itemAdded = false;
for (int i = 0; i < bags.Length; i++)
{
for (int j = 0; j < slots.Length; j++)
{
if (slots[j].GetComponent<InventorySlot>().getItem() == null)
if (slots[j].GetComponent<InventorySlot>().getItem(i) == null)
{
slots[j].GetComponent<InventorySlot>().setItem(item);
slots[j].GetComponent<InventorySlot>().setItem(item, i);
itemAdded = true;
slots[j].GetComponent<RawImage>().color = item.rarityColor;
slots[j].GetComponent<RawImage>().texture = item.image;
@@ -58,9 +74,14 @@ namespace Assets.Scripts
}
if (itemAdded)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;You got an item!");
break;
}
}
if (!itemAdded)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;No inventory space left.");
}
}
}
@@ -84,7 +105,7 @@ namespace Assets.Scripts
Item item;
for (int i = 0; i < slots.Length; i++)
{
item = slots[i].GetComponent<InventorySlot>().getItem();
item = slots[i].GetComponent<InventorySlot>().getItem(currentBag);
if (item != null)
{
slots[i].GetComponent<RawImage>().color = item.rarityColor;
@@ -178,6 +199,37 @@ namespace Assets.Scripts
return null;
}
}
}
public void calculateStatBoost(Dictionary<string, int> attributes, bool isAddition)
{
foreach (string key in attributes.Keys)
{
if (isAddition)
{
statBoost[key] = statBoost[key] + attributes[key];
}
else
{
statBoost[key] = statBoost[key] - attributes[key];
}
}
}
public Dictionary<string, int> getEquipmentBonus()
{
if (statBoost == null)
{
statBoost = new Dictionary<string, int>();
statBoost.Add("HP", 0);
statBoost.Add("MP", 0);
statBoost.Add("HPR", 0);
statBoost.Add("MPR", 0);
statBoost.Add("STR", 0);
statBoost.Add("DEX", 0);
statBoost.Add("INT", 0);
statBoost.Add("LCK", 0);
}
return statBoost;
}
}
}