public void LoadEquipment(InventoryManager inv) { for (int i = 0; i < inv.rh_weapons.Count; i++) { if (i > 2) { break; } EquipmentUISlot slot = equipSlotsUI.weapon[i]; equipSlotsUI.UpdateEqSlot(inv.rh_weapons[i], slot, ItemType.weapon); } for (int i = 0; i < inv.lh_weapons.Count; i++) { if (i > 2) { break; } EquipmentUISlot slot = equipSlotsUI.weapon[i + 3]; equipSlotsUI.UpdateEqSlot(inv.lh_weapons[i], slot, ItemType.weapon); } for (int i = 0; i < inv.consumable_items.Count; i++) { if (i > 9) { break; } EquipmentUISlot slot = equipSlotsUI.cons[i]; equipSlotsUI.UpdateEqSlot(inv.consumable_items[i], slot, ItemType.consum); } }
public void UpdateEqSlot(string itemId, EquipmentUISlot s, ItemType itemType) { Item item = ResourcesManager.singleton.GetItem(itemId, itemType); s.icon.icon.sprite = item.icon; s.icon.icon.enabled = true; s.icon.id = item.item_id; }
void Update() { if (load) { LoadEquipment(invManager); prevEqSlot = null; load = false; } HandleSlotMovement(); if (prevEqSlot != curEqSlot) { LoadItemFromSlot(); } prevEqSlot = curEqSlot; }
public void AddSlotOnList(EquipmentUISlot eq) { switch (eq.slotType) { case EqSlotType.weapons: weapon.Add(eq); break; case EqSlotType.arrows: arrow.Add(eq); break; case EqSlotType.bolts: bolt.Add(eq); break; case EqSlotType.equipment: equipment.Add(eq); break; case EqSlotType.rings: ring.Add(eq); break; case EqSlotType.covenant: covenant = eq; break; case EqSlotType.consumables: cons.Add(eq); break; default: break; } }
void HandleSlotMovement() { int x = Mathf.RoundToInt(curSlotPos.x); int y = Mathf.RoundToInt(curSlotPos.y); bool up = (Input.GetAxis(StaticStrings.Vertical) > 0); bool down = (Input.GetAxis(StaticStrings.Vertical) < 0); bool left = (Input.GetAxis(StaticStrings.Horizontal) < 0); bool right = (Input.GetAxis(StaticStrings.Horizontal) > 0); if (!up && !down && !left && !right) { inputTimer = 0; } else { inputTimer -= Time.deltaTime; } if (inputTimer < 0) { inputTimer = 0; } if (inputTimer > 0) { return; } if (up) { inputTimer = inputDelay; y--; } if (down) { inputTimer = inputDelay; y++; } if (left) { inputTimer = inputDelay; x--; } if (right) { inputTimer = inputDelay; x++; } if (x > 4) { x = 0; } if (x < 0) { x = 4; } if (y > 5) { y = 0; } if (y < 0) { y = 5; } if (curEqSlot) { curEqSlot.icon.background.color = unselected; } if (x == 4 && y == 3) { x = 4; y = 2; } curEqSlot = equipSlots[x, y]; curSlotPos.x = x; curSlotPos.y = y; if (curEqSlot) { curEqSlot.icon.background.color = selected; } }