local UIDivineWeaponForgeLinePanel = UIViewClass() 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 local MoveCenterDuration = 0.4 ---------------------------------- 系统函数 ------------------------------------ function UIDivineWeaponForgeLinePanel:OnCreated() self.pointID2PointCmp = {} self.pointCmp2PointData = {} self.unlockRelyPointCmps = {} end function UIDivineWeaponForgeLinePanel:OnOpened(context) self:RegistSystemEvent(EventID.UI_DivineWeapon_ForgeUpdate, self.SetForgeLinePanel) self:RegistSystemEvent(EventID.BagItem_Update, self.SetForgeLinePanel) self:RegistSystemEvent(EventID.UI_DivineWeapon_ForgeSkillUnlock, self.ShowSkillUnlock) self:RegistSystemEvent(EventID.UI_DivineWeapon_ForgeSkillUnlockClose, self.CloseSkillUnlock) self:RegistSystemEvent(EventID.UI_DivineWeapon_CloseForgePanel, self.UnSelectedPoint) self.screenWidth = UnityEngine.Screen.width self.contentWidth = self.tran_content:GetSizeDelta() self.maxMovePosX = self.contentWidth - self.screenWidth if context then self.weaponId = context.MagicWeaponID self.templateID = CTL.DivineWeapon.GetForgeTemplateID(self.weaponId) self:SetForgeLinePanel() self:JumpToAvailablePoint() CTL.DivineWeaponForgeSoul.TryOpenForgeSoulOpenPanel(self.weaponId) end end function UIDivineWeaponForgeLinePanel:OnClosed() UIManager.CloseView(Const_UI_Lua.UIEnum.UIDivineWeaponForgePanel) end function UIDivineWeaponForgeLinePanel:OnButtonClicked(comp) for cmp, pointData in pairs (self.pointCmp2PointData) do local btn = cmp.btn_BigAttributes or nil if not btn then btn = cmp.btn_SmallAttributes or nil end if not btn then btn = cmp.btn_Skills or nil end if btn and btn == comp then self:OnSelectPoint(cmp, pointData) if btn == cmp.btn_Skills then CTL.Sound.PlayGameSound("UI_breakthrough_02") else CTL.Sound.PlayGameSound("UI_breakthrough_01") end break end end end -------------------------------------------------------------------------------- function UIDivineWeaponForgeLinePanel:SetForgeLinePanel() table.clear(self.pointID2PointCmp) table.clear(self.pointCmp2PointData) local lines, linesCount, topLines, bottomLines = CTL.DivineWeapon.GetLineDataByID(self.templateID) self:SetForgeLine(self.group_FirstLine, lines[1]) self:SetForgeLine(self.group_ThirdLine, lines[2]) self:SetForgeLine(self.group_FifthLinePoint, lines[3]) self:SetForgeLine(self.group_SecondLine, topLines) self:SetForgeLine(self.group_FourthLine, bottomLines) end function UIDivineWeaponForgeLinePanel:SetForgeLine(lineComp, lineData) if not lineComp or not lineData then return end for i, cmp in ipairs (lineComp) do local pointData = lineData[i] if not pointData then UIUtils.SetActive(cmp.gameObject, false) else UIUtils.SetActive(cmp.gameObject, true) self.pointID2PointCmp[pointData.PointID] = cmp self.pointCmp2PointData[cmp] = pointData self:SetForgePointShow(cmp, pointData) end end end function UIDivineWeaponForgeLinePanel:SetForgePointShow(point, pointData) if not point or not pointData then return end local state = CTL.DivineWeapon.GetPointState(self.weaponId, pointData) if pointData.LineType == CENTER_LINE_TYPE or pointData.LineType == TOP_LINE_TYPE or pointData.LineType == BOTTOM_LINE_TYPE then if pointData.PointType == SKILLED_FORGE_POINT or pointData.PointType == SKILL_FORGE_POINT then local showDataId = CTL.DivineWeapon.MagicWeaponFoundryShowID(pointData) local skillData = DataSheetManager.SkillTipsData:GetDataByID(showDataId) if skillData then UIUtils.SetImageByAssetBundle(point.img_SkillsIcon, string.format(SkillPath, skillData.SkillIcon)) end point.btn_Skills:SetGray(state ~= CTL.DivineWeapon.ForgePointState.Activate, true) UIUtils.SetGray(point.img_SkillsIcon, state ~= CTL.DivineWeapon.ForgePointState.Activate) point.state_Mask:SetState(state == CTL.DivineWeapon.ForgePointState.Activate and 0 or 1) UIUtils.SetActive(point.mask, state == CTL.DivineWeapon.ForgePointState.Lock) elseif pointData.PointType == SMALL_FORGE_POINT then UIUtils.SetAtlasImage(point.btn_SmallAttributes, "UI_WeaponHero", pointData.Icon) point.btn_SmallAttributes:SetGray(state ~= CTL.DivineWeapon.ForgePointState.Activate, true) point.state_Mask:SetState(state == CTL.DivineWeapon.ForgePointState.Activate and 0 or 1) UIUtils.SetActive(point.mask, state == CTL.DivineWeapon.ForgePointState.Lock) end if point.img_Light then local maxLinePointID = MDL.DivineWeapon.GetForgeLineMaxActivatePointID(self.weaponId, pointData.LineType) UIUtils.SetActive(point.img_Light, maxLinePointID == pointData.PointID) end else point.btn_BigAttributes:SetGray(state ~= CTL.DivineWeapon.ForgePointState.Activate, true) UIUtils.SetActive(point.mask, state == CTL.DivineWeapon.ForgePointState.Lock) UIUtils.SetGray(point.img_SmallAttributesIcon, state ~= CTL.DivineWeapon.ForgePointState.Activate) UIUtils.SetActive(point.img_Line_1, state == CTL.DivineWeapon.ForgePointState.Activate) UIUtils.SetActive(point.img_Line_2, state == CTL.DivineWeapon.ForgePointState.Activate) end -- 判断点位状态 point.effect_Activatable:StopUIEffect() point.effect_Activation:StopUIEffect() if state == CTL.DivineWeapon.ForgePointState.Available then point.effect_Activatable:PlayUIEffect() end end function UIDivineWeaponForgeLinePanel:MovePointCmpToScreenCenter(pointCmp) if pointCmp then local anchorX, anchorY = pointCmp.gameObject.transform:GetAnchoredPosition() local movePosX = -self.contentWidth / 2 - anchorX + self.screenWidth / 2 local contentAnchorX, contentAnchorY = self.tran_content:GetAnchoredPosition() movePosX = movePosX > 0 and 0 or movePosX movePosX = movePosX < -self.maxMovePosX and -self.maxMovePosX or movePosX self:MoveToPos(self.tran_content, movePosX, contentAnchorY, MoveCenterDuration, false) end end function UIDivineWeaponForgeLinePanel:ShowSkillUnlock(heroId, pointId) if heroId == self.weaponId then local pointCmp = self.pointID2PointCmp[pointId] if pointCmp then pointCmp.effect_Activation:StopUIEffect() pointCmp.effect_Activation:PlayUIEffect() end local weaponData = DataSheetManager.MagicWeaponData:GetDataByMagicWeaponID(heroId) if weaponData then local templateID = CTL.DivineWeapon.GetForgeTemplateID(heroId) local pointData = DataSheetManager.MagicWeaponFoundry:GetDataByID_PointID(templateID, pointId) if pointData and pointData and (pointData.PointType == SKILLED_FORGE_POINT or pointData.PointType == SKILL_FORGE_POINT) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIDivineWeaponForgeSuccessPanel, pointData) elseif pointData.LineType == CENTER_LINE_TYPE or pointData.LineType == BOTTOM_LINE_TYPE or pointData.LineType == TOP_LINE_TYPE then local str = string.FormatByIdsId(Const_IDS.IDS_Foundry_Success, UIUtils.GetLocalizedTxt(Const_IDS.IDS_Foundry_Point1)) CTL.Tips.AddTipsMsg(str) end --如果该类型还有下一个数据,则跳向下一个 local nextData = CTL.DivineWeapon.GetNextPointData(templateID, pointData) if nextData then local nextPointCmp = self.pointID2PointCmp[nextData.PointID] if nextPointCmp then self:OnSelectPoint(nextPointCmp, nextData) end end end end end function UIDivineWeaponForgeLinePanel:CloseSkillUnlock(pointData) -- 判断是否触发依赖点解锁 if pointData then table.clearArray(self.unlockRelyPointCmps) local dict = CTL.DivineWeapon.GetRelyPointDicts(pointData) for _, relyPointData in pairs (dict) do if self.pointID2PointCmp[relyPointData.PointID] and CTL.DivineWeapon.GetPointState(self.templateID, relyPointData) == CTL.DivineWeapon.ForgePointState.Activate then local cmp = self.pointID2PointCmp[relyPointData.PointID] UIUtils.SetActive(cmp.img_Line_1, false) UIUtils.SetActive(cmp.img_Line_2, false) table.insert(self.unlockRelyPointCmps, cmp) end end self:PlayUnlockRelyLinesEft() end CTL.DivineWeaponForgeSoul.TryOpenForgeSoulOpenPanel(self.weaponId) end function UIDivineWeaponForgeLinePanel:PlayUnlockRelyLinesEft() local cmp = self.unlockRelyPointCmps[1] if cmp then cmp.effect_Line_1:PlayUIEffect() cmp.effect_Line_2:PlayUIEffect() self:StartRepeatFunc(self.PlayUnlockRelyPointEft, 2, 1) end end function UIDivineWeaponForgeLinePanel:PlayUnlockRelyPointEft() local cmp = table.remove(self.unlockRelyPointCmps, 1) if cmp then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_Foundry_Success, UIUtils.GetLocalizedTxt(Const_IDS.IDS_Foundry_Point2))) cmp.effect_Activation:PlayUIEffect() UIUtils.SetActive(cmp.img_Line_1, true) UIUtils.SetActive(cmp.img_Line_2, true) self:StartRepeatFunc(self.PlayUnlockRelyLinesEft, 2, 1) end end function UIDivineWeaponForgeLinePanel:UnSelectedPoint() if self.selectedPointCmp then UIUtils.SetActive(self.selectedPointCmp.img_Selected, false) self.selectedPointCmp = nil end end function UIDivineWeaponForgeLinePanel:JumpToAvailablePoint() local lines = CTL.DivineWeapon.GetLineDataByID(self.templateID) local movePointData for _, points in ipairs (lines) do if points and CTL.DivineWeapon.GetPointState(self.weaponId, points[#points]) ~= CTL.DivineWeapon.ForgePointState.Activate then for _, pointData in ipairs (points) do if CTL.DivineWeapon.GetPointState(self.weaponId, pointData) ~= CTL.DivineWeapon.ForgePointState.Activate then movePointData = pointData break end end end if movePointData then break end end if not movePointData then local points = lines[1] movePointData = points[#points] end local pointCmp = self.pointID2PointCmp[movePointData.PointID] if pointCmp then self:OnSelectPoint(pointCmp, movePointData) end end function UIDivineWeaponForgeLinePanel:OnSelectPoint(pointCmp, pointData) self:UnSelectedPoint() self:MovePointCmpToScreenCenter(pointCmp) UIUtils.SetActive(pointCmp.img_Selected, true) self.selectedPointCmp = pointCmp if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIDivineWeaponForgePanel) then EventSystem.Dispatch(EventID.UI_DivineWeapon_ForgeUpdate, {pointData = pointData, heroId = self.weaponId}) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIDivineWeaponForgePanel, {pointData = pointData, heroId = self.weaponId}) end end return UIDivineWeaponForgeLinePanel