Esempio n. 1
0
 /// <summary>
 /// 全部合成点击
 /// </summary>
 private void CraftAllClick()
 {
     SendMessageUpwards("CalcMinMaterial");
     Debug.Log("全部合成");
     Debug.Log("最小数是:" + min);
     for (int i = 0; i < min; i++)
     {
         GameObject go = Instantiate <GameObject>(newItem);
         //设置父物体
         go.transform.SetParent(goodItem_Transform);
         //查找组件,预制体上面有了
         InventoryItemManager iim = go.GetComponent <InventoryItemManager>();
         //设置初始值
         iim.SetItemValue(tempSpriteName, tempId, 1, 1);
         //重置位置
         go.GetComponent <RectTransform>().localPosition = Vector3.zero;
         //重置大小
         iim.ResetSpriteSize(go.GetComponent <RectTransform>(), 110, 110);
         //不在背包里
         iim.IsInventory = false;
     }
     //结果槽显示数量
     CraftResultNum();
     //向C层发送消息
     SendMessageUpwards("CraftingAllOK");
 }
Esempio n. 2
0
    /// <summary>
    /// 单个合成点击
    /// </summary>
    private void CraftClick()
    {
        SendMessageUpwards("CalcMinMaterial");
        Debug.Log("单个合成");
        GameObject go = Instantiate <GameObject>(newItem);

        //设置父物体
        go.transform.SetParent(goodItem_Transform);
        //查找组件,预制体上面有了
        InventoryItemManager iim = go.GetComponent <InventoryItemManager>();

        //设置初始值
        iim.SetItemValue(tempSpriteName, tempId, 1, 1);
        //重置位置
        go.GetComponent <RectTransform>().localPosition = Vector3.zero;
        //重置大小
        iim.ResetSpriteSize(go.GetComponent <RectTransform>(), 110, 110);
        //不在背包里
        iim.IsInventory = false;
        //变为普通按钮
        //NorCraft();
        //结果槽显示数量
        CraftResultNum();
        Debug.Log("结果槽里面" + go.GetComponent <InventoryItemManager>().ToString());
        //向C层发送消息
        SendMessageUpwards("CraftingOK");
    }
    /// <summary>
    /// 创建所有的Item
    /// </summary>
    private void CreateAllItem()
    {
        List <InventoryItem> jsonItemList = inventoryPanelModel.GetJsonByName("InventoryJsonData");

        for (int i = 0; i < jsonItemList.Count; i++)
        {
            GameObject item = Instantiate(inventoryPanelView.InventoryItem, slotList[i].transform);
            itemList.Add(item);
            InventoryItemManager manager = item.GetComponent <InventoryItemManager>();
            manager.SetItemValue(jsonItemList[i].ItemName, jsonItemList[i].ItemId, jsonItemList[i].ItemNum, jsonItemList[i].ItemBar);
        }
    }