local UIDivineWeaponBreak = UIViewClass() local resonance_info = require 'Proto/resonance_info_pb' local EventSystem = require('Event/EventSystem') local STARMAX = MDL.DivineWeapon.STARMAX local goldWeaponFragmentItemID = 302 -- 金神兵万能碎片 local superGoldWeaponFragmentItemID = 402 -- 彩金神兵万能碎片 function UIDivineWeaponBreak:OnOpened(context) self:RegistSystemEvent(EventID.UI_DivineWeapon_Update,self.RefreshInfo) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshCost) self:RegistSystemEvent(EventID.UI_ResonanceChange_Refresh, self.RefreshResonanceLv) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.UpdateAwakenEntry) self:RefreshResonanceLv() CTL.FormationResonance.SetSubResonanceImage(self.icon_Resonance, resonance_info.Weapon_Break) for i,v in ipairs(self.group_unStage) do self:RegistTriggerEvent(v, UIEventTriggerType.PointerDown) self:RegistTriggerEvent(v, UIEventTriggerType.PointerUp) end end function UIDivineWeaponBreak:RefreshResonanceLv() if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.Resonance) then UIUtils.SetActive(self.btn_Resonance, true) else UIUtils.SetActive(self.btn_Resonance, false) end UIUtils.SetLabel(self.txt_ResonanceLv, string.FormatByIdsId(Const_IDS["IDS_Resonance_Level"], MDL.FormationResonance.GetSubResonanceLv(resonance_info.Weapon_Break))) end function UIDivineWeaponBreak:OnPointerDown(comp, eventData) local heroInfo = MDL.HeroSelect.GetHeroInfo(self.weaponId) local weaponLevel = heroInfo.magicWeaponLevel or 0 local max = MDL.DivineWeapon.GetBreakMax(self.weaponId) if weaponLevel ~= max then local index = nil for i,v in ipairs(self.group_unStage) do if v.gameObject == comp.gameObject then index = i end end self.group_StageTitle.transform:SetParent(self.group_unStage[index].transform, false) local attrData = DataSheetManager.MagicWeaponStarAttr:GetDataByAttrRepeatID(self.data.Attr_Table[index].AttrRepeat).Attr_Table[1] local attrName = DataSheetManager.AttrData:GetDataByID(attrData.AttrType).Name UIUtils.SetLabel(self.txt_StageAttr, UIUtils.GetLocalizedTxt(Const_IDS[attrName])..UTL.Color.FormatGreenColor("+"..attrData.AttrNum)) UIUtils.SetActive(self.group_StageTitle.gameObject,true) end end function UIDivineWeaponBreak:OnPointerUp(comp, eventData) local heroInfo = MDL.HeroSelect.GetHeroInfo(self.weaponId) local weaponLevel = heroInfo.magicWeaponLevel or 0 local weaponStar = (heroInfo.magicWeaponStar or 0 )+1 logging.log(LTAG.LOG," OnPointerUp ",weaponStar) local max = MDL.DivineWeapon.GetBreakMax(self.weaponId) local isMax = weaponLevel == max if weaponStar == STARMAX or isMax then UIUtils.SetActive(self.group_StageTitle.gameObject,false) return end self.group_StageTitle.transform:SetParent(self.group_unStage[weaponStar].transform, false) local attrData = DataSheetManager.MagicWeaponStarAttr:GetDataByAttrRepeatID(self.data.Attr_Table[weaponStar].AttrRepeat).Attr_Table[1] local attrName = DataSheetManager.AttrData:GetDataByID(attrData.AttrType).Name UIUtils.SetLabel(self.txt_StageAttr, UIUtils.GetLocalizedTxt(Const_IDS[attrName])..UTL.Color.FormatGreenColor("+"..attrData.AttrNum)) end function UIDivineWeaponBreak:Init(data1) self.group_StageTitle.transform:SetParent(self.group_unStage[1].transform, false) local heroInfo = MDL.HeroSelect.GetHeroInfo(data1.MagicWeaponID) ---神兵TiTle if heroInfo then if data1 and data1.MagicWeaponName and data1.MagicWeaponQuality then UIUtils.SetLabel(self.lab_TreasureName, UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[data1.MagicWeaponName]), CTL.HeroAwaken.GetWeaponQuality(data1.MagicWeaponID, MDL.HeroAwaken.GetIsWeaponAwaken(data1.MagicWeaponID)))) -- 神兵名 end UIUtils.SetLabel(self.txt_Break, heroInfo.magicWeaponLevel > 0 and string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Handbook_Hero_BreakLevel), heroInfo.magicWeaponLevel) or "") -- 突破等级 end local appearanceId = MDL.HeroSelect.GetAttrWeaponAppearanceIDByHeroID(data1.MagicWeaponID) self.weaponId = data1.MagicWeaponID --local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(data1.MagicWeaponID) UIUtils.SetLabel(self.txt_TreasureTalent, CTL.DivineWeapon.GetWeaponIntelligence(data1.MagicWeaponID)) -- 神兵资质 ---神兵TiTle local weaponLevel = heroInfo.magicWeaponLevel or 0 local weaponStar = (heroInfo.magicWeaponStar or 0 )+1 local max = MDL.DivineWeapon.GetBreakMax(data1.MagicWeaponID) local isMax = weaponLevel == max local heroBreakLevel = heroInfo.starLevel local data = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(appearanceId,weaponLevel) if not data then data = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(data1.MagicWeaponID,weaponLevel) end if weaponStar == STARMAX or isMax then UIUtils.SetActive(self.StarActive.gameObject,true) self.effect_StarBreak:PlayUIEffect() UIUtils.SetActive(self.group_StageTitle.gameObject,false) if not isMax then local costData = DataSheetManager.MagicWeaponStarItem:GetDataByItemRepeatID(data.Item_Table[weaponStar].ItemRepeat) self:SetCostInfo(costData.Item_Table) end else local costData = DataSheetManager.MagicWeaponStarItem:GetDataByItemRepeatID(data.Item_Table[weaponStar].ItemRepeat) self:SetCostInfo(costData.Item_Table) UIUtils.SetActive(self.StarActive.gameObject,false) self.effect_StarBreak:StopUIEffect() UIUtils.SetActive(self.group_StageTitle.gameObject,true) self.group_StageTitle.transform:SetParent(self.group_unStage[weaponStar].transform, false) UIUtils.SetActive(self.group_StageTitle.gameObject, true) local attrData = DataSheetManager.MagicWeaponStarAttr:GetDataByAttrRepeatID(data.Attr_Table[weaponStar].AttrRepeat).Attr_Table[1] local attrName = DataSheetManager.AttrData:GetDataByID(attrData.AttrType).Name UIUtils.SetLabel(self.txt_StageAttr, UIUtils.GetLocalizedTxt(Const_IDS[attrName])..UTL.Color.FormatGreenColor("+"..attrData.AttrNum)) end self.data = data self:SetStageIcon(isMax,weaponStar-1) self:RefreshStar(isMax,weaponLevel+1) if isMax or (weaponStar == STARMAX and heroBreakLevel == weaponLevel) or heroBreakLevel < weaponLevel then if isMax then self.obj_FullState:SetState(2) local count = MDL.Bag.GetItemCount(data1.PieceItem) or 0 UTL.Item.SetItemCell(self.obj_fullItem, data1.PieceItem, count) else self.obj_FullState:SetState(1) end else self.obj_FullState:SetState(0) self:ShowSkillInfo() end -- 万能碎片HUD if data1.MagicWeaponQuality == LuaConst.QualityColor.Gold then UIUtils.SetActive(self.currency_Info.gameObject, true) CTL.Currency.OpenCurrencyPanel(self.__viewClassPath, self.currency_Info, {goldWeaponFragmentItemID}) elseif data1.MagicWeaponQuality == LuaConst.QualityColor.DarkGold then UIUtils.SetActive(self.currency_Info.gameObject, true) CTL.Currency.OpenCurrencyPanel(self.__viewClassPath, self.currency_Info, {superGoldWeaponFragmentItemID}) else UIUtils.SetActive(self.currency_Info.gameObject, false) end self:UpdateAwakenEntry() end function UIDivineWeaponBreak:SetStageIcon(isMax, weaponLevel) if isMax then weaponLevel = STARMAX - 1 end for i, v in ipairs(self.group_Stage) do if i > weaponLevel then v.LightStage:StopUIEffect() UIUtils.SetActive(v.gameObject, false) else v.LightStage:PlayUIEffect() UIUtils.SetActive(v.gameObject, true) end end self.lines:SetState(weaponLevel) end function UIDivineWeaponBreak:RefreshStar(isMax, weaponLevel) if isMax then UIUtils.SetActive(self.group_StarTitle.gameObject, false) else UIUtils.SetActive(self.group_StarTitle.gameObject, true) UIUtils.SetLabel(self.txt_StarNum, string.FormatByIdsId(Const_IDS.IDS_HeroStarLevel, weaponLevel)) end end function UIDivineWeaponBreak:RefreshTitle(isMax, heroStar) if isMax then UIUtils.SetActive(self.img_Arrow, false) else UIUtils.SetActive(self.img_Arrow, true) end end function UIDivineWeaponBreak:RefreshInfo() local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(self.weaponId) self:Init(weaponData) if CTL.HeroAwaken.IsShowWeaponAwakenEntry(self.weaponId) then self:OnButtonClicked(self.btn_Return) end end function UIDivineWeaponBreak:RefreshCost() self:SetCostInfo(self.costData) end function UIDivineWeaponBreak:SetCostInfo(costData) local index = 1 self.itemNotEnough = false UTL.Item.SetItemCell(self.group_Item[1],costData[1].ItemID,self:GetItemStr(costData[1].ItemID,costData[1].ItemNum)) UIUtils.SetActive(self.group_Item[1].gameObject, true) if costData[2] and costData[2].ItemID > 0 then self.itemId2 = costData[2].ItemID UTL.Item.SetItemCell(self.group_Item[2],costData[2].ItemID,self:GetItemStr(costData[2].ItemID,costData[2].ItemNum)) UIUtils.SetActive(self.group_Item[2].gameObject, true) else UIUtils.SetActive(self.group_Item[2].gameObject, false) end self.itemId1 = costData[1].ItemID self.costData = costData --print(self.weaponId.. MDL.Player.HeroIsLineUp(self.weaponId)) if MDL.Player.HeroIsLineUp(self.weaponId) then self.btn_Break:SetRedPoint(not self.itemNotEnough) UIUtils.SetActive(self.img_YelPoint, false) else self.btn_Break:SetRedPoint(false) UIUtils.SetActive(self.img_YelPoint, not self.itemNotEnough) end self.Loc_ChangeColor:SetState(self.itemNotEnough and 1 or 0) end function UIDivineWeaponBreak:GetItemStr(id,needCount) local haveCount = MDL.Bag.GetItemCount(id) if needCount<=haveCount then return UTL.Color.FormatQualityText(haveCount,1).."/"..needCount else self.itemNotEnough = true return UTL.Color.FormatRedColor(haveCount).."/"..needCount end end function UIDivineWeaponBreak:OnButtonClicked(comp) if comp == self.btn_Break then if self.itemNotEnough then local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(self.weaponId) if weaponData and (weaponData.MagicWeaponQuality == LuaConst.QualityColor.Gold or weaponData.MagicWeaponQuality == LuaConst.QualityColor.DarkGold) then local bag1Count = MDL.Bag.GetItemCount(self.costData[1].ItemID) if bag1Count < self.costData[1].ItemNum then if self.costData[2] then local bag2Count = MDL.Bag.GetItemCount(self.costData[2].ItemID) if bag2Count >= self.costData[2].ItemNum then if self:OnWeaponFragmentExchange(weaponData, bag1Count) then return end end else if self:OnWeaponFragmentExchange(weaponData, bag1Count) then return end end end end CTL.Tips.AddTipsMsg(Const_IDS["IDS_MagicWeapon_StarItemNotEnough"]) else MDL.DivineWeapon.BreakMagicWeaponRequest(self.weaponId) end elseif comp == self.btn_Enlarge or comp == self.btn_ShowSkillTips then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDivineWeaponBreakInfoView, {weaponId = self.weaponId}, "HeroShow/UIHeroInfoView") elseif self.group_Item[1].event_Click == comp then UTL.ItemTips.ShowCommonTipsById(self.itemId1) elseif self.group_Item[2].event_Click == comp then UTL.ItemTips.ShowCommonTipsById(self.itemId2) elseif self.btn_Resonance == comp then UIManager.OpenView(Const_UI_Lua.UIEnum.UIResonanceInfo, {subResonanceID = resonance_info.Weapon_Break, isShowGoto = false}) elseif self.obj_fullItem.event_Click == comp then local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(self.weaponId) UTL.ItemTips.ShowCommonTipsById(weaponData.PieceItem) elseif self.btn_Return == comp then EventSystem.Dispatch(EventID.UI_HeroAwaken_ReturnBreak, false) elseif self.btn_FullBreak == comp then CTL.Reborn.OpenRecycleFragmentView() end end ---@public 下级突破预览(基础属性、技能加成) function UIDivineWeaponBreak:ShowSkillInfo() local weaponId = MDL.HeroSelect.GetAttrWeaponAppearanceIDByHeroID(self.weaponId) local weaponStar = self.data.Star + 1 local currData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(weaponId, self.data.Star) local nextData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(weaponId, weaponStar) local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(self.weaponId) self.txt_SkillTitle.text = string.FormatByIdsId(Const_IDS.IDS_Horse_Star_8, weaponStar) if nextData.StarType == LuaConst.UIBreakStarType.Attrs then self.state_BreakInfo:SetState(1) local attrText = CTL.DivineWeapon.GetDivineWeaponBreakAttrTextList(weaponId, weaponStar, UTL.Color.Green) for k,v in ipairs(self.group_Attr) do UIUtils.SetLabel(v, attrText[k]) end else self.state_BreakInfo:SetState(0) local skillData = DataSheetManager.SkillData:GetDataByID(weaponData.ActivationMusouSkillID) local skillPath = ConstAssetPathConfig.skillPath..skillData.Icon..".png" UIUtils.SetImageByAssetBundle(self.img_Skill, skillPath) local skillTipData = DataSheetManager.SkillTipsData:GetDataByID(weaponData.ActivationMusouSkillID) UIUtils.SetLabel(self.txt_SkillName, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BreakThrough_SkillName), UIUtils.GetLocalizedTxt(Const_IDS[skillTipData.Name]))) UIUtils.SetLabel(self.txt_LevelNow, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BreakThrough_Level), currData.MusouLevel)) UIUtils.SetLabel(self.txt_LevelNext, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BreakThrough_Level), nextData.MusouLevel)) end end -- 万能碎片兑换 function UIDivineWeaponBreak:OnWeaponFragmentExchange(weaponData, bag1Count) local fragmentItemID if weaponData.MagicWeaponQuality == LuaConst.QualityColor.Gold then -- 金神兵万能碎片 fragmentItemID = goldWeaponFragmentItemID elseif weaponData.MagicWeaponQuality == LuaConst.QualityColor.DarkGold then -- 彩金神兵万能碎片 fragmentItemID = superGoldWeaponFragmentItemID end if MDL.Bag.GetItemCount(fragmentItemID) > 0 then -- 兑换弹窗 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonExchange, {costItemId = fragmentItemID, giveItemId = self.costData[1].ItemID, needCount = self.costData[1].ItemNum - bag1Count}) return true end return false end function UIDivineWeaponBreak:UpdateAwakenEntry() UIUtils.SetActive(self.btn_Return, CTL.HeroAwaken.IsShowWeaponAwakenEntry(self.weaponId)) end return UIDivineWeaponBreak