Example #1
0
    void Awake()
    {
        itemDB = FindObjectOfType<itemDatabase>();
        if(item == null && itemID != "")
        {
            item = new itemBase(itemDB.getItemWithID(itemID));
            item.Quality = quality;
            item.Start();
        }

        if(item != null)
        {
            itemID = item.ID;
        }
    }
Example #2
0
    public itemBase(itemBase item)
    {
        ID = item.ID;
        Name = item.Name;
        Desc = item.Desc;
        Icon = item.Icon;
        Weight = item.Weight;
        Height = item.Height;
        Width = item.Width;

        Quality = item.Quality;

        if(item.Icon == null)
        {
            Icon = Resources.Load<Sprite>("icon_missing");
        }
        else
        {
            Icon = item.Icon;
        }
    }
Example #3
0
    public bool CheckRoomForItem(int x, int y, itemBase item)
    {
        if (x + item.Width > Cols)
        {
          //  Debug.Log("Out of X bounds");
            return false;
        }
        else if (y + item.Height > Rows)
        {
           // Debug.Log("Out of Y bounds");
            return false;
        }

        for (int sY = y; sY < item.Height + y; sY++)
        {
            for (int sX = x; sX < item.Width + x; sX++)
            {
                //                print(equipment.slots[sX, sY].isOcupied);

                if (Slots[sX, sY].Occupied)
                {
                   // Debug.Log("breaks " + x + " , " + "y");
                    return false;
                }
            }
        }

        //Debug.Log("comes" + x + " , " + y);
        //item.x = x;
        //item.y = y;

        //player.inventory.Add(item);
        //equipment.itemInSlot.equipment.itemsStored.Add(item);

        Items.Add(item);

        int slotnum = 0; // add this here to indicate what slot the item is on when making them active
        List<slotScript> additionalSlots = new List<slotScript>();
        for (int sY = y; sY < item.Height + y; sY++)
        {
            for (int sX = x; sX < item.Width + x; sX++)
            {

                if (item.Height > 1 || item.Width > 1)// here is where it checks if the item is bigger than 1*1 and what the slotnum is so that it can make the rest of the buttons inactive
                {
                    if (slotnum >= 1)
                    {
                        //                        print("slot not 1");
                        Slots[sX, sY].Active = false;// you will need to add a public bool named active on the slotscript and get the game object that is associated with that button and set it inactive
                        additionalSlots.Add(Slots[sX, sY]);
                    }
                    else
                    {
                        Slots[sX, sY].AttachedSlots = additionalSlots;
                    }
                    slotnum++;// adds to indicate next slot
                }

                Slots[sX, sY].Occupied = true;
                Slots[sX, sY].Item = item;
                // print(slots[sX, sY] + " should be occupied");

            }
        }
        return true;
    }
Example #4
0
    public bool CheckAvailableSlots(itemBase item)
    {
        for (int y = 0; y < Rows; y++)
        {
            for (int x = 0; x < Cols; x++)
            {
                if (CheckRoomForItem(x, y, item))
                {
                    return true;
                }

            }

        }

        GlobalSettings.PrintDebug("No room for " + item.Name + "("+item.Height+"x"+item.Width+")");
        return false;
    }