Exemple #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]);
        }
    }
Exemple #2
0
    /// <summary>
    /// 活力商品显示
    /// </summary>
    private void InitPowerShopUI()
    {
        int surplusNum_0 = 0;                    //可用次数

        goods = config.getAp_supplement_goods(); //活力补满商品的ID
        ShopTemplate shopDate = (ShopTemplate)DataTemplate.GetInstance().m_ShopTable.getTableData(goods);

        if (shopDate == null)
        {
            LogManager.Log("is Shop null !!!!");
            return;
        }
        m_NameTxt_0.text = GameUtils.getString(shopDate.getCommodityName());
        m_DesTxt_0.text  = GameUtils.getString(shopDate.getCommodityDes());

        //商品使用次数+Vip的使用次数
        surplusNum_0 = shopDate.getDailyMaxBuy() + vipData.getMaxBuyAp();
        //剩余使用次数
        Shopbuy shop = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(goods);

        m_curSurpNum_0 = surplusNum_0 - shop.todaynum;

        _SurplusNumTxt_0.text = m_curSurpNum_0.ToString();
        _Icon_0.sprite        = UIResourceMgr.LoadSprite(common.defaultPath + shopDate.getResourceName());

        //消耗钻石显示
        m_conDiamNum        = DataTemplate.GetInstance().GetShopBuyCost(shopDate, shop.todaynum);
        _ConDiamNumTxt.text = m_conDiamNum.ToString();

        SetBtnColor(m_curSurpNum_0, _UserBtn_0, ObjectSelf.GetInstance().Gold);
    }
Exemple #3
0
    public void SetShowData(ShopTemplate shopT)
    {
        nameTxt.text   = GameUtils.getString(shopT.getCommodityName());
        iconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + shopT.getResourceName());

        //判断当前时间是否打折期间---与购买商品时候是否打折进行比对,如果不同,购买失败,让玩家从新购买;
        isDiscount = ShopModule.IsShopItemInDiscount(shopT);

        UpdateMoneyInfo();
    }
    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);
    }
    /// <summary>
    /// 设置信息,id表示表格id,type = 0表示对应shop表,1表示物品表;
    /// </summary>
    /// <param name="id"></param>
    /// <param name="type"></param>
    public void SetData(int id, int type)
    {
        mId   = id;
        mType = type;

        switch (type)
        {
        case 0:
            m_UseBtnTxt.text = GameUtils.getString("common_button_purchase");
            shopT            = DataTemplate.GetInstance().GetShopTemplateByID(id);
            m_IconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + shopT.getResourceName());
            m_IconImg.SetNativeSize();
            m_TitleTxt.text = GameUtils.getString(shopT.getCommodityName());
            mHaveCount      = int.MaxValue;

            int max = DataTemplate.GetInstance().GetShopItemDailyBuyTimes(shopT, ObjectSelf.GetInstance().VipLevel);

            //剩余使用次数
            Shopbuy shop = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(id);

            mRemineTimes = max - shop.todaynum;
            mCost        = DataTemplate.GetInstance().GetShopBuyCost(shopT, shop.todaynum);

            m_ReminTxt.text = mRemineTimes.ToString();
            m_CostTxt.text  = mCost.ToString();
            m_CostObj.SetActive(true);
            m_HaveObj.SetActive(false);

            long moneyCount = -1;
            if (ObjectSelf.GetInstance().TryGetResourceCountById(EM_RESOURCE_TYPE.Gold, ref moneyCount))
            {
                GameUtils.SetBtnSpriteGrayState(m_UseBtn, mRemineTimes <= 0 || mCost > moneyCount);
            }
            m_DetailTxt.text = GameUtils.getString(shopT.getCommodityDes());
            break;

        case 1:
            m_UseBtnTxt.text = GameUtils.getString("common_button_use");
            itemT            = DataTemplate.GetInstance().GetItemTemplateById(id);
            m_IconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + itemT.getIcon());
            m_IconImg.SetNativeSize();
            m_TitleTxt.text = GameUtils.getString(itemT.getName());

            if (!ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, id, ref mHaveCount))
            {
                mHaveCount = 0;
            }

            int max1 = ExplorePointModule.GetEPItemUseTimes(itemT, ObjectSelf.GetInstance().VipLevel);

            //剩余使用次数
            int useTimes = ObjectSelf.GetInstance().CommonItemContainer.GetItemUseTimes(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, id);

            mRemineTimes = max1 - Mathf.Max(0, useTimes);
            mCost        = 0;

            m_ReminTxt.text = mRemineTimes.ToString();
            m_CostTxt.text  = mCost.ToString();
            m_CostObj.SetActive(false);

            m_HaveTxt.text = (mHaveCount > 999 ? 999 : mHaveCount).ToString();
            m_HaveObj.SetActive(true);
            GameUtils.SetBtnSpriteGrayState(m_UseBtn, mRemineTimes <= 0 || mHaveCount <= 0);
            m_DetailTxt.text = GameUtils.getString(itemT.getDes());
            break;

        default:
            break;
        }
    }
    public void SetShowData(ShopTemplate shopT)
    {
        if (shopT == null)
        {
            LogManager.LogError("皮肤预览传入的ShopTemplate is null");
            return;
        }

        mOldImg.sprite = GameUtils.GetSpriteByResourceType(shopT.getCostType());
        mNewImg.sprite = GameUtils.GetSpriteByResourceType(shopT.getCostType());

        bool isDiscount = ShopModule.IsShopItemInDiscount(shopT);

        mCostOldObj.SetActive(isDiscount);
        mCostNewObj.SetActive(isDiscount);

        int buyTimes = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(shopT.getId()).todaynum;

        if (isDiscount)
        {
            mOldTxt.text = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, false).ToString();
            mNewTxt.text = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, true).ToString();
        }
        else
        {
            //临时这么写;
            mCostNewObj.SetActive(true);
            mNewTxt.text = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, false).ToString();
        }

        int artTableId           = GameUtils.StringToInt(shopT.getPreviewContent());
        ArtresourceTemplate artT = DataTemplate.GetInstance().GetArtResourceTemplate(artTableId);

        if (artT == null)
        {
            LogManager.LogError("ArtresourceTemplate is null id=" + artTableId);
            return;
        }

        iconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + shopT.getResourceName());
        iconImg.SetNativeSize();

        HeroTemplate heroT = DataTemplate.GetInstance().GetHeroTemplateByArtresourceId(artTableId);

        if (heroT != null)
        {
            heroTitleTxt.text = GameUtils.getString(heroT.getTitleID());
            heroNameTxt.text  = GameUtils.getString(heroT.getNameID());
        }
        else
        {
            LogManager.LogError("英雄表中找不到对应皮肤id=" + artTableId + "的数据");
        }

        int count = DataTemplate.GetInstance().GetArtResourceAtrriCount(artT);

        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(artT.getSymbol()[i]);

                if (artT.getIspercentage()[i] == 1)
                {
                    float val = (float)(artT.getAttriValue()[i]) / 10f;
                    sb.Append(val);
                    sb.Append("%");
                }
                else
                {
                    sb.Append(artT.getAttriValue()[i]);
                }

                CreateAttriItem(GameUtils.getString(artT.getAttriDes()[i]), sb.ToString());
            }
        }

        nameTxt.text = GameUtils.getString(artT.getNameID());

        UpdateMoneyInfo();
    }