Ejemplo n.º 1
0
    void OnBuyBtnClick()
    {
        //判断是否还在打折;
        //TODO::
        bool discount = ShopModule.IsShopItemInDiscount(shopT);

        if (discount != isDiscount)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble7"), transform);
            return;
        }

        //判断是否已经下架;
        //TODO::
        bool isSale = ShopModule.IsShopItemInSaling(shopT);

        if (!isSale)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble6"), transform);
            return;
        }
        //购买商品接口;
        ShopModule.BuyItem(shopT.getId(), 1, isDiscount);

        CloseUI();
    }
Ejemplo n.º 2
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();
    }
Ejemplo n.º 3
0
    void OnBuyBtnClick()
    {
        bool isDiscount = ShopModule.IsShopItemInDiscount(mShopTemplate);

        //string errStr = "";
        //if(!ShopModule.BuyItem(mShopTemplate.getId(), 1, isDiscount, out errStr))
        //{
        //    InterfaceControler.GetInst().AddMsgBox(errStr, transform);
        //}
        ShopModule.BuyItem(mShopTemplate.getId(), 1, isDiscount);
    }
Ejemplo n.º 4
0
    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 + "";
            }
        }
    }
Ejemplo n.º 5
0
    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;
                }
            }
        }
    }
Ejemplo n.º 6
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();
    }
Ejemplo n.º 7
0
    /// <sumary>
    ///
    /// </sumary>
    public void UpdatePerSecond()
    {
        bool isDiscount = ShopModule.IsShopItemInDiscount(mShopT);

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

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

        if (isDiscount)
        {
            mOldTxt.text = DataTemplate.GetInstance().GetShopBuyCost(mShopT, buyTimes, false).ToString();
            mNewTxt.text = DataTemplate.GetInstance().GetShopBuyCost(mShopT, buyTimes, true).ToString();
        }
        else
        {
            //临时这么写;
            mCostNewObj.SetActive(true);
            mNewTxt.text = DataTemplate.GetInstance().GetShopBuyCost(mShopT, buyTimes, true).ToString();
        }
    }
Ejemplo n.º 8
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();
    }
Ejemplo n.º 9
0
    void OnBuyBtnClick()
    {
        //判断是否还在打折;
        //TODO::
        bool discount = ShopModule.IsShopItemInDiscount(ShopT);

        if (discount != isDiscount)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble7"), selfTransform);
            return;
        }

        //判断是否已经下架;
        //TODO::
        bool isSale = ShopModule.IsShopItemInSaling(ShopT);

        if (!isSale)
        {
            InterfaceControler.GetInst().AddMsgBox(GameUtils.getString("shop_bubble6"), selfTransform);
            return;
        }

        //购买商品接口;
        //string err = "";
        //if(!ShopModule.BuyItem(ShopT.getId(),ItemCount, isDiscount, out err))
        //{
        //    InterfaceControler.GetInst().AddMsgBox(err, selfTransform);
        //}
        //else
        //{
        //    CloseUI();
        //}

        ShopModule.BuyItem(ShopT.getId(), ItemCount, isDiscount);
        CloseUI();
    }
Ejemplo n.º 10
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);
    }
Ejemplo n.º 11
0
    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;
        }
    }
Ejemplo n.º 12
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);
        }
    }
Ejemplo n.º 13
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();
    }