local UIDivineWeaponBasePanel = UIViewClass() --几个数据说明 --self.data 神兵数据 默认神兵数据 --self.curShowWeaponId 当前神兵id --self.curShowAppearanceId 当前展示的时装 local CONST_INDEX_BREAK = 0 local CONST_INDEX_AWAKEN_SKILL = 1 local CONST_INDEX_APPEARANCE = 2 local CONST_INDEX_FORGE = 3 local CONST_AWAKEN_BG = "Assets/UI/Image/UI_DivineWeapon/sbyc_bg_01.png" function UIDivineWeaponBasePanel:OnCreated() if GameAppInfo.IsVersionGreaterThan19000() then --删除版本判断时,需要同步删除界面上的model节点 UIUtils.SetActive(self.model, false) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.weaponModel) self:RegistTriggerEvent(self.weaponModel, UIEventTriggerType.Drag) self:StartRepeatFunc(self.AutoRotate, 0, -1, true) end end function UIDivineWeaponBasePanel:OnDrag(comp, eventData) UTL.UIRender.RotateMagicWeapon(self.modelComponentDataHandle, -eventData.delta.x * 0.2) end function UIDivineWeaponBasePanel:AutoRotate(deltaTime, timeSinceUpdate) UTL.UIRender.RotateMagicWeapon(self.modelComponentDataHandle, deltaTime*10) end function UIDivineWeaponBasePanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_WeaponAppearance_ChangePreviewAppearance, self.ChangePreviewAppearance) self:RegistSystemEvent(EventID.UI_DivineWeapon_Update, self.OnDivineWeaponUpdate) self:RegistSystemEvent(EventID.BagItem_Update, self.RefreshRedPoint) self:RegistSystemEvent(EventID.UI_Appearance_Refresh, self.RefreshRedPoint) self:RegistSystemEvent(EventID.UI_DivineWeapon_ForgeUpdate, self.RefreshRedPoint) self:RegistSystemEvent(EventID.UI_DivineWeapon_ForgeSoul_Update, self.RefreshRedPoint) self:RegistSystemEvent(EventID.UI_HeroAwaken_UpdateWeaponBreakInfo, self.RefreshRedPoint) self:RegistSystemEvent(EventID.UI_CheatGreenBg, self.SetCheatGreenBg) self:RegistSystemEvent(EventID.UI_HeroAwaken_ReturnBreak, self.OnReturnBreak) self:RegistSystemEvent(EventID.UI_HeroAwaken_WeaponAwaken, self.InitToggles) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.OnFunctionUnlockUpdate) self:RegistSystemEvent(EventID.UI_HeroAwaken_UpdateWeaponAwakenSkillInfo, self.RefreshRedPoint) local mainCanvas = self.gameObject:GetComponent(typeof(UnityEngine.Canvas)) UIUtils.SetCanvasSortingOrderByMainCanvas(mainCanvas, self.Refer_Title.gameObject:GetComponent(typeof(UnityEngine.Canvas)), 201) UIUtils.SetCanvasSortingOrderByMainCanvas(mainCanvas, self.group_Main, 201) self.isInit = false UIManager.ActiveUIModle(false, "UIDivineWeaponBasePanel") self.isFormation = context.isFormation self.weaponAppearanceId = context.weaponAppearanceId self.data = context.data self:ShowWeaponInfo(self.data) self.curToggleIndex = 0 self:InitToggles(context.selectIndex) self:RegistSystemEvent(EventID.UI_DivineWeapon_Update, self.RefreshInfo) self:RegistSystemEvent(EventID.UI_DivineWeapon_OnCloseGamePlay, self.OnCloseActivity) -- 设置标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Magical) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self.isInit = true if context.toggleType then for i, v in ipairs(self.toggleList) do if v == context.toggleType then if self.curToggleIndex ~= i - 1 then self.curToggleIndex = i - 1 if self.curToggleIndex < self.toggles.ActiveCount then self.toggles:SelectIndex(self.curToggleIndex) end end break end end end self:RefreshRedPoint() end function UIDivineWeaponBasePanel:OnDivineWeaponUpdate(data) if data and data.isBreak then self:InitToggles() end self:RefreshRedPoint() end function UIDivineWeaponBasePanel:OnCloseActivity() self:CloseView(true) end function UIDivineWeaponBasePanel:ChangePreviewAppearance(id) self:RefreshInfo(true) self:ShowAppearanceWeapon(id) end function UIDivineWeaponBasePanel:RefreshInfo(init) self:UpdateBtnsRedPoint() self.heroInfo = MDL.HeroSelect.GetHeroInfo(self.curShowWeaponId) local effectTable = {} if self.heroInfo and self.heroInfo.isMagicWeaponActive then local starData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(self.curShowAppearanceId, self.heroInfo.magicWeaponLevel) if not starData then starData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(self.curShowWeaponId, self.heroInfo.magicWeaponLevel) end local weaponModelData = DataSheetManager.MagicWeaponModel:GetDataByID(starData.PreviewModel) for i, v in ipairs(weaponModelData.ModelPart_Table) do effectTable[i] = v.MagicWeaponInitialShowEffect[starData.EffectLevel] end end if GameAppInfo.IsVersionGreaterThan19000() then for index, effectPath in ipairs(effectTable) do UTL.UIRender.ChangeMagicWeaponnEffect(self.modelComponentDataHandle, effectPath, index-1) end else self.model:ChangeWeaponEffect(effectTable) end if not init then local starLevel = 0 if self.heroInfo and self.heroInfo.isMagicWeaponActive and self.heroInfo.magicWeaponLevel > 0 then starLevel = self.heroInfo.magicWeaponLevel end self:ShowSkillInfo(self.curShowAppearanceId, starLevel) end end function UIDivineWeaponBasePanel:SetCheatGreenBg(color, clearEffect) if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.SetCheatGreenBg(self.modelComponentDataHandle, color, clearEffect) else self.model:SetCheatGreenBg(color,clearEffect) end self.cheatBgColor = color self.cheatClearEff = clearEffect end function UIDivineWeaponBasePanel:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) UIManager.ActiveUIModle(true, "UIDivineWeaponBasePanel") if self.isFormation then MDL.HeroSelect.curSelectHeroID = self.curShowWeaponId end if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.DisposeMagicWeaponOther(self.modelComponentDataHandle) UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) else self.model:SetSceneShadowPlane(true) end UIManager.CloseView(Const_UI_Lua.UIEnum.UIDivineWeaponForgePanel) end function UIDivineWeaponBasePanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIDivineWeaponBasePanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif self.btn_Next == comp and not MDL.DivineWeapon.IsActiveState() then self:ShowNext() elseif self.btn_Before == comp and not MDL.DivineWeapon.IsActiveState() then self:ShowPre() elseif comp == self.btn_SkillTips then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDivineWeaponSkillTips, { divineWeaponId = self.curShowWeaponId, appearanceId = self.curShowAppearanceId }, "Common/UITalentSkillTips") end end function UIDivineWeaponBasePanel:GetMagicWeaponAppearanceId(weaponId, heroInfo) if heroInfo and self.heroInfo.isMagicWeaponActive then if heroInfo.curWeaponAppearanceId == 0 then return weaponId else return heroInfo.curWeaponAppearanceId end else return weaponId end end function UIDivineWeaponBasePanel:InitToggles(selectIndex) if not self.toggleList then self.toggleList = LuaExt.CreateTable(4) else table.clear(self.toggleList) end if not self.idsList then self.idsList = LuaExt.CreateTable(4) else table.clear(self.idsList) end -- 无论既不激活 都要显示外观 local appearanceDataList = MDL.Appearance.GetAppearanceDataByHeroID(self.curShowWeaponId, MDL.Appearance.AppearanceType.Weapon) self.isShowAppearance = #appearanceDataList > 1 and MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.WeaponAppearance) if self.heroInfo and self.heroInfo.isMagicWeaponActive then -- 突破 if CTL.HeroAwaken.IsShowWeaponAwakenEntry(self.curShowWeaponId) then table.insert(self.idsList, Const_IDS.IDS_HeroAwaken_FunctionName) table.insert(self.toggleList, UTL.Toggle.ToggleType.HeroAwaken) else table.insert(self.idsList, Const_IDS.IDS_HeroStarUp) table.insert(self.toggleList, UTL.Toggle.ToggleType.Breakthrough) end -- 灵识 local isWeaponAwaken = MDL.HeroAwaken.GetIsWeaponAwaken(self.curShowWeaponId) if isWeaponAwaken then table.insert(self.idsList, Const_IDS.IDS_HeroAwaken_LingShi) table.insert(self.toggleList, UTL.Toggle.ToggleType.WeaponAwakenSkill) end -- 外观 if self.isShowAppearance then table.insert(self.idsList, Const_IDS.IDS_Appearance_Title) table.insert(self.toggleList, UTL.Toggle.ToggleType.Appearance) end -- 锻铸 local isShowForge = MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.DivineWeaponForge) and CTL.DivineWeapon.GetForgeTemplateID(self.data.MagicWeaponID) ~= 0 if isShowForge then table.insert(self.idsList, Const_IDS.IDS_Foundry_Button) table.insert(self.toggleList, UTL.Toggle.ToggleType.Forge) end else -- 激活 table.insert(self.idsList, Const_IDS.IDS_MagicWeapon_SmallActivation_Button) table.insert(self.toggleList, UTL.Toggle.ToggleType.Activation) -- 外观 if self.isShowAppearance then table.insert(self.idsList, Const_IDS.IDS_Appearance_Title) table.insert(self.toggleList, UTL.Toggle.ToggleType.Appearance) end end UTL.Toggle.InitToggleGroupByIDS(self.toggles, "text", self.idsList) for i, toggleType in ipairs (self.toggleList) do if toggleType == UTL.Toggle.ToggleType.Breakthrough then self:SetToggleRp(i - 1, MDL.DivineWeapon.GetEnoughLevel(self.data)) self.toggles:SetToggleCompImage(i, "img_bg_icon", UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.Breakthrough)) self.toggles:SetToggleCompImage(i, "img_SelectedIcon1", UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.Breakthrough)) elseif toggleType == UTL.Toggle.ToggleType.HeroAwaken then self.toggles:SetToggleCompImage(i, "img_bg_icon", UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.HeroAwaken)) self.toggles:SetToggleCompImage(i, "img_SelectedIcon1", UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.HeroAwaken)) elseif toggleType == UTL.Toggle.ToggleType.Activation then self:SetToggleRp(i - 1, MDL.DivineWeapon.GetEnoughLevel(self.data)) self.toggles:SetToggleCompImage(i, "img_bg_icon", UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.Activation)) self.toggles:SetToggleCompImage(i, "img_SelectedIcon1", UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.Activation)) elseif toggleType == UTL.Toggle.ToggleType.Appearance then self:SetToggleRp(i - 1, CTL.Appearance.IsShowWeaponRedPoint(self.curShowWeaponId)) self.toggles:SetToggleCompImage(i, "img_bg_icon", UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.Appearance)) self.toggles:SetToggleCompImage(i, "img_SelectedIcon1", UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.Appearance)) elseif toggleType == UTL.Toggle.ToggleType.Forge then self:SetToggleRp(i - 1, CTL.DivineWeapon.HasForgeRP(self.curShowWeaponId)) self.toggles:SetToggleCompImage(i, "img_bg_icon", UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.Forge)) self.toggles:SetToggleCompImage(i, "img_SelectedIcon1", UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.Forge)) elseif toggleType == UTL.Toggle.ToggleType.WeaponAwakenSkill then self:SetToggleRp(i - 1, CTL.DivineWeapon.HasForgeRP(self.curShowWeaponId)) self.toggles:SetToggleCompImage(i, "img_bg_icon", UTL.Toggle.GetToggleNormalIcon(UTL.Toggle.ToggleType.WeaponAwakenSkill)) self.toggles:SetToggleCompImage(i, "img_SelectedIcon1", UTL.Toggle.GetToggleSelectedIcon(UTL.Toggle.ToggleType.WeaponAwakenSkill)) end end self:UpdateBtnsRedPoint() if selectIndex then self.curToggleIndex = selectIndex end if self.curToggleIndex < self.toggles.ActiveCount then self.toggles:SelectIndex(self.curToggleIndex) else self.toggles:SelectIndex(0) end end function UIDivineWeaponBasePanel:CheckType(index, type) if not index then return false end local toggleType = self.toggleList[index + 1] if not toggleType then return end if toggleType == UTL.Toggle.ToggleType.Activation or toggleType == UTL.Toggle.ToggleType.HeroAwaken or toggleType == UTL.Toggle.ToggleType.Breakthrough then return type == CONST_INDEX_BREAK elseif toggleType == UTL.Toggle.ToggleType.WeaponAwakenSkill then return type == CONST_INDEX_AWAKEN_SKILL elseif toggleType == UTL.Toggle.ToggleType.Appearance then return type == CONST_INDEX_APPEARANCE elseif toggleType == UTL.Toggle.ToggleType.Forge then return type == CONST_INDEX_FORGE end return false end function UIDivineWeaponBasePanel:SetToggleRp(index, value) local activeRp = false if self.toggleList[index + 1] == UTL.Toggle.ToggleType.Appearance then activeRp = CTL.Appearance.CanActiveWeaponAppearance(self.curShowWeaponId) elseif self.toggleList[index + 1] == UTL.Toggle.ToggleType.Activation then activeRp = self.heroInfo and not self.heroInfo.isMagicWeaponActive end if (self.heroInfo and MDL.Player.HeroIsLineUp(self.heroInfo.heroId)) or activeRp then self.toggles:SetRedPoint(index, value) self.toggles:SetToggleCompActive(index + 1, "img_YelPoint", false) else self.toggles:SetToggleCompActive(index + 1, "img_YelPoint", value) self.toggles:SetRedPoint(index, false) end end function UIDivineWeaponBasePanel:ShowWeaponInfo(data) self.data = data self.curShowWeaponId = data.MagicWeaponID self.context = { data = self.data, isFormation = self.isFormation } local weaponEffect = {} local weaponModelData self.heroInfo = MDL.HeroSelect.GetHeroInfo(self.curShowWeaponId) local appearanceId = self:GetMagicWeaponAppearanceId(self.curShowWeaponId, self.heroInfo) self.curShowAppearanceId = appearanceId local effectLevel = nil if self.heroInfo and self.heroInfo.isMagicWeaponActive then if appearanceId ~= self.curShowWeaponId then local appearanceData = MDL.Appearance.GetAppearanceDataByHeroID_AppearanceID(self.curShowWeaponId, self.curAppearanceID, MDL.Appearance.AppearanceType.Hero) self.txt_Weapon.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[data.MagicWeaponName]), data.MagicWeaponQuality) else self.txt_Weapon.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[data.MagicWeaponName]), data.MagicWeaponQuality) end local starData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(appearanceId, self.heroInfo.magicWeaponLevel) if not starData then starData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(self.curShowWeaponId, self.heroInfo.magicWeaponLevel) end weaponModelData = DataSheetManager.MagicWeaponModel:GetDataByID(starData.PreviewModel) for i, v in ipairs(weaponModelData.ModelPart_Table) do local tmp = { weaponPath = v.Prefeb, effectPath = v.MagicWeaponInitialShowEffect[starData.EffectLevel], idleState = v.MagicWeaponAction } table.insert(weaponEffect, tmp) end effectLevel = starData.EffectLevel else weaponModelData = DataSheetManager.MagicWeaponModel:GetDataByID(data.PreviewModel) for i, v in ipairs(weaponModelData.ModelPart_Table) do local tmp = { weaponPath = v.Prefeb, effectPath = v.MagicWeaponInitialShowEffect[data.EffectLevel], idleState = v.MagicWeaponAction } table.insert(weaponEffect, tmp) end effectLevel = data.EffectLevel end UTL.Item.ItemSquareIconByHeroId(self.curShowWeaponId, self.img_Head, self.img_BgHead, nil, MDL.HeroAwaken.GetIsHeroAwaken(self.curShowWeaponId)) local starLevel = 0 if self.heroInfo and self.heroInfo.isMagicWeaponActive and self.heroInfo.magicWeaponLevel > 0 then starLevel = self.heroInfo.magicWeaponLevel end self:ShowSkillInfo(appearanceId, starLevel) self:ShowWeaponModel(weaponModelData, weaponEffect, effectLevel) UIUtils.SetActive(self.btn_Before, true) UIUtils.SetActive(self.btn_Next, true) UIUtils.SetActive(self.group_Skill, true) if GameAppInfo.IsVersionGreaterThan19000() then UIUtils.SetActive(self.weaponModel, true) else UIUtils.SetActive(self.model, true) end end function UIDivineWeaponBasePanel:ShowWeaponModel(weaponModelData, weaponEffect, effectLevel) if GameAppInfo.IsVersionGreaterThan19000() then local bgPath if (self.breakView or self:CheckType(self.curToggleIndex, CONST_INDEX_BREAK)) and CTL.HeroAwaken.IsShowWeaponAwakenEntry(self.curShowWeaponId) then bgPath = CONST_AWAKEN_BG end UTL.UIRender.CreateMagicWeapon3DModel(self.modelComponentDataHandle, weaponModelData.ID, effectLevel, bgPath) else self.model:ShowWeapon(weaponModelData.ModelNode, weaponEffect, weaponModelData.ModelLight) self.model:SetSceneTexture(ConstAssetPathConfig.Path40) self.model:SetNodePos(1, 0, 0) self.model:SetSceneShadowPlane(false) self.model:SetModelScale(UTL.UIRender.GetModelScale()) end --cheatLogic if self.cheatClearEff and self.cheatBgColor then if GameAppInfo.IsVersionGreaterThan19000() then UTL.UIRender.SetCheatGreenBg(self.modelComponentDataHandle, self.cheatBgColor, self.cheatClearEff) else self.model:SetCheatGreenBg(self.cheatBgColor, self.cheatClearEff) end end end function UIDivineWeaponBasePanel:ShowAppearanceWeapon(id) if id == 0 then id = self.curShowWeaponId end self.curShowAppearanceId = id if id ~= self.curShowWeaponId then local appearanceData = MDL.Appearance.GetAppearanceDataByHeroID_AppearanceID(self.curShowWeaponId, id, MDL.Appearance.AppearanceType.Weapon).appearanceConfig self.txt_Weapon.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[appearanceData.AppearanceName]), appearanceData.MagicWeaponQuality) else self.txt_Weapon.text = UTL.Color.FormatQualityText(UIUtils.GetLocalizedTxt(Const_IDS[self.data.MagicWeaponName]), self.data.MagicWeaponQuality) end local weaponEffect = {} local starLevel = 0 if self.heroInfo then starLevel = self.heroInfo.magicWeaponLevel end local starData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(id, starLevel) if not starData then starData = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(self.curShowWeaponId, starLevel) end local weaponModelData = DataSheetManager.MagicWeaponModel:GetDataByID(starData.PreviewModel) for i, v in ipairs(weaponModelData.ModelPart_Table) do local tmp = { weaponPath = v.Prefeb, effectPath = v.MagicWeaponInitialShowEffect[starData.EffectLevel], idleState = v.MagicWeaponAction } table.insert(weaponEffect, tmp) end self:ShowWeaponModel(weaponModelData, weaponEffect, starData.EffectLevel) local heroInfo = MDL.HeroSelect.GetHeroInfo(self.curShowWeaponId) starLevel = 0 if heroInfo and heroInfo.isMagicWeaponActive and heroInfo.magicWeaponLevel > 0 then starLevel = heroInfo.magicWeaponLevel end self:ShowSkillInfo(id, starLevel) end function UIDivineWeaponBasePanel:CloseSubView() self.subView:CloseAll() self.breakView = nil self.activeView = nil self.appearanceView = nil self.forgeView = nil self.weaponAwakenSkillView = nil local wearId = MDL.HeroSelect.GetWeaponAppearanceIDByID(self.curShowWeaponId) if wearId ~= self.curAppearanceID then self:ShowWeaponInfo(self.data) end end function UIDivineWeaponBasePanel:OnValueChanged(comp, index) if comp == self.toggles then UIUtils.SetActive(self.img_Previewing, false) self.curToggleIndex = index if self:CheckType(index, CONST_INDEX_BREAK) then if self.heroInfo and self.heroInfo.isMagicWeaponActive then self:InitBreakView() else self:InitActiveView() end elseif self:CheckType(index, CONST_INDEX_APPEARANCE) then if self.isShowAppearance then self:InitAppearanceView() else self:InitForgeView() end elseif self:CheckType(index, CONST_INDEX_FORGE) then self:InitForgeView() elseif self:CheckType(index, CONST_INDEX_AWAKEN_SKILL) then self:InitWeaponAwakenSkill() end end end function UIDivineWeaponBasePanel:InitBreakView(isForceBreak) if not self.breakView then self:CloseSubView() if isForceBreak or CTL.HeroAwaken.IsShowWeaponAwakenEntry(self.curShowWeaponId) == false then self.breakView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDivineWeaponBreak)) UIUtils.SetActive(self.group_Skill, true) UIUtils.SetActive(self.img_Previewing, false) else self.breakView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDivineWeaponAwaken)) UIUtils.SetActive(self.group_Skill, false) UIUtils.SetActive(self.img_Previewing, MDL.HeroAwaken.GetIsWeaponAwaken(self.curShowWeaponId) == false) end else if CTL.HeroAwaken.IsShowWeaponAwakenEntry(self.curShowWeaponId) == false then if self.subView:IsViewOpened(Const_UI_Lua.UIEnum.UIDivineWeaponAwaken) then self:CloseSubView() self.breakView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDivineWeaponBreak)) UIUtils.SetActive(self.group_Skill, true) UIUtils.SetActive(self.img_Previewing, false) end else if self.subView:IsViewOpened(Const_UI_Lua.UIEnum.UIDivineWeaponAwaken) == false then self:CloseSubView() self.breakView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDivineWeaponAwaken)) UIUtils.SetActive(self.group_Skill, false) UIUtils.SetActive(self.img_Previewing, MDL.HeroAwaken.GetIsWeaponAwaken(self.curShowWeaponId) == false) end end end self.breakView:Init(self.data) self.curShowView = self.breakView end function UIDivineWeaponBasePanel:InitActiveView() if not self.activeView then self:CloseSubView() self.activeView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDivineWeaponAct)) if self.isInit == false then end end self.activeView:Init(self.data) self.curShowView = self.activeView end function UIDivineWeaponBasePanel:InitAppearanceView() if not self.appearanceView then self:CloseSubView() self.appearanceView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDivineWeaponAppearance), {weaponAppearanceId = self.weaponAppearanceId}, "Common/UICommonAppearance") end self.appearanceView:Init(self.data) self.curShowView = self.appearanceView end function UIDivineWeaponBasePanel:InitForgeView() if not self.forgeView then self:CloseSubView() self.forgeView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDivineWeaponForgeLinePanel), self.data) UIUtils.SetActive(self.btn_Before, false) UIUtils.SetActive(self.btn_Next, false) UIUtils.SetActive(self.group_Skill, false) UIUtils.SetActive(self.weaponModel, false) UIUtils.SetActive(self.model, false) end self.curShowView = self.forgeView end function UIDivineWeaponBasePanel:InitWeaponAwakenSkill() if not self.weaponAwakenSkillView then self:CloseSubView() self.weaponAwakenSkillView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIDivineWeaponAwakenSkillTreePanel), {weaponId = self.data.MagicWeaponID}) UIUtils.SetActive(self.btn_Before, false) UIUtils.SetActive(self.btn_Next, false) UIUtils.SetActive(self.group_Skill, false) UIUtils.SetActive(self.weaponModel, false) UIUtils.SetActive(self.model, false) end self.curShowView = self.weaponAwakenSkillView end function UIDivineWeaponBasePanel:ShowNext() local list = {} if self.isFormation then list = MDL.DivineWeapon.GetFormationData() else list = MDL.DivineWeapon.GetAllData() end local index = 0 for i, v in ipairs(list) do if v.MagicWeaponID == self.curShowWeaponId then index = i end end index = index + 1 if index > #list then index = 1 end self.curShowAttrIndex = nil self:ShowWeaponInfo(list[index]) self:InitToggles() end function UIDivineWeaponBasePanel:ShowPre() local list = {} if self.isFormation then list = MDL.DivineWeapon.GetFormationData() else list = MDL.DivineWeapon.GetAllData() end local index = 0 for i, v in ipairs(list) do if v.MagicWeaponID == self.curShowWeaponId then index = i end end index = index - 1 if index == 0 then index = #list end self.curShowAttrIndex = nil self:ShowWeaponInfo(list[index]) self:InitToggles() end function UIDivineWeaponBasePanel:UpdateBtnsRedPoint() if not self.appearanceView then self:UpdateActRedPoint() else self:UpdateAppearanceRedPoint() end end function UIDivineWeaponBasePanel:UpdateActRedPoint() local preRp = false local nextRp = false local list = {} if self.isFormation then list = MDL.DivineWeapon.GetFormationData() else list = MDL.DivineWeapon.GetAllData() end local index = 1 for i, v in ipairs(list) do if v.MagicWeaponID == self.curShowWeaponId then index = i end end local preId, nextId for i, v in ipairs(list) do if index < i and MDL.DivineWeapon.GetEnoughLevel(v) then nextRp = true nextId = v.MagicWeaponID elseif index > i and MDL.DivineWeapon.GetEnoughLevel(v) then preRp = true preId = v.MagicWeaponID end end self:SetBtnRp(preRp, nextRp, preId, nextId) end function UIDivineWeaponBasePanel:SetBtnRp(preRp, nextRp, preId, nextId) if MDL.Player.HeroIsLineUp(preId) then self.btn_Before:SetRedPoint(preRp) UIUtils.SetActive(self.before_YelPoint, false) else self.btn_Before:SetRedPoint(false) UIUtils.SetActive(self.before_YelPoint, preRp) end if MDL.Player.HeroIsLineUp(nextId) then UIUtils.SetActive(self.next_YelPoint, false) else self.btn_Next:SetRedPoint(false) UIUtils.SetActive(self.next_YelPoint, nextRp) end end function UIDivineWeaponBasePanel:UpdateAppearanceRedPoint() local preRp = false local nextRp = false local list = {} if self.isFormation then list = MDL.DivineWeapon.GetFormationData() else list = MDL.DivineWeapon.GetAllData() end local index = 1 for i, v in ipairs(list) do if v.MagicWeaponID == self.curShowWeaponId then index = i end end for i, v in ipairs(list) do if index < i and CTL.Appearance.IsShowWeaponRedPoint(v.MagicWeaponID) then nextRp = true elseif index > i and CTL.Appearance.IsShowWeaponRedPoint(v.MagicWeaponID) then preRp = true end end self.btn_Before:SetRedPoint(preRp) self.btn_Next:SetRedPoint(nextRp) end function UIDivineWeaponBasePanel:ShowSkillInfo(id, starLevel) local magicWeaponStar = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(id, starLevel) if not magicWeaponStar then magicWeaponStar = DataSheetManager.MagicWeaponStar:GetDataByMagicWeaponID_Star(self.curShowWeaponId, starLevel) end local skillId = magicWeaponStar.MusouSkillID local skillStar = magicWeaponStar.MusouLevel local skillData = DataSheetManager.SkillData:GetDataByID(skillId) local skillPath = ConstAssetPathConfig.skillPath .. skillData.Icon .. ".png" UIUtils.SetImageByAssetBundle(self.sprite_Skill, skillPath) local skillTipData = DataSheetManager.SkillTipsData:GetDataByID(skillId) UIUtils.SetLabel(self.txt_SkillName, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BreakThrough_SkillName), UIUtils.GetLocalizedTxt(Const_IDS[skillTipData.Name]))) UIUtils.SetLabel(self.txt_SkillLevel, skillStar ~= 0 and string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_BreakThrough_Level), skillStar) or "") end function UIDivineWeaponBasePanel:RefreshRedPoint() for i, toggleType in ipairs (self.toggleList) do local isShowRP = false if toggleType == UTL.Toggle.ToggleType.Breakthrough or toggleType == UTL.Toggle.ToggleType.Activation then isShowRP = MDL.DivineWeapon.GetEnoughLevel(self.data) elseif toggleType == UTL.Toggle.ToggleType.WeaponAwakenSkill then isShowRP = CTL.HeroAwaken.CheckWeaponSkillRed(self.curShowWeaponId) elseif toggleType == UTL.Toggle.ToggleType.HeroAwaken then isShowRP = CTL.HeroAwaken.CheckWeaponAwakenRed(self.curShowWeaponId) elseif toggleType == UTL.Toggle.ToggleType.Appearance then isShowRP = CTL.Appearance.IsShowWeaponRedPoint(self.curShowWeaponId) elseif toggleType == UTL.Toggle.ToggleType.Forge then isShowRP = CTL.DivineWeapon.HasForgeRP(self.curShowWeaponId) end self:SetToggleRp(i - 1, isShowRP) end if CTL.HeroAwaken.IsShowWeaponAwakenEntry(self.weaponId) then self:UpdateToggleIDS(UTL.Toggle.ToggleType.HeroAwaken, Const_IDS.IDS_HeroAwaken_FunctionName) end end function UIDivineWeaponBasePanel:OnReturnBreak(isBreak) self:CloseSubView() if isBreak then self:InitBreakView(true) else self:InitBreakView(false) end end function UIDivineWeaponBasePanel:UpdateToggleIDS(toggleType, replaceIDS) for i, type in ipairs (self.toggleList) do if toggleType == type then if self.idsList[i] ~= replaceIDS then self.toggles:SetToggleIDS(i, "text", replaceIDS) end break end end end function UIDivineWeaponBasePanel:OnFunctionUnlockUpdate(fucId, isUnlock) self:InitToggles() if fucId == MDL.Unlock.FunctionType.AwakenActivity then if not isUnlock then if self:CheckType(self.curToggleIndex, CONST_INDEX_AWAKEN_SKILL) then self.toggles:SelectIndex(0) end end end end return UIDivineWeaponBasePanel