Beispiel #1
0
    /// <summary>
    /// 获取购买商品消耗资源类型;
    /// </summary>
    /// <param name="shopT"></param>
    /// <returns></returns>
    public int GetShopBuyCostType(ShopTemplate shopT)
    {
        if (shopT == null)
        {
            return(-1);
        }

        return(shopT.getCostType());
    }
Beispiel #2
0
    void UpdateMoneyInfo()
    {
        int resourceId = shopT.getCostType();

        moneyImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        moneyImg.SetNativeSize();
        long count = -1;

        if (ObjectSelf.GetInstance().TryGetResourceCountById(resourceId, ref count))
        {
            moneyTxt.text = count.ToString();
        }

        mOldImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        mNewImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);

        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();
        }
        //costImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        //int buyTimes = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(shopT.getId()).todaynum;
        //bool isDiscount = ShopModule.IsShopItemInDiscount(shopT);
        //costTxt.text = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, isDiscount).ToString();
    }
    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);
    }
    void OnItemClick()
    {
        //判断VIP等级是否足够;
        if (mShopT.getVipLimit() > ObjectSelf.GetInstance().VipLevel)
        {
            InterfaceControler.GetInst().AddMsgBox(string.Format(GameUtils.getString("shop_bubble3"), mShopT.getVipLimit()), UI_ShopMgr.inst.transform);
            return;
        }

        //当前金钱够不够买一个的;
        bool isDiscount = ShopModule.IsShopItemInDiscount(mShopT);

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

        int costNum = DataTemplate.GetInstance().GetShopBuyCost(mShopT, buyTimes, isDiscount);

        long             curCount = -1;
        EM_RESOURCE_TYPE resType  = (EM_RESOURCE_TYPE)mShopT.getCostType();

        if (ObjectSelf.GetInstance().TryGetResourceCountById(resType, ref curCount))
        {
            if (curCount >= costNum)
            {
                if (mShopT.getType() != 51)
                {
                    LogManager.LogError("不是金币类型51的物品,所属标签填写错误!" + mShopT.getId());
                    return;
                }

                //打开金币购买界面;
                UI_GoldBuyMgr.SetData(mShopT);
                UI_HomeControler.Inst.AddUI(UI_GoldBuyMgr.UI_ResPath);
            }
            else
            {
                switch (resType)
                {
                case EM_RESOURCE_TYPE.Gold:
                    //打开魔钻不足提示窗;
                    InterfaceControler.GetInst().ShowGoldNotEnougth(UI_QuikBuyGoldMgr.Inst.transform);
                    break;

                default:
                    InterfaceControler.GetInst().AddMsgBox("除魔钻资源不足时,其他资源不足先不做处理", UI_ShopMgr.inst.transform);
                    break;
                }
            }
        }
    }
Beispiel #5
0
    void UpdateMoneyInfo()
    {
        int resourceId = mShopTemplate.getCostType();

        moneyIcon.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        moneyIcon.SetNativeSize();
        long count = -1;

        if (ObjectSelf.GetInstance().TryGetResourceCountById(resourceId, ref count))
        {
            moneyTxt.text = count.ToString();
        }

        costImg.sprite = GameUtils.GetSpriteByResourceType(resourceId);
        int  buyTimes   = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(mShopTemplate.getId()).todaynum;
        bool isDiscount = ShopModule.IsShopItemInDiscount(mShopTemplate);

        costTxt.text = DataTemplate.GetInstance().GetShopBuyCost(mShopTemplate, buyTimes, isDiscount).ToString();
    }
Beispiel #6
0
    /// <summary>
    /// 获得最大购买次数---注意不会有阶梯价格的物品;
    /// </summary>
    /// <param name="shopId"></param>
    /// <param name="perPrice"></param>
    /// <returns></returns>
    public static int GetMaxBuyCount(int shopId, int perPrice)
    {
        ShopTemplate ShopT = DataTemplate.GetInstance().GetShopTemplateByID(shopId);

        if (ShopT == null)
        {
            LogManager.LogError("ShopTemplate is null id=" + shopId);
            return(-1);
        }

        List <int> times = new List <int>();
        //-----根据人物当前资源最大购买次数--------
        int  countByMoney = -1;
        long count        = -1;

        if (ObjectSelf.GetInstance().TryGetResourceCountById(ShopT.getCostType(), ref count))
        {
            countByMoney = (int)(count / perPrice);
            times.Add(countByMoney);
        }

        int     vipLv = ObjectSelf.GetInstance().VipLevel;
        Shopbuy sb    = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(ShopT.getId());
        //-----根据人物当前vip每日限购最大购买次数--
        int countByDaily = -1;
        //-----根据人物当前vip总限购最大购买次数----
        int countByTotal = -1;

        if (IsShopBuyLimited(ShopT))
        {
            countByDaily = DataTemplate.GetInstance().GetShopItemDailyBuyTimes(ShopT, vipLv) - sb.todaynum;
            countByTotal = DataTemplate.GetInstance().GetShopItemDailyBuyTimes(ShopT, vipLv) - sb.buyallnum;

            times.Add(countByDaily);
            times.Add(countByTotal);
        }

        //默认最大购买次数;
        times.Add(999);

        return(Mathf.Max(0, Mathf.Min(times.ToArray())));
    }
    void OnUseBtnClick()
    {
        switch (mType)
        {
        case 0:
            bool isDiscount = ShopModule.IsShopItemInDiscount(shopT);
            int  buyTimes   = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(shopT.getId()).todaynum;
            int  costNum    = DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, isDiscount);

            long             curCount = -1;
            EM_RESOURCE_TYPE resType  = (EM_RESOURCE_TYPE)shopT.getCostType();
            if (ObjectSelf.GetInstance().TryGetResourceCountById(resType, ref curCount))
            {
                if (curCount >= costNum)
                {
                    //1.是否满活力;
                    if (ObjectSelf.GetInstance().ExplorePoint >= ObjectSelf.GetInstance().ExplorePointMax)
                    {
                        InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("explore_bubble2"));
                        return;
                    }
                    //2.是否有购买次数;
                    int maxDayliTimes = DataTemplate.GetInstance().GetShopItemDailyBuyTimes(shopT, ObjectSelf.GetInstance().VipLevel);
                    if (buyTimes >= maxDayliTimes)
                    {
                        InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("UI_raids_tips2"));
                        return;
                    }

                    //成功后弹窗;
                    ShowBuyWater(isDiscount, costNum);
                }
                else
                {
                    switch (resType)
                    {
                    case EM_RESOURCE_TYPE.Gold:
                        //打开魔钻不足提示窗;
                        InterfaceControler.GetInst().ShowGoldNotEnougth();
                        break;

                    default:
                        //InterfaceControler.GetInst().AddMsgBox("除魔钻资源不足时,其他资源不足先不做处理");
                        break;
                    }
                }
            }
            break;

        case 1:
            //是否有使用次数;
            if (mRemineTimes <= 0)
            {
                InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("vigour_supplement_tip1"));
                return;
            }

            //是否拥有该道具;
            if (mHaveCount <= 0)
            {
                InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("vigour_supplement_tip3"));
                return;
            }

            //成功;
            BaseItem item = ObjectSelf.GetInstance().CommonItemContainer.FindItem(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, mId);
            if (item == null)
            {
                Debug.LogError("人物身上没有该物品id" + mId);
                return;
            }

            SendMsg(item.GetItemGuid(), 1);
            break;

        default:
            break;
        }
    }
Beispiel #8
0
    void OnDefineBtnClick()
    {
        if (mRuneGUID == null || ItemEquipInfo == null)
        {
            return;
        }

        ItemTemplate itemT = ItemEquipInfo.GetItemRowData();

        //一星符文没法鉴定;
        if (itemT.getRune_quality() <= 1)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("hero_rune_tip3"), transform);
            return;
        }

        int count = DataTemplate.GetInstance().GetRuneMaxRedefineTimes(itemT);

        //是否鉴定满级;
        if (ItemEquipInfo.GetDefineTimes() >= count)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("hero_rune_tip4"), transform);
            return;
        }

        ///鉴定消耗物品是否足够;
        itemId    = -1;           //消耗道具id
        itemCount = -1;           //消耗道具数量;
        switch (ItemEquipInfo.GetDefineTimes())
        {
        case 0:
            itemId    = itemT.getRune_exposeCostType1();
            itemCount = itemT.getRune_exposeCostValue1();
            break;

        case 1:
            itemId    = itemT.getRune_exposeCostType2();
            itemCount = itemT.getRune_exposeCostValue2();
            break;

        case 2:
            itemId    = itemT.getRune_exposeCostType3();
            itemCount = itemT.getRune_exposeCostValue3();
            break;

        case 3:
            itemId    = itemT.getRune_exposeCostType4();
            itemCount = itemT.getRune_exposeCostValue4();
            break;

        default:
            break;
        }
        if (itemId != -1 && itemCount > 0)
        {
            int haveCount = 0;
            ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, itemId, ref haveCount);

            //道具不足提示;
            if (haveCount < itemCount)
            {
                ItemTemplate   costItemT = DataTemplate.GetInstance().GetItemTemplateById(itemId);
                UI_RechargeBox box       = UI_HomeControler.Inst.AddUI(UI_RechargeBox.UI_ResPath).GetComponent <UI_RechargeBox>();
                box.SetIsNeedDescription(true);
                Sprite sp = UIResourceMgr.LoadSprite(common.defaultPath + costItemT.getIcon());
                //获取商城中该物品的价格----写死的商品id==3;
                int          shopid = DataTemplate.GetInstance().GetGameConfig().getIdentify_stone_id();
                ShopTemplate shopT  = DataTemplate.GetInstance().GetShopTemplateByID(shopid);
                if (!ShopModule.IsShopItemInSaling(shopT))
                {
                    InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble6"), transform);
                    return;
                }
                box.SetConsume_Image(GameUtils.GetSpriteByResourceType(shopT.getCostType()));
                int  buyTimes   = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(shopid).todaynum;
                bool isdiscount = ShopModule.IsShopItemInDiscount(shopT);
                int  needCount  = itemCount - haveCount;
                long costTotal  = (DataTemplate.GetInstance().GetShopBuyCost(shopT, buyTimes, isdiscount) * needCount);
                box.SetConNum(costTotal.ToString());
                string content = string.Format(GameUtils.getString("hero_rune_identifyform_tip1"), GameUtils.getString(costItemT.getName(), TEXT_COLOR.YELLOW) + " X " + needCount);
                box.SetDescription_text(content);
                long resourceCount = 0;
                ObjectSelf.GetInstance().TryGetResourceCountById(shopT.getCostType(), ref resourceCount);
                box.SetMoneyInfo(shopT.getCostType(), (int)resourceCount);
                box.SetMoneyInfoActive(true);
                box.SetLeftBtn_text(GameUtils.getString("common_button_purchase1"));

                if (costTotal > resourceCount)
                {
                    box.SetLeftClick(OnMsgBoxYesNoMoneyClick);
                }
                else
                {
                    box.SetLeftClick(OnMsgBoxYesClick);
                }
            }
            else
            {
                SendIndentifyProtocol();
            }
        }
        else
        {
            LogManager.LogError("错误的道具id:" + itemId + "或者是错误的道具数量:" + itemCount);
        }
    }
Beispiel #9
0
    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();
    }