Beispiel #1
0
    public static bool ShowYUEKAPreviewUI(ShopTemplate shopT)
    {
        UI_YueKaPreviewMgr.SetShopTemplate(shopT);
        UI_HomeControler.Inst.AddUI(UI_YueKaPreviewMgr.UI_ResPath);

        return(true);
    }
Beispiel #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);
    }
Beispiel #3
0
    /// <summary>
    /// 商城道具图标点击处理函数;
    /// </summary>
    /// <param name="shopT"></param>
    /// <returns></returns>
    public static bool OnShopItemIconClickHandler(ShopTemplate shopT)
    {
        if (shopT == null)
        {
            LogManager.LogError("ShopTemplate is NULL");
            return(false);
        }

        switch (shopT.getPreviewType())
        {
        case -1:
            break;

        case 1:
            int tableId = GameUtils.StringToInt(shopT.getPreviewContent());

            return(ShowItemPreviewUIHandler(tableId));

        case 2:
            ShowGroupItemPreviewUI(shopT);
            break;

        case 3:
            ShowYUEKAPreviewUI(shopT);
            break;

        default:
            LogManager.LogError("没有处理的商品点击预览类型");
            return(false);
        }

        return(true);
    }
Beispiel #4
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);
    }
Beispiel #5
0
    public static SHOP_LIMIT_TYPE GetShopLimitType(ShopTemplate shopT)
    {
        if (shopT == null)
        {
            return(SHOP_LIMIT_TYPE.NONE);
        }

        int daily = shopT.getDailyMaxBuy();
        int total = shopT.getShelveMaxBuy();

        if (daily != -1)
        {
            return(SHOP_LIMIT_TYPE.DAILY);
        }

        if (daily == -1 && total != -1)
        {
            return(SHOP_LIMIT_TYPE.TOTAL);
        }

        if (daily != -1 && total != -1)
        {
            LogManager.LogError("策划说不会有每天限购且永久限购类型的商品");
            return(SHOP_LIMIT_TYPE.NONE);
        }

        return(SHOP_LIMIT_TYPE.NONE);
    }
Beispiel #6
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 #7
0
    /// <summary>
    /// 显示物品组预览UI;
    /// </summary>
    /// <param name="content">预览显示配置中填以#分割的预览串:
    /// 预览方式-ID/美术资源名-数量-名称文本
    /// 预览方式1时为ID
    /// 预览方式2时为美术资源名
    /// 预览方式为1时要有2次预览弹窗,弹窗同预览类型1显示</param>
    /// <returns></returns>
    public static bool ShowGroupItemPreviewUI(ShopTemplate shopT)
    {
        UI_ItemGroupMgr.SetData(shopT);
        UI_HomeControler.Inst.AddUI(UI_ItemGroupMgr.UI_ResPath);

        return(true);
    }
Beispiel #8
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 #9
0
    /// <summary>
    /// 该物品是否限购;
    /// </summary>
    /// <param name="shopT"></param>
    /// <returns></returns>
    public static bool IsShopBuyLimited(ShopTemplate shopT)
    {
        if (shopT == null)
        {
            return(false);
        }

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

        return(shopT.getCostType());
    }
Beispiel #11
0
    public static TimeSpan GetTimeSpanToDiscountOff(ShopTemplate shopT)
    {
        if (shopT == null)
        {
            return(TimeSpan.MaxValue);
        }

        return(GameUtils.ConvertStringToDateTime(shopT.getDiscountOff()) - ObjectSelf.GetInstance().ServerDateTime);
    }
Beispiel #12
0
    public override void OnReadyForClose()
    {
        base.OnReadyForClose();

        buyBtn.onClick.RemoveAllListeners();
        closeBtn.onClick.RemoveAllListeners();

        mShopTemplate = null;
    }
Beispiel #13
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();
    }
Beispiel #14
0
    public override void OnReadyForClose()
    {
        base.OnReadyForClose();

        GameEventDispatcher.Inst.removeEventListener(GameEventID.G_MoneyResource_Update, UpdateMoney);

        shopT = null;
        buyBtn.onClick.RemoveAllListeners();
        closeBtn.onClick.RemoveAllListeners();
    }
Beispiel #15
0
    /// <summary>
    /// 获取商城物品总的购买次数限制---目前VIP等级会影响到这里,后期可能还会增加其他限制;
    /// </summary>
    /// <param name="shopT"></param>
    /// <param name="vipLv"></param>
    /// <returns></returns>
    public int GetShopItemTotalBuyTimes(ShopTemplate shopT, int vipLv)
    {
        if (shopT.getShelveMaxBuy() < 0)
        {
            return(-1);
        }

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

        return(shopT.getShelveMaxBuy() + vipCount);
    }
Beispiel #16
0
    public override void OnReadyForClose()
    {
        base.OnReadyForClose();

        shopT = null;
        closeBtn.onClick.RemoveAllListeners();

        for (int i = 0; i < itemsList.Count; i++)
        {
            itemsList[i].RemoveClickListener(OnItemClick);
        }
    }
Beispiel #17
0
 /// <summary>
 /// 只有经验药水有用
 /// </summary>
 /// <param name="id">商品参数 id</param>
 /// <returns>商品一行数值表</returns>
 public ShopTemplate GetShopTemplateByParaID(int id)
 {
     foreach (var item in m_ShopTable.getDataList())
     {
         ShopTemplate shop = ( ShopTemplate )item;
         if (int.Parse(shop.getPara()) == id)
         {
             return(shop);
         }
     }
     return(null);
 }
Beispiel #18
0
    public override void OnReadyForClose()
    {
        base.OnReadyForClose();

        closeBtn.onClick.RemoveAllListeners();

        GameUtils.DestroyChildsObj(listObj);

        _shopT      = null;
        _exchangeT  = null;
        _monthCardT = null;
    }
    public override void InitUIView()
    {
        base.InitUIView();

        if (data != null)
        {
            _shopT = DataTemplate.GetInstance().GetShopTemplateByID(data.shopId);

            iconImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + ShopT.getResourceName());
            //iconImg.SetNativeSize();
            nameTxt.text        = GameUtils.getString(ShopT.getCommodityName());
            oneCostImg.sprite   = GameUtils.GetSpriteByResourceType(ShopT.getCostType());
            totalCostImg.sprite = GameUtils.GetSpriteByResourceType(ShopT.getCostType());

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

            if (isDiscount)
            {
                perPrice = ShopT.getDiscountCost()[0];
            }
            else
            {
                perPrice = ShopT.getCost()[0];
            }
            oneCostTxt.text   = perPrice.ToString();
            totalCostTxt.text = (ItemCount * perPrice).ToString();

            maxCount = GetMaxCount();

            ItemCount = Mathf.Min(1, maxCount);

            moneyIcon.sprite = GameUtils.GetSpriteByResourceType(ShopT.getCostType());
            switch (ShopT.getCostType())
            {
            case (int)EM_RESOURCE_TYPE.Gold:
                GameEventDispatcher.Inst.addEventListener(GameEventID.G_Gold_Update, UpdateTotalGoldInfo);
                UpdateTotalGoldInfo();
                break;

            case (int)EM_RESOURCE_TYPE.Money:
                GameEventDispatcher.Inst.addEventListener(GameEventID.G_Money_Update, UpdateTotalMoneyInfo);
                UpdateTotalMoneyInfo();
                break;
            }

            int curCount = -1;
            if (ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, Convert.ToInt32(_shopT.getPara()), ref curCount))
            {
                curCountTxt.text = curCount + "";
            }
        }
    }
Beispiel #20
0
    /// <summary>
    /// 根据当前时间判断物品是否在打折;
    /// </summary>
    /// <param name="shopT"></param>
    /// <returns></returns>
    public static bool IsShopItemInDiscount(ShopTemplate shopT)
    {
        DateTime dt1 = GameUtils.ConvertStringToDateTime(shopT.getDiscountOn());
        DateTime dt2 = GameUtils.ConvertStringToDateTime(shopT.getDiscountOff());

        if (ObjectSelf.GetInstance().ServerDateTime > dt1 && ObjectSelf.GetInstance().ServerDateTime < dt2)
        {
            return(true);
        }

        return(false);
    }
    void CreateItem(ShopTemplate mShopT)
    {
        GameObject go = GameObject.Instantiate(itemObj) as GameObject;

        go.transform.parent        = itemListObj.transform;
        go.transform.localPosition = Vector3.zero;
        go.transform.localScale    = Vector3.one;

        QuikBuyGoldItemUI chargeUI = new QuikBuyGoldItemUI(go, mShopT);

        mChargeUIs.Add(chargeUI);
    }
Beispiel #22
0
    public List <ShopTemplate> GetAllShopTemplates()
    {
        List <ShopTemplate> result = new List <ShopTemplate> ();

        foreach (int i in m_ShopTable.GetDataKeys())
        {
            ShopTemplate st = ( ShopTemplate )m_ShopTable.getTableData(i);

            if (st == null)
            {
                continue;
            }

            result.Add(st);
        }

        return(result);
    }
Beispiel #23
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 #24
0
    public List <ShopTemplate> GetShopTemplatesByTabID(int tabID)
    {
        List <ShopTemplate> result = new List <ShopTemplate> ();

        foreach (int i in m_ShopTable.GetDataKeys())
        {
            ShopTemplate st = ( ShopTemplate )m_ShopTable.getTableData(i);

            if (st == null)
            {
                continue;
            }

            if (st.getTabID() == tabID)
            {
                result.Add(st);
            }
        }

        return(result);
    }
Beispiel #25
0
    public void ShowInfo(int tableid)
    {
        m_Tableid = tableid;

        m_ShopTemp = DataTemplate.GetInstance().GetShopTemplateByParaID(m_Tableid);


        // icon
        m_Item        = ( ItemTemplate )DataTemplate.GetInstance().m_ItemTable.getTableData(tableid);
        m_Icon.sprite = UIResourceMgr.LoadSprite(common.defaultPath + m_Item.getIcon_s());

        int number = 0;

        ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, tableid, ref number);
        m_UI_Text_Count.text = number.ToString();

        m_UI_Text_Name.text = GameUtils.getString(m_Item.getName());

        m_UI_Text_Num.text = m_Number.ToString();

        m_UI_Text_Total.text = (m_Number * m_ShopTemp.getCost() [0]).ToString();
    }
    /****************检测商店的可购买礼包*****************/
    /// <summary>
    /// 检测商店的可购买礼包
    /// </summary>
    /// <returns></returns>
    public bool CheckNonPurchasedGiftSet()
    {
        bool _result = false;

        m_NonPurchasedGiftSetList.Clear();

        for (int i = 0; i < m_GiftSetList.Count; i++)
        {
            bool         _timesResult = true;
            ShopTemplate _shopT       = m_GiftSetList[i];
            if (_shopT.getVipLimit() > m_ObjectSelf.VipLevel)
            {
                continue;
            }

            int _maxTimes      = _shopT.getDailyMaxBuy();
            int _maxTotalTimes = _shopT.getShelveMaxBuy();

            var _shopBuy = m_ObjectSelf.GetShopBuyInfoByShopId(_shopT.GetID());

            if (_maxTimes > 0)
            {
                _timesResult &= _maxTimes > _shopBuy.todaynum;
            }

            if (_maxTotalTimes > 0)
            {
                _timesResult &= _maxTotalTimes > _shopBuy.buyallnum;
            }
            if (_timesResult)
            {
                _result |= true;
                m_NonPurchasedGiftSetList.Add(_shopT.GetID());
            }
        }

        return(_result);
    }
    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);
    }
Beispiel #28
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 #29
0
    /// <summary>
    /// 点击立刻购买;
    /// </summary>
    void OnMsgBoxYesClick()
    {
        UI_HomeControler.Inst.ReMoveUI(UI_RechargeBox.UI_ResPath);

        int          stoneid = DataTemplate.GetInstance().GetGameConfig().getIdentify_stone_id();
        ShopTemplate shopT   = DataTemplate.GetInstance().GetShopTemplateByID(stoneid);

        if (!ShopModule.IsShopItemInSaling(shopT))
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble6"), transform);
            return;
        }
        int  buyTimes   = ObjectSelf.GetInstance().GetShopBuyInfoByShopId(stoneid).todaynum;
        bool isdiscount = ShopModule.IsShopItemInDiscount(shopT);

        int haveCount = 0;

        ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, itemId, ref haveCount);

        //获取符文鉴定石对应到商店表的id;
        int shopId = DataTemplate.GetInstance().GetGameConfig().getIdentify_stone_id();

        ShopModule.BuyItem(shopId, itemCount - haveCount, isdiscount);
    }
Beispiel #30
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);
        }
    }