Esempio n. 1
0
    public void AddItem(CommonDefine.GoodType goodType, int num = 0)
    {
        if (num > 0)
        {
            for (int i = 0; i < cells.Length; i++)
            {
                if (cells[i].transform.childCount > 0)
                {
                    InventoryItemView inventoryItem = cells[i].GetComponentInChildren <InventoryItemView>();
                    if (inventoryItem.m_goodType == goodType)
                    {
                        m_isFind = true;
                        inventoryItem.AddCount(num);
                        break;
                    }
                }
                else
                {
                    m_isFind = false;
                }
            }

            if (!m_isFind)
            {
                for (int j = 0; j < cells.Length; j++)
                {
                    if (cells[j].transform.childCount == 0)
                    {
                        GameObject go = NGUITools.AddChild(cells[j], (GameObject)ResMgr.Instance.LoadAssetFromResource("Prefabs/UI/Inventory/InventoryItem"));
                        go.GetComponent <UISprite>().spriteName = CommonDefine.GoodNameDic[goodType];
                        go.transform.localPosition = Vector3.zero;
                        InventoryItemView dragObjTemp = go.GetComponentInChildren <InventoryItemView>();
                        dragObjTemp.m_goodType = goodType;
                        dragObjTemp.AddCount(num);
                        break;
                    }
                }
            }
        }
    }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 public virtual void DealWith(CommonDefine.GoodType goodType)
 {
 }