Exemple #1
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);
        }
    }
Exemple #2
0
    //void ResetAttriCount()
    //{
    //    mAttriCount = 0;
    //}

    void UpdateUI()
    {
        //ResetAttriCount();

        ItemTemplate itemT = ItemEquipInfo.GetItemRowData();

        //mRuneNameTxt.text = GameUtils.getString(itemT.getName());

        //mSpeHeroTxt.text = GameUtils.getString(itemT.getSpecialHeroDes());

        //mDefineRuneItem.SetIcon(common.defaultPath + itemT.getIcon());
        //mDefineRuneItem.SetStarsNum(itemT.getRune_quality());
        //mDefineRuneItem.SetLevel(ItemEquipInfo.GetStrenghLevel());
        ////bool isSpecial = itemT.getRune_type() == 5 || itemT.getRune_type() == 6;
        //bool isSpecial = RuneModule.IsSpecialRune(itemT);
        //mDefineRuneItem.SetIsSpecial(isSpecial);

        //if (!isSpecial)
        //{
        //    mDefineRuneItem.SetRuneType(itemT.getRune_type());
        //}

        mItemCommonData.IsShowMaxEffect = true;
        mItemCommonData.RuneLevel       = ItemEquipInfo.GetStrenghLevel();
        mItemCommonData.ItemT           = itemT;
        mItemCommonData.EquipedHeroName = RuneModule.GetItemEuipHeroName(ItemEquipInfo);
        mItemCommon.SetRuneItemData(mItemCommonData, RuneItemCommon.RuneItemShowType.IconWithRightName);


        mDetailTxt.text = "";
        GameUtils.DestroyChildsObj(mAttriList);

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

        ////--------基础属性;
        //RuneData runeData = ItemEquipInfo.GetRuneData();
        //bool titleDone1 = false;
        //foreach (int id in runeData.BaseAttributeID)
        //{
        //    if (id == -1)
        //        continue;

        //    if (!titleDone1)
        //    {
        //        titleDone1 = true;
        //        CreateTitle(mAttriList, GameUtils.getString("hero_rune_content8"));
        //    }

        //    BaseruneattributeTemplate bt = DataTemplate.GetInstance().GetBaseruneattributeTemplate(id);
        //    if (bt.getNumshow() == 0)
        //    {
        //        //CreateTitle(mAttriList, GameUtils.getString(bt.getAttriDes()));
        //        CreateDetailTxts(mAttriList, GameUtils.getString(bt.getAttriDes()));
        //    }
        //    else
        //    {
        //        //CreateBaseAttriObj(mAttriList, GameUtils.GetAttriName(bt.getAttriType()), "+" + bt.getAttriValue().ToString());
        //        CreateBaseAttriObj(mAttriList, GameUtils.getString(bt.getAttriDes()), "+" + bt.getAttriValue().ToString());
        //    }
        //}

        ////--------附加属性;
        //bool titleDone2 = false;
        //int i = 0;
        //bool isGray = false;

        //foreach (int id in runeData.AppendAttribute)
        //{
        //    i++;

        //    isGray = i * 3 > ItemEquipInfo.GetStrenghLevel();

        //    if (id == -1)
        //    {
        //        if (i <= count)
        //        {
        //            if (!titleDone2)
        //            {
        //                titleDone2 = true;
        //                CreateTitle(mAttriList, GameUtils.getString("hero_rune_content9"));
        //            }
        //            //未知属性,未鉴定;
        //            CreateAddAttriObj(mAttriList, GameUtils.getString("rune_content2"), "", GameUtils.getString("rune_content3"), isGray);
        //        }

        //        continue;
        //    }

        //    if (!titleDone2)
        //    {
        //        titleDone2 = true;
        //        CreateTitle(mAttriList, GameUtils.getString("hero_rune_content9"));
        //    }

        //    AddruneattributeTemplate bt = DataTemplate.GetInstance().GetAddruneattributeTemplate(id);
        //    bool isPercent = bt.getIspercentage() > 0;
        //    string val = isPercent ? ((float)bt.getAttriValue() / (float)10f + "%") : bt.getAttriValue().ToString();
        //    CreateAddAttriObj(mAttriList, GameUtils.getString(bt.getAttriDes1()), GameUtils.getString(bt.getAttriDes2()), bt.getSymbol() + val, isGray);
        //}

        //是否鉴定满级;
        bool isFullIdentify = ItemEquipInfo.GetDefineTimes() >= count;

        //按钮是否置灰
        if (isFullIdentify)
        {
            mBtUnChange.SetActive(true);
            mBtChange.SetActive(false);
        }
        else
        {
            mBtUnChange.SetActive(false);
            mBtChange.SetActive(true);
        }
        //GameUtils.SetBtnSpriteGrayState(mDefineBtn, isFullIdentify);
        //是否显示道具消耗
        mCostItemImg.gameObject.SetActive(!isFullIdentify);
        mCostItemNum.gameObject.SetActive(!isFullIdentify);
        //刷新消耗;
        //int itemId = -1;              //消耗道具id
        //int itemCount = -1;           //消耗道具数量;
        int curLv = ItemEquipInfo.GetDefineTimes();

        switch (curLv)
        {
        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;
        }

        int itemTotal = UpdateCostTotalItemInfo();

        if (!isFullIdentify)
        {
            if (itemId == -1 || itemCount == -1)
            {
                //LogManager.LogError("错误的道具id:" + itemId + "或者是错误的道具数量:" + itemCount);
                LogManager.LogError("符文当前:" + curLv + "级,还可以鉴定,但是鉴定道具id" + itemId + "或者道具数量:" + itemCount + "不对");
            }
            ItemTemplate costItemT = DataTemplate.GetInstance().GetItemTemplateById(itemId);
            mCostItemImg.sprite = UIResourceMgr.LoadSprite(common.defaultPath + costItemT.getIcon());
            mCostImg1.sprite    = mCostItemImg.sprite;
            //int haveCount = 0;
            //ObjectSelf.GetInstance().TryGetItemCountById(EM_BAG_HASHTABLE_TYPE.EM_BAG_HASHTABLE_TYPE_COMMON, itemId, ref haveCount);
            TEXT_COLOR tc = itemCount > itemTotal ? TEXT_COLOR.RED : TEXT_COLOR.WHITE;
            mCostItemNum.text = GameUtils.StringWithColor(itemCount.ToString(), tc);
        }
    }