local UIThreeTeamFightMain = UIViewClass() local SweepLevel = DataSheetManager.ConstData:GetDataByID("ThreeTeamsPKSweepUnlockLevel").IntValue function UIThreeTeamFightMain:OnCreated() UIUtils.SetActive(self.group_Tip, false) UIUtils.SetActive(self.rect_CloseTips, false) UIUtils.SetActive(self.group_Team, false) UIUtils.SetActive(self.group_EmptyBg, true) end function UIThreeTeamFightMain:OnOpened(context) self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfFuncUnlock) -- GMS self:RegistSystemEvent(EventID.UI_ThreeTeamFight_RefreshBasic, self.RefreshTimes) self:RegistSystemEvent(EventID.UI_ThreeTeamFight_RefreshTopInfo, self.RefreshTopInfo) self:RegistSystemEvent(EventID.UI_ThreeTeamFight_UpdateMyRank, self.UpdateMyRank) self:RegistSystemEvent(EventID.UI_FreeLineUp_RefreshUI, self.UpdateLineUp) self:RegistSystemEvent(EventID.UI_ThreeTeamFight_RefreshEventInfo, self.OnEventRefresh) self:RegistSystemEvent(EventID.UI_ThreeTeamFight_OnSeasonFinish, self.OnSeasonFinish) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.ThreeTeamFight_TaskCanGet, self.RefreshRewardRed) self:RefreshRewardRed() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_3TeamsPK_3TeamsPK) local lev = MDL.Player.GetRoleInfo() CTL.Character.SetSelfPortraitAndFrame(self.UIHeroHead190, lev) self.lab_Name.text = BattleDataGetter.GetPlayerName() self:UpdateTimeDesc() self:RefreshTimes() self.top3PlayerList = {} --请求防守阵容 MDL.FreeLineUp.FreeLineUpGetInfoRequest(MDL.FreeLineUp.FuncType.ThreeTeamFight) MDL.ThreeTeamFight.ThreeTeamsPKGetTopRankReq() MDL.ThreeTeamFight.ThreeTeamsPKEventInfosReq() self.btn_Sweep:SetGray(true,true) if MDL.HeroSelect.GetTeamLevel() >= SweepLevel then UIUtils.SetGray(self.img_sweep, false) else UIUtils.SetGray(self.img_sweep, true) end end function UIThreeTeamFightMain:UpdateLineUp(funcType) if funcType == MDL.FreeLineUp.FuncType.ThreeTeamFight then local lineUpList = MDL.FreeLineUp.GetLineUpInfoByFunctionType(funcType) local totalPower = 0 if lineUpList and #lineUpList > 0 then local isEmpty = true for i = CTL.ThreeTeamFight.LineNumberType.Defence_1, CTL.ThreeTeamFight.LineNumberType.Defence_3 do local heroInfos for _, v in ipairs(lineUpList) do if v.lineNumber == i then heroInfos = v.heroInfos totalPower = totalPower + v.TotalGs break end end if i == CTL.ThreeTeamFight.LineNumberType.Defence_1 then self:SetLineUpHeroArray(self.group_Team1, heroInfos) elseif i == CTL.ThreeTeamFight.LineNumberType.Defence_2 then self:SetLineUpHeroArray(self.group_Team2, heroInfos) elseif i == CTL.ThreeTeamFight.LineNumberType.Defence_3 then self:SetLineUpHeroArray(self.group_Team3, heroInfos) end if heroInfos and #heroInfos > 0 then isEmpty = false end end if isEmpty then UIUtils.SetActive(self.group_Team, false) UIUtils.SetActive(self.group_EmptyBg, true) else UIUtils.SetActive(self.group_Team, true) UIUtils.SetActive(self.group_EmptyBg, false) end else UIUtils.SetActive(self.group_Team, false) UIUtils.SetActive(self.group_EmptyBg, true) end self.txt_BR.text = totalPower end end function UIThreeTeamFightMain:SetLineUpHeroArray(group, heroInfos) for i, v in ipairs(group) do local heroIdMain = self:GetHeroIdByPosNumber(heroInfos, i * 2 - 1) self:SetHeroItem(v.template_HeroMain, heroIdMain) local heroIdAssistant = self:GetHeroIdByPosNumber(heroInfos, i * 2) self:SetHeroItem(v.template_HeroAssistant, heroIdAssistant) end end function UIThreeTeamFightMain:SetHeroItem(template, heroId) UIUtils.SetActive(template.group_Level, false) if heroId and heroId > 0 then UIUtils.SetActive(template.img_Empty, false) UIUtils.SetActive(template.img_HeroHead, true) UTL.Item.SetHeroIconByHeroId(template.img_HeroHead, heroId, MDL.HeroAwaken.GetIsHeroAwaken(heroId)) else UIUtils.SetActive(template.img_Empty, true) UIUtils.SetActive(template.img_HeroHead, false) end end function UIThreeTeamFightMain:GetHeroIdByPosNumber(heroInfos, posNumber) if heroInfos then for i, v in ipairs(heroInfos) do if v.posNumber == posNumber then return v.heroId end end end return nil end function UIThreeTeamFightMain:RefreshTimes() UIUtils.SetLabel(self.txt_Times, CTL.ThreeTeamFight.GetChallengeTimesDesc()) end function UIThreeTeamFightMain:UpdateMyRank() CTL.ThreeTeamFight.FormatMyRankDesc(self.txt_Rank) local myRank = MDL.ThreeTeamFight.GetMyRank() UIUtils.SetActive(self.btn_eye1, CTL.ThreeTeamFight.CheckIfHideByIndex(myRank, 1)) UIUtils.SetActive(self.btn_eye2, CTL.ThreeTeamFight.CheckIfHideByIndex(myRank, 2)) UIUtils.SetActive(self.btn_eye3, CTL.ThreeTeamFight.CheckIfHideByIndex(myRank, 3)) end function UIThreeTeamFightMain:RefreshTopInfo(topInfos) for i, v in ipairs(self.group_Rank) do local info = topInfos[i] if info then self.top3PlayerList[i] = info.ShowInfo.acid self:SetRankTopInfo(v, info, i) else logging.error(LTAG.ERROR, "前三名数据有空的情况,找服务器检查下") end end end function UIThreeTeamFightMain:SetRankTopInfo(comp, data, rank) UIUtils.SetLabel(comp.lab_Level, UTL.Item.GetNobilityByTeamLevel(data.ShowInfo.level)) CTL.Character.SetPortraitAndFrame(comp.UIHeroHead190, data.ShowInfo.PortraitId, data.ShowInfo.FrameId) UIUtils.SetCanvasSortingOrderByMainCanvas(comp.UIHeroHead190.effectUpCanvas, comp.img_Rank, CTL.Character.UpOrder.Common) UIUtils.SetLabel(comp.lab_Name, data.ShowInfo.name) UIUtils.SetLabel(comp.lab_Server, "S." .. data.ShowInfo.ShowServerId) UIUtils.SetLabel(comp.txt_Rank, CTL.ThreeTeamFight.GetRankDesc(rank, true, true)) if string.isNilOrEmpty(data.ShowInfo.EmblemContent) then UIUtils.SetActive(comp.img_Emblem, false) else UIUtils.SetActive(comp.img_Emblem, true) UIUtils.SetLabel(comp.txt_Emblem, data.ShowInfo.EmblemContent) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(data.ShowInfo.EmblemFrame) if guildEmblemCfg then UTL.Item.SetAtlasSprite(comp.img_Emblem, "UI_Guild", guildEmblemCfg.Image) end end --点赞 self:UpdateThumbsUp(comp, data.thumpUpNum) end function UIThreeTeamFightMain:UpdateThumbsUp(obj, thumpUpNum) UIUtils.SetLabel(obj.txt_ThumbsUpNum, UTL.String.GetCountStr(thumpUpNum)) local rp = CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.ThreeTeamFight_ThumbsUp) if MDL.ThreeTeamFight.GetLeftThumbsUpTimes() == 0 then obj.obj_giveLike:SetState(0) obj.img_Nor:SetGray(true, true) obj.obj_btnColor:SetState(0) else obj.obj_giveLike:SetState(1) obj.img_Nor:SetGray(false, true) obj.obj_btnColor:SetState(1) end obj.img_Nor:SetRedPoint(rp) obj.img_Gold:SetRedPoint(rp) end function UIThreeTeamFightMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIThreeTeamFightMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then CTL.ThreeTeamFight.OpenNote() elseif comp == self.btn_Reward then CTL.ThreeTeamFight.OpenReward() elseif comp == self.btn_Msg then CTL.ThreeTeamFight.OpenMsg(self.eventList) self.btn_Msg:SetRedPoint(false) elseif comp == self.btn_Rank then if CTL.ThreeTeamFight.IsActivityOpen() then CTL.Rank.OpenRankPanelByType(MDL.Rank.RankType.ThreeTeamFight) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_ActivityItem_NotAtActivityTime) end elseif comp == self.btn_Formation then CTL.ThreeTeamFight.OpenFormation(false) elseif comp == self.btn_Shop then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, { TabEnum = CTL.PayMall.ShopMainTabEnum.QunXiongYanWu }) elseif comp == self.btn_Click then CTL.ThreeTeamFight.TryOpenTimeUp() elseif comp == self.btn_EnterTeam then CTL.ThreeTeamFight.TryEnterChallenge(true) elseif comp == self.btn_Sweep then if MDL.ThreeTeamFight.GetLeftTimes() == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroBiography_NoNum) return end if MDL.HeroSelect.GetTeamLevel() >= SweepLevel then MDL.ThreeTeamFight.ThreeTeamsSweepReq() else local tlData = DataSheetManager.TeamLevelData:GetDataByTeamLevel(SweepLevel) if tlData ~= nil then local _levelStr = UTL.Item.GetNobilityByTeamLevel(tlData.TeamLevel) -- 爵位转换 local teamLevelName = string.FormatByIdsId(Const_IDS[tlData.TeamLevelName], _levelStr) CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_51, teamLevelName)) end end elseif comp == self.rect_CloseTips then UIUtils.SetActive(self.group_Tip, false) UIUtils.SetActive(self.rect_CloseTips, false) elseif comp == self.btn_eye1 then self:ShowTips(1) elseif comp == self.btn_eye2 then self:ShowTips(2) elseif comp == self.btn_eye3 then self:ShowTips(3) else for i, v in ipairs(self.group_Rank) do if v.img_Gold == comp or v.img_Nor == comp then if MDL.ThreeTeamFight.GetLeftThumbsUpTimes() == 0 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Ranking_NoGood) else MDL.ThreeTeamFight.ThreeTeamsPKThumpUpReq(self.top3PlayerList[i]) end break end if comp == v.UIHeroHead190.img_PlayerAvatarBg then CTL.PlayerInteract.OpenFriendInteractView(self.top3PlayerList[i]) end end end end function UIThreeTeamFightMain:ShowTips(type) UIUtils.SetActive(self.group_Tip, true) self.tips_State:SetState(type) UIUtils.SetActive(self.rect_CloseTips, true) end function UIThreeTeamFightMain:UpdateTimeDesc() local activityCfgData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.ThreeTeamFight) local date, time = CTL.Activities.GetDetailsTimeDesc(activityCfgData) self.txt_OpenTime.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_3TeamsPK_DailyTime) .. time end function UIThreeTeamFightMain:CheckIfFuncUnlock(funcId, isUnlock) if funcId and funcId == MDL.Unlock.FunctionType.ThreeTeamFight then self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end end function UIThreeTeamFightMain:OnSeasonFinish() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIThreeTeamFightMain:OnEventRefresh(list, isRed) self.eventList = list self.btn_Msg:SetRedPoint(isRed) end function UIThreeTeamFightMain:RefreshRewardRed() self.btn_Reward:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.ThreeTeamFight_TaskCanGet)) end return UIThreeTeamFightMain