예제 #1
0
    /// <summary>
    /// 生成所有物品.
    /// </summary>
    void CreateAllItem()
    {
        List <InventoryItem> itemList = _inventoryPanelModel.GetJsonList("InventoryJsonData");

        for (int i = 0; i < itemList.Count; i++)
        {
            GameObject.Instantiate <GameObject>(_inventoryPanelView.ItemPrefab, slotList[i].GetComponent <Transform>());
        }
    }
예제 #2
0
    /// <summary>
    /// 创建人物背包物品
    /// </summary>
    private void CreateALLItem()
    {
        //测试数据

        /*List<InventoryItem> tempList = new List<InventoryItem>
         * {
         *  new InventoryItem("Torch", 50),
         *  new InventoryItem("Axe", 79),
         *  new InventoryItem("Arrow", 99)
         * };
         */
        List <InventoryItem> tempList = inventoryPanelModel.GetJsonList("InventoryJsonData");

        for (int i = 0; i < tempList.Count; i++)
        {
            GameObject tempItem = GameObject.Instantiate(inventoryPanelView.PrefabItem, slotLists[i].GetComponent <Transform>());
            tempItem.GetComponent <InventoryItemController>().InitItem(tempList[i].ItemName, tempList[i].ItemNum, tempList[i].ItemId, tempList[i].ItemBar);
        }
    }