local UIDivineWeaponForgePanel = UIViewClass() local resonance_info = require 'Proto/resonance_info_pb' local EventSystem = require('Event/EventSystem') local SMALL_FORGE_POINT = 1 local FULL_FORGE_POINT = 2 local SKILLED_FORGE_POINT = 3 local SKILL_FORGE_POINT = 4 local TERMINAL_FORGE_POINT = 5 local CENTER_LINE_TYPE = 1 local TOP_LINE_TYPE = 2 local BOTTOM_LINE_TYPE = 3 local SkillPath = ConstAssetPathConfig.SkillImagePath ---------------------------------- 系统函数 ------------------------------------ function UIDivineWeaponForgePanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_DivineWeapon_ForgeUpdate, self.RefreshPanel) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_ResonanceChange_Refresh, self.RefreshResonanceLv) self:RegistSystemEvent(EventID.UI_DivineWeapon_ForgeSoul_Update, self.RefreshForgeSoulBtn) UIUtils.SetActive(self.bottom_Btn, false) self:RefreshResonanceLv() self:RefreshPanel(context) self:SetPushStyle(LuaConst.PushStyleEnum.CLOSENOTRECOVER) self:RefreshForgeSoulBtn() end function UIDivineWeaponForgePanel:RefreshForgeSoulBtn() local isShowForgeSoul = CTL.DivineWeapon.IsDivineWeaponForgeMax(self.heroId) and CTL.HeroSelect.IsSuperGoldHero(self.heroId) and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.WeaponForgeSoul) UIUtils.SetActive(self.btn_ForgeSoul, isShowForgeSoul) self.btn_ForgeSoul:SetRedPoint(CTL.DivineWeaponForgeSoul.GetIsShowRedpoint(self.heroId)) end function UIDivineWeaponForgePanel:OnClosed() EventSystem.Dispatch(EventID.UI_DivineWeapon_CloseForgePanel) end function UIDivineWeaponForgePanel:OnButtonClicked(comp) if comp == self.bottom_Btn then self.TipView:CloseAll() UIUtils.SetActive(self.bottom_Btn, false) elseif comp == self.group_Btns.btn_Forge or comp == self.group_Btns.Btn_SmallBoost then local itemRepeatData = DataSheetManager.MagicWeaponFoundryItemRepeat:GetDataByItemRepeatID(self.pointData.ItemRepeat) if itemRepeatData and itemRepeatData.Item_Table[1] then local _, isEnough = self:GetItemStr(itemRepeatData.Item_Table[1].ItemID, itemRepeatData.Item_Table[1].ItemNum) if not isEnough then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Foundry_LackItem"]) return end end if itemRepeatData and itemRepeatData.Item_Table[2] then local _, isEnough = self:GetItemStr(itemRepeatData.Item_Table[2].ItemID, itemRepeatData.Item_Table[2].ItemNum) if not isEnough then CTL.Tips.AddTipsMsg(Const_IDS["IDS_Foundry_LackItem"]) return end end MDL.DivineWeapon.FoundryActivateRequest(self.heroId, self.pointData.PointID, self.pointData.LineType) elseif comp == self.group_Info1.Btn then CTL.Tips.OpenHeroSkillTips(self.TipView, self.heroId, self.baseSkillID) UIUtils.SetActive(self.bottom_Btn, true) elseif comp == self.group_Btns.item1.event_Click then local itemRepeatData = DataSheetManager.MagicWeaponFoundryItemRepeat:GetDataByItemRepeatID(self.pointData.ItemRepeat) if itemRepeatData and itemRepeatData.Item_Table[1] then UTL.ItemTips.ShowCommonTipsById(itemRepeatData.Item_Table[1].ItemID) end elseif comp == self.group_Btns.item2.event_Click then local itemRepeatData = DataSheetManager.MagicWeaponFoundryItemRepeat:GetDataByItemRepeatID(self.pointData.ItemRepeat) if itemRepeatData and itemRepeatData.Item_Table[2] then UTL.ItemTips.ShowCommonTipsById(itemRepeatData.Item_Table[2].ItemID) end elseif comp == self.btn_Enlarge then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.DivineWeaponForge}) elseif comp == self.btn_Resonance then UIManager.OpenView(Const_UI_Lua.UIEnum.UIResonanceInfo, {subResonanceID = resonance_info.Weapon_Foundry, isShowGoto = false}) elseif comp == self.btn_ForgeSoul then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIWeaponForgeSoulMain, {heroId = self.heroId}) end end -------------------------------------------------------------------------------- function UIDivineWeaponForgePanel: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_Foundry))) end function UIDivineWeaponForgePanel:RefreshPanel(context) if context then self.pointData = context.pointData self.heroId = context.heroId end local group_info1 = self.group_Info1 local group_info2 = self.group_Info2 UIUtils.SetActive(group_info1.group_Skill, false) UIUtils.SetActive(group_info1.group_Attributes, false) UIUtils.SetActive(group_info2.group_AllAttribute, false) UIUtils.SetActive(group_info2.group_Attr.gameObject, false) UIUtils.SetActive(group_info2.group_Skill.gameObject, false) local state = CTL.DivineWeapon.GetPointState(self.heroId, self.pointData) UIUtils.SetGray(group_info1.img_InfoBg, state ~= CTL.DivineWeapon.ForgePointState.Activate) UIUtils.SetGray(group_info1.img_SkillIconBg, state ~= CTL.DivineWeapon.ForgePointState.Activate) UIUtils.SetGray(group_info1.img_SkillIcon, state ~= CTL.DivineWeapon.ForgePointState.Activate) UIUtils.SetGray(group_info1.img_AttrIconSmall, state ~= CTL.DivineWeapon.ForgePointState.Activate) UIUtils.SetGray(group_info1.img_AttrIconBig, state ~= CTL.DivineWeapon.ForgePointState.Activate) if self.pointData.PointType == SKILLED_FORGE_POINT or self.pointData.PointType == SKILL_FORGE_POINT then UIUtils.SetActive(group_info1.group_Skill, true) local showDataId = CTL.DivineWeapon.MagicWeaponFoundryShowID(self.pointData) local skillData = DataSheetManager.SkillTipsData:GetDataByID(showDataId) UIUtils.SetImageByAssetBundle(group_info1.img_SkillIcon, string.format(SkillPath, skillData.SkillIcon)) UIUtils.SetLabelText(group_info1.txt_SkillName, Const_IDS[skillData.Name]) UIUtils.SetActive(group_info2.group_Skill.gameObject, true) local baseSkillID, level = CTL.DivineWeapon.GetLineSkillBaseIDAndSkillLevel(self.pointData) self.baseSkillID = baseSkillID local levelStr = string.FormatByIdsId(Const_IDS["IDS_TalentSkill_Level"], level) UIUtils.SetLabel(group_info2.group_Skill.txt_SkillInfo, levelStr .. " " .. UTL.String.FormatCombineTextByID(skillData.TipsFunc)) else UIUtils.SetActive(group_info1.group_Attributes, true) local isShowSmall = self.pointData.LineType == CENTER_LINE_TYPE or self.pointData.LineType == BOTTOM_LINE_TYPE or self.pointData.LineType == TOP_LINE_TYPE UIUtils.SetActive(group_info1.img_AttrIconSmall, isShowSmall) UIUtils.SetActive(group_info1.img_AttrIconBig, not isShowSmall) if isShowSmall then UIUtils.SetAtlasImage(group_info1.img_AttrIconSmall, "UI_WeaponHero", self.pointData.Icon) else UIUtils.SetAtlasImage(group_info1.img_AttrIconBig, "UI_WeaponHero", self.pointData.Icon) end end local attrRepeatData = DataSheetManager.MagicWeaponFoundryAttrRepeat:GetDataByAttrRepeatID(self.pointData.AttrRepeat) if attrRepeatData then UIUtils.SetActive(group_info2.group_Attr.gameObject, true) for i = 1, #group_info2.group_Attr do local attrItem = group_info2.group_Attr[i] local attrData = attrRepeatData.Attr_Table[i] if attrData then UIUtils.SetActive(attrItem.gameObject, true) UTL.Attr.SetAttrItemByCompName(attrItem, attrData.AttrType, attrData.AttrNum, true) else UIUtils.SetActive(attrItem.gameObject, false) end end end local group_Btns = self.group_Btns if state == CTL.DivineWeapon.ForgePointState.Activate then group_Btns.state_UnlockConditions:SetState(3) else for _, v in ipairs (group_Btns.group_UnlockConditions) do UIUtils.SetActive(v.gameObject, false) end local index = 1 local needPointCount = #self.pointData.NeedPoint local isCompleteCon = true if needPointCount > 0 then local cond = group_Btns.group_UnlockConditions[index] for _, pointID in ipairs (self.pointData.NeedPoint) do local relyPointData = DataSheetManager.MagicWeaponFoundry:GetDataByID_PointID(self.pointData.ID, pointID) local relyPointState = CTL.DivineWeapon.GetPointState(self.heroId, relyPointData) if relyPointState ~= CTL.DivineWeapon.ForgePointState.Activate then isCompleteCon = false break end end UIUtils.SetActive(cond.gameObject, true) local str = UIUtils.GetLocalizedTxt(needPointCount == 1 and Const_IDS["IDS_Foundry_LastPoint"] or Const_IDS["IDS_Foundry_DoublePoint"]) UIUtils.SetLabel(cond.txt_Conditions, isCompleteCon and UTL.Color.FormatWhiteColor(str) or UTL.Color.FormatRedColor(str)) index = index + 1 end local triggerData = self.pointData.triggerID>0 and DataSheetManager.TriggerID:GetDataByID(self.pointData.triggerID) or nil local triggerCondTable = triggerData and triggerData.Unlock_Table or nil if triggerCondTable then for _, triggerCond in ipairs (triggerCondTable) do local cond = group_Btns.group_UnlockConditions[index] local isComplete = MDL.Unlock.IsTriggerComplete(triggerCond.UnlockCondition, nil, triggerCond.UnlockConditionParamA, triggerCond.UnlockConditionParamB) UIUtils.SetActive(cond.gameObject, true) UIUtils.SetLabel(cond.txt_Conditions, MDL.Unlock.GetDesByTriggerID(triggerCond, isComplete)) if not isComplete then isCompleteCon = false end index = index + 1 end end local itemRepeatData = self.pointData.ItemRepeat>0 and DataSheetManager.MagicWeaponFoundryItemRepeat:GetDataByItemRepeatID(self.pointData.ItemRepeat) or nil local itemCount = 1 local hasEnoughItem = true if itemRepeatData and #itemRepeatData.Item_Table > 0 then itemCount = #itemRepeatData.Item_Table local item_1 = itemRepeatData.Item_Table[1] local item_2 = itemRepeatData.Item_Table[2] if itemCount == 2 then local itemNumStr_1, itemEnough_1 = self:GetItemStr(item_1.ItemID, item_1.ItemNum) local itemNumStr_2, itemEnough_2 = self:GetItemStr(item_2.ItemID, item_2.ItemNum) hasEnoughItem = itemEnough_1 and itemEnough_2 UTL.Item.SetItemCell(group_Btns.item1, item_1.ItemID, itemNumStr_1, false) UTL.Item.SetItemCell(group_Btns.item2, item_2.ItemID, itemNumStr_2, false) else local itemNumStr_1, itemEnough_1 = self:GetItemStr(item_1.ItemID, item_1.ItemNum) hasEnoughItem = itemEnough_1 UTL.Item.SetItemCell(group_Btns.item1, item_1.ItemID, itemNumStr_1, false) end end if isCompleteCon then self.group_Btns.btn_Forge:SetGray(not hasEnoughItem, true) group_Btns.state_UnlockConditions:SetState(itemCount == 2 and 1 or 2) else group_Btns.state_UnlockConditions:SetState(0) end end end function UIDivineWeaponForgePanel:GetItemStr(id, needCount) local haveCount = MDL.Bag.GetItemCount(id) if needCount <= haveCount then return UTL.Color.FormatQualityText(haveCount,1).."/"..needCount, true else return UTL.Color.FormatRedColor(haveCount).."/"..needCount, false end end return UIDivineWeaponForgePanel