Exemplo n.º 1
0
    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);
            }
        }
    }
Exemplo n.º 2
0
    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);
    }
Exemplo n.º 3
0
    private bool CheckIndexToGear(int index, GearItemSO gear)
    {
        if (index == GetGearSlotIndex(gear.GetEquipType))
        {
            return(true);
        }

        return(false);
    }
Exemplo n.º 4
0
    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;
        }
    }
Exemplo n.º 5
0
    // 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;
    }