Added controls for gamepad, changed input & UI
This commit is contained in:
@@ -18,7 +18,6 @@ namespace Assets.Scripts
|
||||
public GameObject amulet;
|
||||
public GameObject leftHand;
|
||||
public GameObject rightHand;
|
||||
public GameObject dragImage;
|
||||
public GameObject itemDisplay;
|
||||
|
||||
public GameObject[] bags;
|
||||
@@ -28,8 +27,9 @@ namespace Assets.Scripts
|
||||
|
||||
public int currentBag = -1;
|
||||
|
||||
GameObject startDrag;
|
||||
TooltipHandler tooltip;
|
||||
|
||||
public GameObject currentSlot;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
@@ -101,10 +101,10 @@ namespace Assets.Scripts
|
||||
{
|
||||
if (currentBag != -1)
|
||||
{
|
||||
bags[currentBag].transform.Find("Selected").GetComponent<RawImage>().color = Color.white;
|
||||
bags[currentBag].transform.parent.Find("Selected").GetComponent<RawImage>().color = Color.white;
|
||||
}
|
||||
currentBag = index;
|
||||
bags[currentBag].transform.Find("Selected").GetComponent<RawImage>().color = Color.cyan;
|
||||
bags[currentBag].transform.parent.Find("Selected").GetComponent<RawImage>().color = Color.cyan;
|
||||
checkInventoryColors();
|
||||
foreach(GameObject slot in slots)
|
||||
{
|
||||
@@ -177,41 +177,6 @@ namespace Assets.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
public void setDrag(GameObject slot)
|
||||
{
|
||||
startDrag = slot;
|
||||
}
|
||||
|
||||
public GameObject getDrag()
|
||||
{
|
||||
return startDrag;
|
||||
}
|
||||
|
||||
/*public Item getEquip(ItemPlace place)
|
||||
{
|
||||
switch (place)
|
||||
{
|
||||
case ItemPlace.LEFTHAND:
|
||||
return leftHand.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.RIGHTHAND:
|
||||
return rightHand.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.HELMET:
|
||||
return head.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.BOOTS:
|
||||
return feet.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.SHOULDER:
|
||||
return shoulders.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.AMULET:
|
||||
return amulet.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.RING:
|
||||
return ring.GetComponent<InventorySlot>().getEquip();
|
||||
case ItemPlace.ARMOR:
|
||||
return chest.GetComponent<InventorySlot>().getEquip();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}*/
|
||||
|
||||
public void calculateStatBoost(Dictionary<string, int> attributes, bool isAddition)
|
||||
{
|
||||
foreach (string key in attributes.Keys)
|
||||
@@ -382,12 +347,79 @@ namespace Assets.Scripts
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnMouseUp(){
|
||||
if(dragImage.GetComponent<RawImage>().texture != null){
|
||||
dragImage.GetComponent<RawImage>().color = new Color(0,0,0,0);
|
||||
dragImage.GetComponent<RawImage>().texture = null;
|
||||
dragImage.transform.position = new Vector3(0,0,0);
|
||||
|
||||
public void trashItem(){
|
||||
InventorySlot invSlot = currentSlot.GetComponent<InventorySlot>();
|
||||
if (invSlot.place == ItemPlace.BAG)
|
||||
{
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("collect", invSlot.getItem(invSlot.getCurrentBag()), -1);
|
||||
invSlot.removeItem();
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().updateQuests("collect", invSlot.getEquip(), -1);
|
||||
invSlot.removeEquip();
|
||||
}
|
||||
hideSlotOptions();
|
||||
}
|
||||
|
||||
public void equipItem(){
|
||||
InventorySlot invSlot = currentSlot.GetComponent<InventorySlot>();
|
||||
if(invSlot.place == ItemPlace.BAG){
|
||||
Equipment save = (Equipment)invSlot.getItem(currentBag);
|
||||
InventorySlot equipSlot;
|
||||
switch(save.getPlace()){
|
||||
case ItemPlace.HELMET:
|
||||
equipSlot = head.GetComponent<InventorySlot>();
|
||||
break;
|
||||
case ItemPlace.SHOULDER:
|
||||
equipSlot = shoulders.GetComponent<InventorySlot>();
|
||||
break;
|
||||
case ItemPlace.BOOTS:
|
||||
equipSlot = feet.GetComponent<InventorySlot>();
|
||||
break;
|
||||
case ItemPlace.AMULET:
|
||||
equipSlot = amulet.GetComponent<InventorySlot>();
|
||||
break;
|
||||
case ItemPlace.ARMOR:
|
||||
equipSlot = chest.GetComponent<InventorySlot>();
|
||||
break;
|
||||
case ItemPlace.RING:
|
||||
equipSlot = ring.GetComponent<InventorySlot>();
|
||||
break;
|
||||
case ItemPlace.RIGHTHAND:
|
||||
equipSlot = rightHand.GetComponent<InventorySlot>();
|
||||
break;
|
||||
case ItemPlace.LEFTHAND:
|
||||
equipSlot = leftHand.GetComponent<InventorySlot>();
|
||||
break;
|
||||
default:
|
||||
equipSlot = invSlot;
|
||||
break;
|
||||
}
|
||||
if(equipSlot.getEquip() != null){
|
||||
invSlot.setItem(equipSlot.getEquip(), currentBag);
|
||||
calculateStatBoost(equipSlot.getEquip().getAttributes(), false);
|
||||
}
|
||||
else{
|
||||
invSlot.removeItem();
|
||||
}
|
||||
equipSlot.setEquip(save);
|
||||
calculateStatBoost(equipSlot.getEquip().getAttributes(), true);
|
||||
}
|
||||
else{
|
||||
addItem(invSlot.getEquip());
|
||||
calculateStatBoost(invSlot.getEquip().getAttributes(), false);
|
||||
invSlot.removeEquip();
|
||||
}
|
||||
hideSlotOptions();
|
||||
}
|
||||
|
||||
public void hideSlotOptions(){
|
||||
GameObject.Find("pnlInventoryActions").transform.localScale = new Vector3(0,0,0);
|
||||
GameObject.Find("btnEquip").transform.Find("Text").GetComponent<Text>().text = "Equip";
|
||||
GameObject.Find("btnEquip").GetComponent<Button>().interactable = true;
|
||||
EventSystem.current.SetSelectedGameObject(currentSlot);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user