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]);
        }
    }
Beispiel #2
0
    /// <summary>
    /// 获取商城物品每日购买次数限制---目前VIP等级会影响到这里,后期可能还会增加其他限制;
    /// </summary>
    /// <param name="shopT"></param>
    /// <param name="vipLv"></param>
    /// <returns></returns>
    public int GetShopItemDailyBuyTimes(ShopTemplate shopT, int vipLv)
    {
        if (shopT.getDailyMaxBuy() < 0)
        {
            return(-1);
        }

        int vipCount = 0;//根据VIP算出的附加值;

        //行动力补满药水;
        if (shopT.getId() == GetGameConfig().getEp_supplement_goods())
        {
            VipTemplate vip = GetVipTemplateById(vipLv);
            vipCount = vip.getMaxBuyEp();
        }

        //活力补满药水;
        if (shopT.getId() == GetGameConfig().getAp_supplement_goods())
        {
            VipTemplate vip = GetVipTemplateById(vipLv);
            vipCount = vip.getMaxBuyAp();
        }

        return(shopT.getDailyMaxBuy() + vipCount);
    }
    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 #4
0
    /// <summary>
    /// 根据商店物品购买次数获得下次购买需要消耗的资源数;
    /// </summary>
    /// <param name="shopT"></param>
    /// <param name="buyTimes"></param>
    /// <param name="isDiscount"></param>
    /// <returns></returns>
    public int GetShopBuyCost(ShopTemplate shopT, int buyTimes, bool isDiscount = false)
    {
        if (shopT == null || buyTimes < 0)
        {
            return(-1);
        }

        int [] costs = null;

        if (isDiscount)
        {
            costs = shopT.getDiscountCost();
        }
        else
        {
            costs = shopT.getCost();
        }

        if (costs == null)
        {
            Debug.LogError("shop表格数据错误,id=" + shopT.getId() + "的消费数据处错误");
            return(-1);
        }

        if (buyTimes >= costs.Length)
        {
            return(costs [costs.Length - 1]);
        }

        return(costs [buyTimes]);
    }
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
    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();
    }
Beispiel #7
0
    public void SetShowData(ShopTemplate shopT)
    {
        string[] details = shopT.getPreviewContent().Split(new string[] { "#" }, StringSplitOptions.None);

        if (details == null || details.Length == 0)
        {
            LogManager.LogError("打包展示物品内容解析错误,shopid=" + shopT.getId());
            return;
        }

        for (int i = 0, j = details.Length; i < j; i++)
        {
            string[] cont = details[i].Split(new string[] { "-" }, StringSplitOptions.None);
            if (cont == null || cont.Length != 4)
            {
                LogManager.LogError("打包展示物品内容解析错误,shopid=" + shopT.getId());
            }

            try
            {
                switch (int.Parse(cont[0]))
                {
                case 1:
                    CreateItem(int.Parse(cont[1]), cont[2], cont[3]);
                    break;

                case 2:
                    CreateItem(cont[1], cont[2], cont[3]);
                    break;
                }
            }
            catch (Exception e)
            {
                LogManager.LogError(e.ToString());
            }
        }
    }
Beispiel #8
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())));
    }
Beispiel #9
0
    /// <summary>
    /// 购买物品接口
    /// </summary>
    /// <param name="shopId">shop表id</param>
    /// <param name="count">购买数量</param>
    /// <param name="isdiscount">是否在打折</param>
    /// <param name="errStr">返回的错误信息</param>
    /// <returns></returns>
    public static void BuyItem(int shopId, int count, bool isdiscount)
    {
        UI_ShopMgr.CanBuyItem = false;

        ShopTemplate shopT = DataTemplate.GetInstance().GetShopTemplateByID(shopId);

        if (shopT.getTabID() == (int)SHOP_TAB.CHARGE)
        {
            CRequestExchangeBill bill = new CRequestExchangeBill();
            bill.goodid  = shopT.getId();
            bill.goodnum = count;

            IOControler.GetInstance().SendProtocol(bill);
        }
        else
        {
            CShopBuy csb = new CShopBuy();
            csb.isdiscount = System.Convert.ToByte(isdiscount);
            csb.shopid     = shopId;
            csb.num        = count;

            IOControler.GetInstance().SendProtocol(csb);
        }
    }
    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 #11
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();
    }