示例#1
0
    void ShowItemList(uint itemBaseId)
    {
        List <BaseItem> itemdataList = new List <BaseItem>();

        List <BaseItem> itemdataList1 = DataManager.Manager <ItemManager>().GetItemByBaseId(itemBaseId, GameCmd.PACKAGETYPE.PACKAGETYPE_MAIN);

        itemdataList.AddRange(itemdataList1);

        table.ItemDataBase itemdb = GameTableManager.Instance.GetTableItem <table.ItemDataBase>(itemBaseId);
        if (itemdb != null && itemdb.EqualsId != 0)
        {
            List <BaseItem> itemdataList2 = DataManager.Manager <ItemManager>().GetItemByBaseId(itemdb.EqualsId, GameCmd.PACKAGETYPE.PACKAGETYPE_MAIN);
            itemdataList.AddRange(itemdataList2);
        }


        if (itemdataList.Count <= 0)
        {
            Engine.Utility.Log.Error("背包没有道具{0}", itemBaseId);
        }
        int count = m_lstUIItem.Count;

        while (count > 0)
        {
            m_lstUIItem[0].Release();
            m_lstUIItem.RemoveAt(0);
            count = m_lstUIItem.Count;
        }
        m_lstUIItem.Clear();

        for (int i = 0; i < itemdataList.Count; i++)
        {
            UIItem uiitem = DataManager.Manager <UIManager>().GetUICommonItem(itemBaseId, itemdataList[i].Num, itemdataList[i].QWThisID, OnSelectItem);
            uiitem.Attach(m_grid_root.transform);
            if (uiitem.GetGrid <UIItemCommonGrid>().GetComponent <UIDragScrollView>() == null)
            {
                uiitem.GetGrid <UIItemCommonGrid>().gameObject.AddComponent <UIDragScrollView>();
            }
            //int x = (i % 3) * 85;
            //int y = -(i / 3) * 85;
            //uiitem.SetPosition(true, new Vector3(x, y, 0));
            m_lstUIItem.Add(uiitem);
        }

        if (m_grid_root != null)
        {
            m_grid_root.Reposition();
        }

        if (itemdataList.Count > 0)
        {
            OnSelectItem(m_lstUIItem[0].GetGrid <UIItemCommonGrid>());
        }
    }
示例#2
0
    /// <summary>
    /// 金币经验类icon显示
    /// </summary>
    /// <param name="type"></param>
    /// <param name="num"></param>
    /// <returns></returns>
    public UIItem GetUIMoneyExpItem(ItemDefine.CommonItem type, uint num, bool showGetWay = true)
    {
        //货币的图集Icon跟枚举一致
        string keyStr = ((int)type).ToString();
        UIItem uiitem = GetUIItem(keyStr, num);

        if (!showGetWay)
        {
            UIItemCommonGrid grid = uiitem.GetGrid <UIItemCommonGrid>();
            grid.SetShowGetWay(showGetWay);
        }
        return(uiitem);
    }