Beispiel #1
0
    public void SetShowData(ShopTemplate shopT)
    {
        if (shopT == null)
        {
            LogManager.LogError("YueKaPreview ShopTemplate is null");
            return;
        }

        nameTxt.text  = GameUtils.getString(shopT.getCommodityName());
        iconBg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + shopT.getBaseicon());
        iconBg.SetNativeSize();
        iconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + shopT.getResourceName());
        string content = shopT.getPreviewContent();

        if (string.IsNullOrEmpty(content))
        {
            LogManager.LogError("ShopTemplate表格预览内容描述填写错误!id=" + shopT.getId());
            return;
        }

        string[] detailTxt = GameUtils.getString(content).Split(new string[] { "#" }, StringSplitOptions.None);
        if (detailTxt == null || detailTxt.Length == 0)
        {
            LogManager.LogError("ShopTemplate表格预览内容描述解析数据为空!id=" + shopT.getId());
            return;
        }

        for (int i = 0, j = detailTxt.Length; i < j; i++)
        {
            CreateDetail(detailTxt[i]);
        }
    }
    public QuikBuyGoldItemUI(GameObject go, ShopTemplate shopT)
    {
        trans = go.transform;

        mShopT = shopT;

        nameTxt = trans.FindChild("NameImg/Text").GetComponent <Text>();
        iconBg  = trans.FindChild("iconBg").GetComponent <Image>();
        iconImg = trans.FindChild("iconImg").GetComponent <Image>();
        //iconBtn = trans.FindChild("iconImg").GetComponent<Button>();
        detailTxt = trans.FindChild("DetailTxt").GetComponent <Text>();

        mCostOldObj = trans.FindChild("CostObj/MoneyCost1").gameObject;
        mOldImg     = trans.FindChild("CostObj/MoneyCost1/Text/bgImg").GetComponent <Image>();
        mOldTxt     = trans.FindChild("CostObj/MoneyCost1/Text").GetComponent <Text>();
        mCostNewObj = trans.FindChild("CostObj/MoneyCost2").gameObject;
        mNewImg     = trans.FindChild("CostObj/MoneyCost2/Text/bgImg").GetComponent <Image>();
        mNewTxt     = trans.FindChild("CostObj/MoneyCost2/Text").GetComponent <Text>();

        buyBtn = trans.FindChild("BuyBtn").GetComponent <Button>();

        nameTxt.text  = GameUtils.getString(mShopT.getCommodityName());
        iconBg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + mShopT.getBaseicon());
        iconBg.SetNativeSize();
        iconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + mShopT.getResourceName());
        iconImg.SetNativeSize();
        detailTxt.text = GameUtils.getString(mShopT.getCommodityDes());
        mOldImg.sprite = GameUtils.GetSpriteByResourceType(mShopT.getCostType());
        mNewImg.sprite = GameUtils.GetSpriteByResourceType(mShopT.getCostType());

        GameUtils.SetImageGrayState(mOldImg, true);

        UpdatePerSecond();

        //iconBtn.onClick.AddListener(OnItemClick);
        buyBtn.onClick.AddListener(OnItemClick);
    }