Exemplo n.º 1
0
    public void slotClicked(InvStack slot)
    {
        if (!selectedOne) {
            selectedOne = slot;
            ItemPanel.weapon = selectedOne.item;
            selectedOne.GetComponent<Image> ().color = selectedColour;
            if (selectedOne.GetComponent<ArmourSlot> ())
                armourSwitching = true;
        } else if (selectedOne && !selectedTwo) {
            selectedTwo = slot;
            bool skip = false;
            if (selectedTwo.GetComponent<ArmourSlot> () && !armourSwitching) {
                int tempint = System.Array.IndexOf(Slots, selectedOne.GetComponent<Button>());
                int tempint2 = System.Array.IndexOf(Slots, selectedTwo.GetComponent<Button>());
                selectedOne = Slots[tempint2].GetComponent<InvStack>();
                selectedTwo = Slots[tempint].GetComponent<InvStack>();
                armourSwitching = true;
            }
            else if (selectedTwo.GetComponent<ArmourSlot>() && armourSwitching) {
                skip = true;
            }

            if (selectedTwo.GetComponent<ArmourSlot>() && (selectedTwo.GetComponent<ArmourSlot>() && selectedTwo.item is Item_Armour && ((Item_Armour)selectedTwo.item).lvlMin > XP.Level || selectedOne.GetComponent<ArmourSlot>() || selectedOne.item is Item_Armour && ((Item_Armour)selectedOne.item).lvlMin > XP.Level) ||
            selectedOne.GetComponent<ArmourSlot>() && (selectedTwo.GetComponent<ArmourSlot>() || selectedTwo.item is Item_Armour && ((Item_Armour)selectedTwo.item).lvlMin > XP.Level || selectedOne.GetComponent<ArmourSlot>() && selectedOne.item is Item_Armour && ((Item_Armour)selectedOne.item).lvlMin > XP.Level)) {
                skip = true;
            }
            Item tempData_Item = selectedTwo.item;
            int tempData_amt = selectedTwo.amount;
            if(!skip && (!armourSwitching || selectedTwo.item == ItemDB.Weapons[0] || selectedTwo.item == null || armourSwitching && selectedTwo.item is Item_Armour && selectedOne.GetComponent<ArmourSlot>().Type == ((Item_Armour)selectedTwo.item).Type))
            {
                selectedTwo.item = selectedOne.item;
                selectedOne.item = tempData_Item;
                selectedTwo.amount = selectedOne.amount;
                selectedOne.amount = tempData_amt;
                selectedOne.UpdateIcon ();
                selectedTwo.UpdateIcon ();
            }
            selectedOne.GetComponent<Image> ().color = Color.white;
            selectedTwo.GetComponent<Image> ().color = Color.white;
            selectedOne = null;
            selectedTwo = null;
            armourSwitching = false;
            selectHotbarSlot (CurrentHotbarSlot, false);
            Player.RecalcArmour();
        }
    }
Exemplo n.º 2
0
 public void DropItem(InvStack slot, int amount = 1, bool justDelete = false)
 {
     amount = Mathf.Clamp (amount, 1, slot.amount);
     slot.amount -= amount;
     if (!justDelete) {
         for (int i = 0; i < amount; i++) {
             DroppedItem droppedItem = ((GameObject)Instantiate (ItemDB.droppedItem, Camera.main.transform.position, transform.rotation)).GetComponent<DroppedItem> ();
             droppedItem.item = slot.item;
             droppedItem.GetComponent<Rigidbody> ().AddForce ((transform.forward + transform.up) * 5f, ForceMode.VelocityChange);
             droppedItem.StartCoroutine (droppedItem.TriggerWait (1f));
         }
     }
     if (slot.amount <= 0) {
         slot.item = ItemDB.Weapons[0];
         slot.amount = 1;
         slot.UpdateIcon();
         selectHotbarSlot (CurrentHotbarSlot, false);
     }
 }
Exemplo n.º 3
0
 public void toggleInv(bool open)
 {
     InvPanel.SetActive (open);
     if (selectedOne) {
         selectedOne.GetComponent<Image> ().color = Color.white;
         if (selectedTwo)
             selectedTwo.GetComponent<Image> ().color = Color.white;
         selectedOne = null;
         selectedTwo = null;
         armourSwitching = false;
         selectHotbarSlot (CurrentHotbarSlot, false);
     }
     if(open)
         RecalcSlots ();
 }
Exemplo n.º 4
0
    void Update()
    {
        if (Input.mouseScrollDelta.y > 0) {
            selectHotbarSlot(1, true);
        } else if (Input.mouseScrollDelta.y < 0) {
            selectHotbarSlot(-1, true);
        }

        if (selectedOne && Input.GetKeyDown (KeyCode.Q)) {
            selectedOne.GetComponent<Image> ().color = Color.white;
            if(selectedTwo)
                selectedTwo.GetComponent<Image> ().color = Color.white;
            InvStack tempselected = selectedOne;
            selectedOne = null;
            selectedTwo = null;
            armourSwitching = false;
            DropItem (tempselected);
            selectHotbarSlot (CurrentHotbarSlot, false);
        }
    }
Exemplo n.º 5
0
	void Start() {
		slot = GetComponent<InvStack> ();
	}