void RemoveStats(ItemSO equip) { if (!(equip is GearItemSO || equip is ToolItemSO)) { return; } gearCache = null; if (equip is GearItemSO) { gearCache = equip as GearItemSO; if (gearCache.equipstats.Length <= 0) { return; } for (int i = 0; i < gearCache.equipstats.Length; i++) { if (gearCache.equipstats[i].isPercentage) { GetPlayerStats.AddToStatValue(gearCache.equipstats[i].statType, -GetPlayerStats.GetStatValue(gearCache.equipstats[i].statType) * gearCache.equipstats[i].amount / 100); continue; } GetPlayerStats.AddToStatValue(gearCache.equipstats[i].statType, -gearCache.equipstats[i].amount); } } }
public bool UnEquipItem(ItemSlot item) { if (item == null || !(item.item is GearItemSO || item.item is ToolItemSO)) { return(false); } if (item.item is GearItemSO) { gearCache = null; gearCache = (item.item as GearItemSO); if (gearSlots[GetGearSlotIndex(gearCache.GetEquipType)] == null) { return(false); } RemoveStats(gearSlots[GetGearSlotIndex(gearCache.GetEquipType)].item); return(true); } else if (item.item is ToolItemSO) { if (toolSlots[GetToolSlotIndex((item.item as ToolItemSO).GetToolType)] == null) { return(false); } return(true); } return(false); }
private bool CheckIndexToGear(int index, GearItemSO gear) { if (index == GetGearSlotIndex(gear.GetEquipType)) { return(true); } return(false); }
public bool EquipItem(ItemSlot item) { if (item == null || !(item.item is GearItemSO || item.item is ToolItemSO)) { return(false); } if (item.item is GearItemSO) { gearCache = null; gearCache = (item.item as GearItemSO); if (gearSlots[GetGearSlotIndex(gearCache.GetEquipType)] != null) { RemoveStats(gearSlots[GetGearSlotIndex(gearCache.GetEquipType)].item); } ApplyStats(gearCache); return(true); } else if (item.item is ToolItemSO) { return(true); } return(false); { //int index = GetGearSlotIndex((equipSlotCache.item as GearItemSO).GetEquipType); //if (gearSlots[index] != null) // UnEquipItem(index); //else // inventory.GetInventoryFromDictionary(chestID)[buttonID] = null; //gearSlots[index] = equipSlotCache; //ApplyStats((gearSlots[index].item as GearItemSO)); //InventoryUIManager._instance.UpdatePlayerInventory(); //equipSlotCache = null; } }
// do unequip function to the outside will get itemslot and REMOVE THE FUNCTION #region Equips public void ResetEquip() { if (gearSlots != null && toolSlots != null) { for (int i = 0; i < gearSlots.Length; i++) { if (gearSlots[i] != null) { UnEquipItem(gearSlots[i]); } toolSlots[i] = null; } } inventory = Inventory.GetInstance; gearSlots = inventory.GetInventoryFromDictionary(2); toolSlots = inventory.GetInventoryFromDictionary(3); if (toolsActive == null) { toolsActive = new bool[toolSlots.Length]; } for (int i = 0; i < toolsActive.Length; i++) { toolsActive[i] = true; } equipSlotCache = null; gearCache = null; toolCache = null; }