Ejemplo n.º 1
0
    public int[] items;                         // items array contain only the id of item that put in items array. if the slot contain empty item, the id is 0

    /*
     * UpdateOnload works for load function when player press f7 or click on load button when the panel shows up
     * it will read all data and fill in the necssary array that GUI inventory need
     */
    public void UpdateOnLoad()
    {
        for (int i = 0; i < 40; i++)
        {
            if (items[i] == 0)
            {
                continue;
            }
            Test_UIItemSlot_Assign item = gameslot[i].GetComponent <Test_UIItemSlot_Assign>();
            if (item == null)
            {
                gameslot[i].AddComponent <Test_UIItemSlot_Assign>();
                Test_UIItemSlot_Assign newitem = gameslot[i].GetComponent <Test_UIItemSlot_Assign>();
                newitem.slot         = gameslot[i].GetComponent <UIItemSlot>();
                newitem.itemDatabase = itemDatabase;
                newitem.assignItem   = items[i];
            }
            else
            {
                item.assignItem = items[i];
                UIItemSlot slot = gameslot[i].GetComponent <UIItemSlot>();
                slot.Assign(itemDatabase.GetByID(item.assignItem = items[i]));
            }
        }
    }
Ejemplo n.º 2
0
 //  updateslot()    update the gui items from backend array and use the item id in backend array to update the gui item
 public void updateSlot()
 {
     for (int i = 0; i < 40; i++)
     {
         //Debug.Log("FIRST ROW");
         Test_UIItemSlot_Assign item = gameslot[i].GetComponent <Test_UIItemSlot_Assign>();
         item.assignItem = Inventory.instance.items[i].itemID;
         UIItemSlot slot = gameslot[i].GetComponent <UIItemSlot>();
         slot.Assign(itemDatabase.GetByID(item.assignItem));
         //Debug.Log("update slot " + Inventory.instance.items[i].itemID);
     }
 }
Ejemplo n.º 3
0
 // add new item to the items array. if the item id is 0 which means its empty,
 //  fill in the additem into that slot
 public bool addNewItem(Item additem)
 {
     for (int i = 0; i < 40; i++)
     {
         Test_UIItemSlot_Assign item = gameslot[i].GetComponent <Test_UIItemSlot_Assign>();
         if (items[i] == 0)
         {
             //gameslot[i].AddComponent<Test_UIItemSlot_Assign>();
             //Test_UIItemSlot_Assign newitem = gameslot[i].GetComponent<Test_UIItemSlot_Assign>();
             //newitem.slot = gameslot[i].GetComponent<UIItemSlot>();
             //newitem.itemDatabase = itemDatabase;
             //newitem.assignItem = additem.itemID;
             items[i] = additem.itemID;
             UIItemSlot slot = gameslot[i].GetComponent <UIItemSlot>();
             slot.Assign(itemDatabase.GetByID(item.assignItem = items[i]));
             return(true);
         }
     }
     return(false);
 }