Esempio n. 1
0
    IEnumerator RefreshGoodsList()
    {
        CommodityWaitLoad.SetActive(true);
        if (GameApp.Instance.Platform != null)
        {
            CommodityLoadProgLab.text = StringBuilderTool.ToString("等待获取商品列表...");
            if (!GameApp.Instance.Platform.IsGetGetGoodsListOver)
            {
                GameApp.Instance.Platform.GetGoodsList();

                while (!GameApp.Instance.Platform.IsGetGetGoodsListOver)
                {
                    yield return(new WaitForEndOfFrame());
                }
            }

            MyTools.DestroyChildNodes(GoodsTable.transform);
            foreach (KeyValuePair <int, GoodsInfo> pair in GameApp.Instance.Platform.GoodsDic)
            {
                if (pair.Value.ID >= 35 && pair.Value.ID <= 37)
                {
                    GameObject newUnit = NGUITools.AddChild(GoodsTable.gameObject, GoodsUnit_Prefab);
                    newUnit.SetActive(true);
                    newUnit.name = "Goods_" + pair.Value.ID;

                    UI_CommodityItem ci = newUnit.GetComponent <UI_CommodityItem>();
                    ci.Show(pair.Value.CfgItemID, float.Parse(pair.Value.GetPriceStr()), 0);
                    ci.OverrideName(pair.Value.Name);
                    ci.GoodsID = pair.Value.ID;

                    GoodsTable.repositionNow = true;

                    yield return(new WaitForEndOfFrame());

                    GoodsLstRoot.GetComponent <UIScrollView>().ResetPosition();
                }
            }
        }
        else
        {
            CommodityLoadProgLab.text = StringBuilderTool.ToString("为连接运营平台,无法获取商品列表!");
            yield return(new WaitForSeconds(2f));
        }
        CommodityWaitLoad.SetActive(false);
    }
Esempio n. 2
0
    IEnumerator RefreshCommodityList()
    {
        MyTools.DestroyChildNodes(CommodityTable.transform);
        CommodityWaitLoad.SetActive(true);
        int CurProg = 0;

        foreach (Commodity c in TempCommodityLst)
        {
            if (c.Type == ECommodityType.eCard)
            {
                GameObject newUnit = NGUITools.AddChild(CommodityTable.gameObject, CommodityUnit_CardPrefab);
                newUnit.SetActive(true);
                newUnit.name = "Commodity_Card_" + c.ID;

                UI_MagicCard mc = newUnit.GetComponent <UI_MagicCard>();
                mc.UnconditionalShow(c.ID);
                mc.SetPrice(c.Price);
            }
            else if (c.Type == ECommodityType.eItem)
            {
                GameObject newUnit = NGUITools.AddChild(CommodityTable.gameObject, CommodityUnit_ItemPrefab);
                newUnit.SetActive(true);
                newUnit.name = "Commodity_Item_" + c.ID;

                UI_CommodityItem ci = newUnit.GetComponent <UI_CommodityItem>();
                ci.Show(c.ID, c.Price, 1001);
            }

            CommodityTable.repositionNow = true;
            yield return(new WaitForEndOfFrame());

            CommodityLstRoot.GetComponent <UIScrollView>().ResetPosition();

            CurProg++;
            CommodityLoadProgLab.text = StringBuilderTool.ToString("商品加载中(", CurProg, "/", TempCommodityLst.Count, ")...");
        }
        CommodityWaitLoad.SetActive(false);
    }