Exemplo 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]));
            }
        }
    }
Exemplo n.º 2
0
    // add item to vendor inventory and numbers of item generate will be random
    // clear item for every time player interact with NPC
    private void setItemInSlots(int pre, int end)
    {
        for (int i = 0; i < 40; i++)
        {
            slots[i].GetComponent <UIItemSlot>().Assign(itemDatabase.GetByID(0));
            slots[i].GetComponent <Test_UIItemSlot_Assign>().assignItem = 0;
        }
        int k = Random.Range(1, 10);
        int tmp;// = Random.Range(pre, end);

        for (int i = 0; i < k; i++)
        {
            tmp = Random.Range(pre, end);
            slots[i].GetComponent <UIItemSlot>().Assign(itemDatabase.GetByID(tmp));
            slots[i].GetComponent <Test_UIItemSlot_Assign>().assignItem = tmp;
        }
    }
Exemplo n.º 3
0
    // when player is load between scene or just load manaully,
    //  this function will read the gem id array from the array that contain the gem id
    public void UpdateGemOnload()
    {
        Test_UIEquipSlot_Assign equipment;
        UIEquipSlot             slot;

        for (int i = 0; i < 4; i++)
        {
            equipment            = SkillAOE[i].GetComponent <Test_UIEquipSlot_Assign>();
            equipment.assignItem = SkillAOE_IDs[i];
            slot = SkillAOE[i].GetComponent <UIEquipSlot>();
            slot.Assign(UIItemdatabase.GetByID(equipment.assignItem));
        }
        for (int i = 0; i < 5; i++)
        {
            equipment            = SkillProjectile[i].GetComponent <Test_UIEquipSlot_Assign>();
            equipment.assignItem = SkillProjectile_IDs[i];
            slot = SkillProjectile[i].GetComponent <UIEquipSlot>();
            slot.Assign(UIItemdatabase.GetByID(equipment.assignItem));
        }
        for (int i = 0; i < 6; i++)
        {
            equipment            = SkillDash[i].GetComponent <Test_UIEquipSlot_Assign>();
            equipment.assignItem = SkillDash_IDs[i];
            slot = SkillDash[i].GetComponent <UIEquipSlot>();
            slot.Assign(UIItemdatabase.GetByID(equipment.assignItem));
        }
    }