示例#1
0
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        if (!phase1Init)
        {
            CmdFetchPlayerInfo();
            phase1Init = true;
            return;
        }

        if (!phase2Init)
        {
            if (info == null)
            {
                return;
            }

            beltUI = GameObject.FindGameObjectWithTag("ItemBar").GetComponent <BeltInventoryUI> ();
            beltUI.loadInventory(info.belt);


            backpackUI = GameObject.FindGameObjectWithTag("BackpackUI").GetComponent <BackpackInventoryUI> ();
            equipUI    = GameObject.FindGameObjectWithTag("EquipUI").GetComponent <EquipMenuUI> ();
            if (info.backpack != null)
            {
                backpackUI.loadInventory(info.backpack.inventory);
            }

            equipUI.updateUI(info);

            phase2Init = true;
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            int  slotNum = beltUI.getSelectedSlotNumber();
            Item item    = info.belt.getSlots() [slotNum].getItem();
            if (item != null)
            {
                CmdUseItem(slotNum, MessageUtil.ToArray(item));
            }
        }
    }