public void UpdateEquipmentSlot(int uniqueId, EquipmentSlot eqSlot, Itemtype itemType) { ItemInventoryInstance invInstance = null; switch (itemType) { case Itemtype.Weapon: invInstance = SessionManager.Instance.GetWeaponItem(uniqueId); break; case Itemtype.Spell: break; case Itemtype.Consumable: invInstance = SessionManager.Instance.GetConsumableItem(uniqueId); break; case Itemtype.Equipment: break; default: break; } if (invInstance == null) { return; } Item item = ResourcesManager.Instance.GetItem(invInstance.itemId, itemType); eqSlot.iconBase.icon.sprite = item.itemIcon; eqSlot.iconBase.icon.enabled = true; eqSlot.iconBase.id = invInstance.uniqueId; }
void InitEmptyItems() { unarmedItem = new ItemInventoryInstance(); unarmedItem.itemId = "Unarmed"; unarmedItem.uniqueId = -1; emptyItem = new ItemInventoryInstance(); emptyItem.itemId = "empty"; emptyItem.uniqueId = -1; }
void LoadConsumableItem(ResourcesManager resManager) { if (currentInvIcon == null) { return; } ItemInventoryInstance invInstance = session.GetConsumableItem(currentInvIcon.id); string itemID = invInstance.itemId; Item item = resManager.GetItem(itemID, Itemtype.Consumable); equipment_Left.currentItem.text = item.name_item; }
void LoadWeaponItem(ResourcesManager resManager, IconBase icon) { ItemInventoryInstance invInstance = session.GetWeaponItem(icon.id); string weaponID = invInstance.itemId; WeaponStats weaponStats = resManager.GetWeaponStats(weaponID); Item item = resManager.GetItem(weaponID, Itemtype.Weapon); equipment_Left.currentItem.text = item.name_item; //Update Center Overlay UI Panel UpdateCenterOverlay(item); center_Overlay.skillName.text = weaponStats.skillName; //Center Main UI weaponInfo.smallIcon.sprite = item.itemIcon; weaponInfo.itemName.text = item.name_item; weaponInfo.weaponType.text = weaponStats.weaponType; weaponInfo.damageType.text = weaponStats.damageType; weaponInfo.skillName.text = weaponStats.skillName; weaponInfo.weightCost.text = weaponStats.weightCost.ToString(); //Update the min durability!!! weaponInfo.durability_Min.text = weaponInfo.durability_Max.ToString(); weaponInfo.durability_Max.text = weaponInfo.durability_Max.ToString(); //Attack Power UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Physical, weaponStats.attackPhysical.ToString()); UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Magic, weaponStats.attackMagic.ToString()); UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Fire, weaponStats.attackFire.ToString()); UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Lightning, weaponStats.attackLigthning.ToString()); UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Dark, weaponStats.attackDark.ToString()); UpdateAttackDefenseUIElement(weaponInfo.attackPowerSlots, AttackDefenseType.Critical, weaponStats.attackCritical.ToString()); UpdateAttackDefenseUIElement(weaponInfo.additionalEffects, AttackDefenseType.Frost, weaponStats.attackFrost.ToString(), true); UpdateAttackDefenseUIElement(weaponInfo.additionalEffects, AttackDefenseType.Curse, weaponStats.attackCurse.ToString(), true); //UpdateAttackDefenseUIElement(weaponInfo.additionalEffects, AttackDefenseType.Poison, weaponStats.poisonDamage.ToString()); //UpdateAttackDefenseUIElement(weaponInfo.additionalEffects, AttackDefenseType.Bleed, weaponStats.frostDamage.ToString(), true); //Guard Absorptions UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Physical, weaponStats.defensePhysical.ToString()); UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Magic, weaponStats.defenseMagic.ToString()); UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Fire, weaponStats.defenseFire.ToString()); UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Lightning, weaponStats.defenseLigthning.ToString()); UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Dark, weaponStats.defenseDark.ToString()); UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Dark, weaponStats.defenseDark.ToString()); UpdateAttackDefenseUIElement(weaponInfo.guardAbsorptions, AttackDefenseType.Stability, weaponStats.defenseStability.ToString()); }
public void AddItem(string itemID, Itemtype type) { switch (type) { case Itemtype.Weapon: weaponItemList.Add(itemID); ItemInventoryInstance invItem = new ItemInventoryInstance(); invItem.itemId = itemID; invItem.uniqueId = max_Weapon_Item_Index; max_Weapon_Item_Index++; _weapon_items.Add(invItem); break; case Itemtype.Spell: break; case Itemtype.Consumable: ItemInventoryInstance consumableItem = new ItemInventoryInstance(); consumableItem.itemId = itemID; consumableItem.uniqueId = max_Consumable_Item_Index; max_Consumable_Item_Index++; _consumable_items.Add(consumableItem); break; case Itemtype.Equipment: AddArmorItem(itemID); break; default: break; } Item item = resourcesManager.GetItem(itemID, type); UIManager.Instance.AddAnnounceCard(item); }
void UpdateItemSlotInfo(ResourcesManager resManager, IconBase iconBase, Itemtype itemtype) { ItemInventoryInstance invInstance = null; if (!centerOverlayIsOpen) { centerOverlay.SetActive(false); } centerOverlay.SetActive(false); switch (itemtype) { case Itemtype.Spell: break; case Itemtype.Consumable: invInstance = session.GetConsumableItem(iconBase.id); centerOverlay.SetActive(true); break; case Itemtype.Equipment: //invInstance = session.GetArmorItem(iconBase.id); centerOverlay.SetActive(true); break; default: break; } string itemID = invInstance.itemId; Item item = resManager.GetItem(itemID, itemtype); UpdateCenterOverlay(item); equipment_Left.currentItem.text = item.name_item; }
void Awake() { Instance = this; InitEmptyItems(); resourcesManager.PreInit(); inventoryUI.PreInit(); for (int i = 0; i < rightHand_Weapons_Equipped.Count; i++) { weaponItemList.Add(rightHand_Weapons_Equipped[i]); } for (int i = 0; i < leftHand_Weapons_Equipped.Count; i++) { weaponItemList.Add(leftHand_Weapons_Equipped[i]); } for (int i = 0; i < consumables_Equipped.Count; i++) { consumableItemList.Add(consumables_Equipped[i]); } for (int i = 0; i < weaponItemList.Count; i++) { ItemInventoryInstance invItem = new ItemInventoryInstance(); invItem.itemId = weaponItemList[i]; invItem.uniqueId = max_Weapon_Item_Index; max_Weapon_Item_Index++; _weapon_items.Add(invItem); } for (int i = 0; i < rightHand_Weapons_Equipped.Count; i++) { ItemInventoryInstance it = StringToInID(_weapon_items, rightHand_Weapons_Equipped[i]); _equipped_RightHand.Add(it.uniqueId); it.slot = inventoryUI.equipmentSlotsUI.GetWeaponSlot(i); it.equip_Index = i; } for (int i = 0; i < leftHand_Weapons_Equipped.Count; i++) { ItemInventoryInstance it = StringToInID(_weapon_items, leftHand_Weapons_Equipped[i]); _equipped_LeftHand.Add(it.uniqueId); int targetIndex = i + 3; it.slot = inventoryUI.equipmentSlotsUI.GetWeaponSlot(targetIndex); it.equip_Index = targetIndex; } for (int i = 0; i < consumableItemList.Count; i++) { ItemInventoryInstance invItem = new ItemInventoryInstance(); invItem.itemId = consumableItemList[i]; invItem.uniqueId = max_Consumable_Item_Index; max_Consumable_Item_Index++; _consumable_items.Add(invItem); } for (int i = 0; i < consumables_Equipped.Count; i++) { ItemInventoryInstance it = StringToInID(_consumable_items, consumables_Equipped[i]); _equipped_Consumables.Add(it.uniqueId); it.slot = inventoryUI.equipmentSlotsUI.GetConsumableSlot(i); it.equip_Index = i; } //NPC States for (int i = 0; i < npcStates.Length; i++) { npc_IDs.Add(npcStates[i].NPCId, i); } }
public void LoadInventory(bool updateActions = false) { SessionManager sessionManger = SessionManager.Instance; unarmedRunTimeWeapon = WeaponToRuntimeWeapon(ResourcesManager.Instance.GetWeapon(unarmedId), false); unarmedRunTimeWeapon.isUnarmed = true; //3 --> number of equipment slots in inventory for (int i = 0; i < 3; i++) { runtime_Right_Weapons.Add(unarmedRunTimeWeapon); runtime_Left_Weapons.Add(unarmedRunTimeWeapon); } //There are 10 slots for consumables in inventory for (int i = 0; i < 10; i++) { runtime_Consumables.Add(emptyItem); } for (int i = 0; i < rightHandWeapons.Count; i++) { if (rightHandWeapons[i] == -1) { runtime_Right_Weapons[i] = unarmedRunTimeWeapon; } else { ItemInventoryInstance invInstance = sessionManger.GetWeaponItem(rightHandWeapons[i]); RuntimeWeapon weapon = WeaponToRuntimeWeapon(ResourcesManager.Instance.GetWeapon(invInstance.itemId)); runtime_Right_Weapons[i] = weapon; } } for (int i = 0; i < leftHandWeapons.Count; i++) { if (leftHandWeapons[i] == -1) { runtime_Left_Weapons[i] = unarmedRunTimeWeapon; } else { ItemInventoryInstance invInstance = sessionManger.GetWeaponItem(leftHandWeapons[i]); RuntimeWeapon weapon = WeaponToRuntimeWeapon(ResourcesManager.Instance.GetWeapon(invInstance.itemId), true); runtime_Left_Weapons[i] = weapon; } } for (int i = 0; i < spellItems.Count; i++) { SpellToRuntimeSpell(ResourcesManager.Instance.GetSpell(spellItems[i])); } emptyItem = ConsumableToRunTime(ResourcesManager.Instance.GetConsumable("empty")); emptyItem.isEmpty = true; //Consumables for (int i = 0; i < consumableItems.Count; i++) { if (consumableItems[i] == -1) { runtime_Consumables[i] = emptyItem; } else { ItemInventoryInstance invInstance = sessionManger.GetConsumableItem(consumableItems[i]); RuntimeConsumableItem runtimeConsumable = ConsumableToRunTime(ResourcesManager.Instance.GetConsumable(invInstance.itemId)); runtime_Consumables[i] = runtimeConsumable; } } InitAllDamageColliders(states); CloseAllDamageColliders(); MakeIndexesList(); EquipInventory(); if (updateActions) { states.actionManager.UpdateActionsOneHanded(); } }
public void LoadEquipment(InventoryManager inv, bool loadOnCharacter = false) { if (loadOnCharacter) { inv.ClearReferences(); } #region Load Right Hand Weapons //Load Right Hand weapons for (int i = 0; i < inv.rightHandWeapons.Count; i++) { //Clamp = no more than 3 items (thats how much slot we have for RightHand Weapons) if (i > 2) { break; } EquipmentSlot eqSlot = equipmentSlotsUI.weaponSlots[i]; if (inv.rightHandWeapons[i] == -1) { equipmentSlotsUI.ClearEquipmentSlot(eqSlot, Itemtype.Weapon); } else { ItemInventoryInstance item = session.GetWeaponItem(inv.rightHandWeapons[i]); item.slot = eqSlot; item.equip_Index = i; equipmentSlotsUI.UpdateEquipmentSlot(item.uniqueId, eqSlot, Itemtype.Weapon); } } #endregion #region Load Left Hand Weapons //Load Left Hand weapons for (int i = 0; i < inv.leftHandWeapons.Count; i++) { //Clamp = no more than 3 items (thats how much slot we have for RightHand Weapons) if (i > 2) { break; } //i+3 -- > Left side index starts after 3 slots of right hand weapons EquipmentSlot eqSlot = equipmentSlotsUI.weaponSlots[i + 3]; if (inv.leftHandWeapons[i] == -1) { equipmentSlotsUI.ClearEquipmentSlot(eqSlot, Itemtype.Weapon); } else { ItemInventoryInstance item = session.GetWeaponItem(inv.leftHandWeapons[i]); item.slot = eqSlot; item.equip_Index = i + 3; equipmentSlotsUI.UpdateEquipmentSlot(item.uniqueId, eqSlot, Itemtype.Weapon); } } #endregion #region Load Consumable Items //Load Consumable items for (int i = 0; i < inv.consumableItems.Count; i++) { //Clamp = no more than 3 items (thats how much slot we have for RightHand Weapons) if (i > 9) { break; } EquipmentSlot eqSlot = equipmentSlotsUI.consumableSlots[i]; if (inv.consumableItems[i] == -1) { equipmentSlotsUI.ClearEquipmentSlot(eqSlot, Itemtype.Consumable); } else { ItemInventoryInstance item = session.GetConsumableItem(inv.consumableItems[i]); item.slot = eqSlot; item.equip_Index = i; equipmentSlotsUI.UpdateEquipmentSlot(item.uniqueId, eqSlot, Itemtype.Consumable); } } #endregion if (loadOnCharacter) { inv.LoadInventory(true); } }
void HandleSlotInput(InputUI inputUI) { if (currentEqSlot == null) { return; } #region X Input --> Switching if (inputUI.x_input) { isSwitching = !isSwitching; Debug.Log("Changed is switching to : " + isSwitching); if (isSwitching) { Itemtype type = ItemTypeFromSlotType(currentEqSlot.eqSlotType); LoadCurrentItems(type); } else { Itemtype type = ItemTypeFromSlotType(currentEqSlot.eqSlotType); if (type == Itemtype.Weapon) { int targetIndex = currentEqSlot.itemPosition; //If slot index is greater than 2, it is left hand weapon, //since first 3 slots belong to right hand weapons bool isLeft = (currentEqSlot.itemPosition > 2) ? true : false; if (isLeft) { targetIndex -= 3; invManager.leftHandWeapons[targetIndex] = currentInvIcon.id; ItemInventoryInstance invInstance = session.GetWeaponItem(invManager.leftHandWeapons[targetIndex]); if (invInstance.slot != null) { equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Weapon); ClearOnIndex(invInstance.equip_Index); } } else { invManager.rightHandWeapons[targetIndex] = currentInvIcon.id; ItemInventoryInstance invInstance = session.GetWeaponItem(invManager.rightHandWeapons[targetIndex]); if (invInstance.slot != null) { equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Weapon); ClearOnIndex(invInstance.equip_Index); } } } else { ItemInventoryInstance invInstance = session.GetConsumableItem(invManager.consumableItems[currentEqSlot.itemPosition]); if (invInstance.slot != null) { equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Consumable); //Set as empty item invManager.consumableItems[invInstance.equip_Index] = -1; } invManager.consumableItems[currentEqSlot.itemPosition] = currentInvIcon.id; } LoadEquipment(invManager, true); } ChangeToSwitching(); } #endregion //b --> back button if (inputUI.b_input) { if (isSwitching) { isSwitching = false; ChangeToSwitching(); } else { isMenu = false; CloseUI(); } } #region Y Input if (inputUI.y_input) { if (isSwitching) { centerOverlayIsOpen = !centerOverlayIsOpen; centerOverlay.SetActive(centerOverlayIsOpen); } else { Itemtype type = ItemTypeFromSlotType(currentEqSlot.eqSlotType); if (type == Itemtype.Weapon) { int targetIndex = currentEqSlot.itemPosition; bool isLeft = (currentEqSlot.itemPosition > 2) ? true : false; if (isLeft) { targetIndex -= 3; invManager.leftHandWeapons[targetIndex] = -1; ItemInventoryInstance invInstance = session.GetWeaponItem(invManager.leftHandWeapons[targetIndex]); if (invInstance.slot != null) { equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Weapon); } } else { invManager.rightHandWeapons[targetIndex] = -1; ItemInventoryInstance invInstance = session.GetWeaponItem(invManager.rightHandWeapons[targetIndex]); if (invInstance.slot != null) { equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Weapon); } } } else if (type == Itemtype.Consumable) { int targetIndex = currentEqSlot.itemPosition; if (targetIndex < invManager.consumableItems.Count) { invManager.consumableItems[currentEqSlot.itemPosition] = -1; ItemInventoryInstance invInstance = session.GetConsumableItem(invManager.consumableItems[targetIndex]); if (invInstance.slot != null) { equipmentSlotsUI.ClearEquipmentSlot(invInstance.slot, Itemtype.Consumable); } } } LoadEquipment(invManager, true); } } #endregion }