Exemplo n.º 1
0
        //从配置表读取信息,初始化TreasureView
        private void InitViewByConfig()
        {
            Dictionary <uint, object> treasureConfigDic = BaseDataMgr.instance.GetSysTreasureDic();
            int treasureNum = treasureConfigDic.Count;

            //克隆足够数量的对象
            Transform  mode = awardCombineItems.FindChild("1");
            GameObject clone;

            for (int i = awardCombineItems.childCount + 1; i <= treasureNum; ++i)
            {
                clone      = UIUtils.CloneObj(mode);
                clone.name = i.ToString();
            }
            awardCombineItems.GetComponent <UIGrid>().Reposition();

            //初始化
            int       j = 1;
            Transform orderItem;

            string[]   treasureList;
            uint       awardGoodId;
            GameObject Award;

            foreach (uint key in treasureConfigDic.Keys)
            {
                orderItem = awardCombineItems.FindChild(j.ToString());
                //显示额外奖励
                awardGoodId = uint.Parse(StringUtils.GetValueListFromString
                                             (BaseDataMgr.instance.GetSysTreasure(key).other_award)[0]);
                //增加额外奖励点击处理
                Award = orderItem.FindChild("Award-0").gameObject;
                Singleton <ItemManager> .Instance.InitItem(Award, awardGoodId, ItemType.BaseGoods);

                Award.name = "Award-" + awardGoodId;
                Award.GetComponent <UIToggle>().onSelect = GoodsOnClick;

                //显示组合宝藏点
                treasureList = StringUtils.GetValueListFromString(BaseDataMgr.instance.GetSysTreasure(key).order);
                orderItem.FindChild("Place_1").GetComponent <UISprite>().spriteName = treasureList[0];
                orderItem.FindChild("Place_2").GetComponent <UISprite>().spriteName = treasureList[1];
                orderItem.FindChild("Place_3").GetComponent <UISprite>().spriteName = treasureList[2];
                ++j;
            }
        }