local UISyncSoloMainPanel = UIViewClass() local SyncTeamPVPImgPath = ConstAssetPathConfig.SyncTeamPVPImgPath local TITLE_TOURNAMENT = 21755 --天下会武冠军称号id local THUMB_UP_TOTAL = 3 --天下会武点赞总数 local UIHeroLightEffectTool = require "View/Common/UIHeroLightEffectTool" local NO1_EFFECT_ID = 201041 local OPEN_BP_BATTLE_NODE = "OPEN_BP_BATTLE_NODE" function UISyncSoloMainPanel:OnOpened(context) if not CTL.Unlock.CheckIfFuncUnlock(MDL.Unlock.FunctionType.SyncSolo, self, true) then return end self:RegistSystemEvent(EventID.FunctionUnlockUpdate, self.CheckIfFuncUnlock) self.heroFormationNumber = 0 self:RegistSystemEvent(EventID.UI_SyncSolo_RankRefresh, self.RefreshRankInfo) self:RegistSystemEvent(EventID.UI_TeamMatch_MatchTime, self.OnMatchExpression) self:RegistSystemEvent(EventID.UI_FairPlay_SyncSoloSeasonInfoUpdate, self.RefreshPanel) self:RegistSystemEvent(EventID.UI_FairPlay_SyncSoloSeasonInfoUpdate, self.RefreshRedPoint) self:RegistSystemEvent(EventID.UI_SyncSolo_RankRefresh, self.RefreshRedPoint) self:RegistSystemEvent(EventID.UI_FairPlay_SyncSoloEloScoreUpdate, self.RefreshRankInfo) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_Reward, self.RefreshRedPoint) self:RegistSystemEvent(EventID.UI_OperationActivity_DataChanged, self.RefreshSyncSoloLineUp) self:RegistSystemEvent(EventID.UI_FairSoloTournament_UpdateThumbsUpParam, self.UpdateThumbsUpParam) self:RegistSystemEvent(EventID.UI_FairPlay_RefreshHeroWinRateInfo,self.EnterChooseHero) self:RegistSystemEvent(EventID.UI_SyncSolo_OpenBPBattleMode,self.OpenBPBattleMode) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.FairPlay_KingChallenge, self.RefreshKingChallengeEntry) self.heroLightEffectDatas = UIHeroLightEffectTool.CreateHeroLightEffectDatas(true) -- 设置标题 IDS_1v1Sync_Title UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_1v1Sync_Title) self:RefreshPanel() MDL.SyncSolo.SyncSoloOpenReq() -- 测试武将到期倒计时 local testHeroTimer = MDL.SyncSolo.GetTestHeroTimer() if testHeroTimer > 0 then self:StartRepeatFunc(self.TestHeroUpdateRepeatFunc, testHeroTimer) end self:RefreshKingChallengeEntry() UIUtils.SetCanvasSortingOrderByMainCanvas(self.gameObject:GetComponent(typeof(UnityEngine.Canvas)), self.group_Middle, CTL.Character.UpOrder.ChannelChat) end function UISyncSoloMainPanel:CheckIfFuncUnlock(funcId, isUnlock) if funcId then if funcId == MDL.Unlock.FunctionType.SyncSolo then CTL.Unlock.CheckIfFuncUnlock(funcId, self, true) elseif funcId == MDL.Unlock.FunctionType.AwakenActivity then UIUtils.SetActive(self.btn_SkillPlan, MDL.HeroAwaken.GetIsAnyHeroAwaken()) elseif funcId == MDL.Unlock.FunctionType.KingChallenge then UIUtils.SetActive(self.btn_KingChallenge, CTL.KingChallenge.IsShowKingChallengeEntry()) elseif funcId == MDL.Unlock.FunctionType.SyncSoloBP then self:RefreshRankInfo() end end end function UISyncSoloMainPanel:RefreshPanel() self:ShowRewardState() self:RefreshOpenTime() self:RefreshLeftTime() self:RefreshSeasonFreeHeroes() self:UpdateTimer(CTL.TeamMatch.IsActivityMatchingById(LuaConst.ActivityType.SyncSolo)) UIUtils.SetLabelText(self.txt_Rank, Const_IDS["IDS_Rank"]) if CTL.SyncSolo.IsWarZoneStyle() then UIUtils.SetLabelText(self.txt_Rank, Const_IDS["IDS_WarZone_Rank"]) end self:RefreshBtn() UIUtils.SetLabel(self.group_LeftTitleInfo.txt_Number,MDL.SyncSolo.GetSeasonId()) UIUtils.SetLabel(self.group_RightTitleInfo.txt_Number,MDL.SyncSolo.GetSeasonId()) local protectCardIdNum = UTL.Item.GetItemStockCount(CTL.FairPlayCard.protectCard1v1Id) if protectCardIdNum > 0 then UIUtils.SetActive(self.group_Scorecard, true) UIUtils.SetLabel(self.txt_card, "x"..protectCardIdNum) self.cardToggleIsOn = MDL.FairPlayCard.GetIs1V1UseProtectCard() self.toggle_UseCard.isOn = MDL.FairPlayCard.GetIs1V1UseProtectCard() else UIUtils.SetActive(self.group_Scorecard, false) end UIUtils.SetActive(self.btn_Bg, false) UIUtils.SetActive(self.tips_scorcard.gameObject, false) UIUtils.SetActive(self.btn_SkillPlan, MDL.HeroAwaken.GetIsAnyHeroAwaken()) UIUtils.SetActive(self.buff_btn, CTL.KingChallenge.IsHasSeasonBuff()) end function UISyncSoloMainPanel:RefreshBtn() if MDL.SyncSolo.GetSyncSoloState() == MDL.FairPlay.SeasonState.SeasonOpening then self.btn_Match:SetGray(false, true) local btnText if CTL.TeamMatch.IsActivityMatchingById(LuaConst.ActivityType.SyncSolo) then btnText = UIUtils.GetLocalizedTxt(Const_IDS.IDS_UI_Word20) else if self.isOpenBPBattle then btnText = UIUtils.GetLocalizedTxt(Const_IDS.IDS_FairPlay_IVITop) else btnText = UIUtils.GetLocalizedTxt(Const_IDS.IDS_Team_3v3_StartMatch) end end self.btn_Match:SetText(btnText) else self.btn_Match:SetGray(true, true) self.btn_Match:SetText(UIUtils.GetLocalizedTxt(Const_IDS.IDS_RankOptimization_SeasonOff)) end end function UISyncSoloMainPanel:RefreshRedPoint() self.btn_Reward:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_Reward)) end function UISyncSoloMainPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UISyncSoloMainPanel:OnClosed() UIHeroLightEffectTool.StopHeroLightEffect(self.heroLightEffectDatas) self.heroLightEffectDatas = nil if self.modelComponentDataHandle then UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end end function UISyncSoloMainPanel:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UISyncSoloReward, nil, "SyncTeamPVP/UISyncTeamPVPReward") elseif comp == self.btn_Rank then CTL.Rank.OpenRankPanelByType(MDL.Rank.RankType.SyncSolo) elseif comp == self.UITemplateTitlePanel.btn_Info then local noteID = self.isOpenBPBattle and LuaConst.NoteID.BattleGround_1V1_BP or LuaConst.NoteID.BattleGround_1V1 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = noteID, params = {MDL.SyncSolo.GetSoloLevelRank()}}) elseif comp == self.btn_ChooseHero then MDL.Replay.FairPlayHeroWinRateReq(MDL.FairPlay.FairPlayType.Solo) --选将相关的信息,在属性修正之前发,否则属性修正刷不出来 elseif comp == self.btn_Match then self:OnClickBeginMatch() elseif comp == self.btn_HallOfFame then -- 如果赛季为1且进行中 拦截不显示 if MDL.SyncSolo.GetSeasonId() == 1 and MDL.SyncSolo.GetSyncSoloState() == MDL.FairPlay.SeasonState.SeasonOpening then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SeasonAndRank_AfterFirstSeason"]) return end local isFairSoloTournament = MDL.SyncSolo.GetIsFairTournamentFamous() CTL.FairPlay.OpenHallOfFame(LuaConst.ActivityType.SyncSolo, Const_IDS.IDS_1v1Sync_Title, isFairSoloTournament) elseif comp == self.btn_Daily then --每日首胜 self:OnClickOpenWinOfEveryDay() elseif comp == self.btn_weekly then --每周奖励 self:OnClickOpenRewardOfEveryWeek() elseif comp == self.btn_Shop then --店铺 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.GongPing}) elseif comp == self.group_No1.img_Nor or comp == self.group_No1.img_Gold then if self.leftThumbUpNum and self.leftThumbUpNum > 0 then MDL.FairSoloTournament.FairTournamentThumbsUpReq() else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Ranking_NoGood) end elseif comp == self.btn_KingChallenge then --王者挑战 UIManager.OpenView(Const_UI_Lua.UIEnum.UIKingChallengeMainPanel) elseif comp == self.btn_SkillPlan then --灵识方案 UIManager.OpenView(Const_UI_Lua.UIEnum.UIFairAwakenSkillPlan) elseif comp == self.btn_card then UTL.ItemTips.ShowCommonTipsById(CTL.FairPlayCard.protectCard1v1Id) elseif comp == self.btn_Bg then UIUtils.SetActive(self.btn_Bg, false) UIUtils.SetActive(self.tips_scorcard.gameObject, false) elseif comp == self.btn_tips then UIUtils.SetActive(self.btn_Bg, true) UIUtils.SetActive(self.tips_scorcard.gameObject, true) elseif comp == self.buff_btn then UIManager.OpenView(Const_UI_Lua.UIEnum.UIKingChallengeSeasonBuffPopUp) elseif comp == self.btn_CloseLevelPanel then UIUtils.SetActive(self.btn_CloseLevelPanel, false) UIUtils.SetActive(self.Level_Popup, false) elseif comp == self.btn_tips2 then UIUtils.SetActive(self.btn_CloseLevelPanel, true) UIUtils.SetActive(self.Level_Popup, true) end end --先获取胜率数据再打开阵容界面,否则打开时同时获取的话,会有短暂的等待模型加载,此时会闪一下主城 function UISyncSoloMainPanel:EnterChooseHero(type) if type ~= MDL.FairPlay.FairPlayType.Solo then return end MDL.FairPlay.FairGetFixAttrReq(MDL.FairPlay.FairPlayType.Solo) UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISyncSoloFormation, nil, Const_UI_Lua.UIEnum.UIBossChallengeFormation) end --开始匹配\取消匹配 function UISyncSoloMainPanel:OnClickBeginMatch() if CTL.Activities.IsOpeningTime(LuaConst.ActivityType.SyncSolo) then self:RefreshSyncSoloLineUp() if self.heroFormationNumber < 6 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_RankOptimization_Less6Hero"]) -- 阵容不足6人,无法开始匹配 return end if MDL.SyncSolo.GetSyncSoloState() == MDL.FairPlay.SeasonState.SeasonOpening then local state = CTL.TeamMatch.OnPressMatchButton(LuaConst.ActivityType.SyncSolo, MDL.SyncSolo.DealWithSyncSoloMatch) if state == CTL.TeamMatch.MatchOperationState.CancelMatch then CTL.Sound.PlayGameSound("UI_invalid") else self.cardToggleIsOn = self.toggle_UseCard.isOn end else CTL.Tips.AddTipsMsg(Const_IDS["IDS_FairPlay_3v3NotOpen"]) -- 请在活动开启时间参与 CTL.Sound.PlayGameSound("UI_invalid") end else CTL.Tips.AddTipsMsg(Const_IDS["IDS_FairPlay_3v3NotOpen"]) -- 请在活动开启时间参与 CTL.Sound.PlayGameSound("UI_invalid") end end function UISyncSoloMainPanel:RefreshOpenTime() local activityTimeData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.SyncSolo).Time_Table local desc, time = UTL.Time.GetDateDescAndTime(activityTimeData) local endTimeStr = CTL.FairPlay.GetSeasonLastEndTimeStr("SyncSoloSeasonDayEndTime") self.group_LeftTitleInfo.txt_Time.text = desc .. " "..time self.group_RightTitleInfo.txt_Time.text = desc .. " "..time UIUtils.SetLabel(self.txt_TimeInfo, endTimeStr) UIUtils.SetLabel(self.group_LeftTitleInfo.txt_TimeInfo, endTimeStr) end function UISyncSoloMainPanel:RefreshLeftTime() local time = MDL.SyncSolo.GetNextTime() if CTL.SyncSolo.IsSeasonOpen() then UIUtils.SetLabelText(self.group_LeftTitleInfo.txt_Tip1, Const_IDS["IDS_1v1Sync_SeasonLeftTimeTip"]) UIUtils.SetLabelText(self.group_RightTitleInfo.txt_Tip1, Const_IDS["IDS_1v1Sync_SeasonLeftTimeTip"]) UIUtils.SetLabelText(self.group_LeftTitleInfo.txt_Term, Const_IDS["IDS_RankOptimization_Season"]) UIUtils.SetLabelText(self.group_RightTitleInfo.txt_Term, Const_IDS["IDS_RankOptimization_Season"]) else UIUtils.SetLabelText(self.group_LeftTitleInfo.txt_Tip1, Const_IDS["IDS_BossChallenge_NextSeasonOpenTimeTip"]) UIUtils.SetLabelText(self.group_RightTitleInfo.txt_Tip1, Const_IDS["IDS_BossChallenge_NextSeasonOpenTimeTip"]) UIUtils.SetLabelText(self.group_LeftTitleInfo.txt_Term, Const_IDS["IDS_RankOptimization_SeasonOff"]) UIUtils.SetLabelText(self.group_RightTitleInfo.txt_Term, Const_IDS["IDS_RankOptimization_SeasonOff"]) end self.group_LeftTitleInfo.bg_Time:ResetAndBeginCustomTimer(false, time, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_BossChallenge_SeasonLeftTime"]), 1) self.group_RightTitleInfo.bg_Time:ResetAndBeginCustomTimer(false, time, 0, UIUtils.GetLocalizedTxt(Const_IDS["IDS_BossChallenge_SeasonLeftTime"]), 1) self:StartRepeatFunc(self.OnUpdateFun, time) UIUtils.SetActive(self.group_LeftTitleInfo.bg_Time.gameObject, true) UIUtils.SetActive(self.group_RightTitleInfo.bg_Time.gameObject, true) end function UISyncSoloMainPanel:ShowModel(heroInfo, sourceInfo) if self.modelComponentDataHandle then --防止重复加载 UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end UIHeroLightEffectTool.StopHeroLightEffect(self.heroLightEffectDatas) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.group_No1.obj_Model) UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, ConstAssetPathConfig.Common2DScenePrefab, 1600, 0, 1600, ConstAssetPathConfig.AssetPath228, true, UTL.UIRender.LayerActiveType.BossChallenge) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0.84, -1.2, 0) -- 设置模型位移信息 UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -10, 0) -- 设置模型位移信息 UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, -10, 0) -- 设置模型位移信息 UTL.UIRender.CreateOtherPlayerModel(self.modelComponentDataHandle, heroInfo, sourceInfo.weaponAppearanceId, sourceInfo.weaponBreak, sourceInfo.isActiveMagicWeapon, true, -0.05) local weaponSoul = CTL.DivineWeaponForgeSoul.GetWeaponSoulSkillByWeaponSoulSceneInfo(sourceInfo.HeroId, sourceInfo.weaponSoulInfo) if weaponSoul then UTL.UIRender.LoadPlayerWeaponSoul(self.modelComponentDataHandle, weaponSoul) end --强行设置第一名的光效 UIHeroLightEffectTool.PlayHeroLightEffect(self.heroLightEffectDatas, self, 0, UIHeroLightEffectTool.PlayLightEffectFuncEnum.LuaView, NO1_EFFECT_ID, nil) end function UISyncSoloMainPanel:AuxUtilPlayPsEffect(effectPath) return UTL.UIRender.PlayPsEffect(self.modelComponentDataHandle, effectPath) end function UISyncSoloMainPanel:UpdateThumbsUpParam(totalNum, myTodayNum) local leftNum = THUMB_UP_TOTAL - myTodayNum if leftNum == 0 then self.group_No1.obj_giveLike:SetState(0) self.group_No1.img_Nor:SetGray(true, true) self.group_No1.obj_btnColor:SetState(0) else self.group_No1.obj_giveLike:SetState(myTodayNum > 0 and 1 or 0) self.group_No1.img_Nor:SetGray(false, true) self.group_No1.obj_btnColor:SetState(1) end UIUtils.SetLabel(self.group_No1.txt_ThumbsUpNum, UTL.String.GetCountStr(totalNum)) self.group_No1.img_Nor:SetRedPoint(leftNum > 0) self.group_No1.img_Gold:SetRedPoint(leftNum > 0) self.leftThumbUpNum = leftNum end function UISyncSoloMainPanel:RefreshRankInfo() local fairSoloTournamentData = MDL.SyncSolo.GetFairSoloTournamentNo1Info() self.isOpenBPBattle = CTL.SyncSolo.IsOpenBPBattle() if self.isOpenBPBattle then UIUtils.SetActive(self.btn_tips2, true) UIUtils.SetActive(self.bg_ChoiceHero, true) self.bg_ChoiceHero:SetText(UIUtils.GetLocalizedTxt(Const_IDS.IDS_FairPlay_IVITips)) else UIUtils.SetActive(self.btn_tips2, false) UIUtils.SetActive(self.bg_ChoiceHero, false) end if IsServerDataNotNil(fairSoloTournamentData) then self.UIState_Fair:SetState(1) --设置天下会武冠军信息 self.group_No1.lab_No1Name.text = CTL.OfficialPosition.GetModelNameShow(fairSoloTournamentData.officialTitle) .. fairSoloTournamentData.Name local roleInfo = CTL.Player.RoleSceneBasicToCommonRoleInfo(fairSoloTournamentData) self:ShowModel(roleInfo, fairSoloTournamentData) local titleConfig = DataSheetManager.Title:GetDataByID(TITLE_TOURNAMENT) CTL.Title.SetTitleShow(self.group_No1.titleTemplate, titleConfig) if string.isNilOrEmpty(fairSoloTournamentData.guildShow.guildName) == false then UIUtils.SetActive(self.group_No1.groupGuild, true) local framePath, emblemContent, guildDesc = CTL.Guild.GetModelNameShowParam(fairSoloTournamentData.guildShow.emblemFrame, fairSoloTournamentData.guildShow.emblemContent, fairSoloTournamentData.guildShow.guildName, fairSoloTournamentData.guildShow.jobTitle, fairSoloTournamentData.guildShow.identity) UIUtils.SetImageByAssetBundle(self.group_No1.img_GuildEmblem, framePath) self.group_No1.lab_EmblemName.text = emblemContent self.group_No1.lab_GuildName.text = guildDesc else UIUtils.SetActive(self.group_No1.groupGuild, false) self.group_No1.lab_GuildName.text = nil end else self.UIState_Fair:SetState(0) end local oldLevelRank = MDL.SyncSolo.GetSyncSoloLastDan() local levelRank = MDL.SyncSolo.GetSyncSoloCurDan() local rankData = DataSheetManager.SyncSoloData:GetDataByLevelID(levelRank) local curStar = rankData.Star local maxStar = rankData.MaxStar --上赛季段位,只推送一次,推完就归0 local lastSeasonDan = MDL.SyncSolo.GetSyncSoloLastSeasonDan() if lastSeasonDan ~= 0 then oldLevelRank = lastSeasonDan end if (levelRank > oldLevelRank and oldLevelRank ~=0) or lastSeasonDan ~= 0 then local oldRankData = DataSheetManager.SyncSoloData:GetDataByLevelID(oldLevelRank) --播放晋升特效或段位重置特效 if oldLevelRank ~= 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.UISyncTeamPVPUpGrade, {newData = rankData , oldData = oldRankData , txt = CTL.SyncSolo.GetEloDesc() , isSeasonChanged = lastSeasonDan ~= 0} , "SyncTeamPVP/UISyncTeamPVPUpGrade") end else CTL.KingChallenge.TryAutoOpenBuffUI() end self.effect_Rank:PlayUIEffect(rankData.LevelResidentEffect, 0) UIUtils.SetActive(self.img_TitleBg, true) self:PlayUIAnimation("UIAnimationRankTitle") MDL.SyncSolo.SaveSyncSoloLevelRank() --根据分数显示段位图 UIUtils.SetImageByAssetBundle(self.img_TitleBg, string.format(SyncTeamPVPImgPath, rankData.LevelImageFrame)) if self.loc_Title.CurState == 1 then self.loc_Title:SetText(0, UIUtils.GetLocalizedTxt(Const_IDS[rankData.LevelName])) self.loc_Color:SetState(rankData.LevelColor) else self.loc_Title:SetImage(0, "UI_3V3/"..rankData.LevelNameImage..".png", true) end self.txt_MyScore.text = CTL.SyncSolo.GetEloDesc() self.lab_PromotionCondition.text = CTL.SyncSolo.GetLevelRankDesc() for i, v in ipairs(self.group_Stars) do UIUtils.SetActive(v.gameObject, maxStar >= i) UIUtils.SetActive(v.img_Star, curStar >= i) end self:RefreshBtn() self:RefreshFormationHeroes() end function UISyncSoloMainPanel:OnUpdateFun(deltaTime, timeSinceUpdate) local levelRank = CTL.SyncSolo.GetSyncSoloLevelRank() local rankData = DataSheetManager.SyncSoloData:GetDataByLevelID(levelRank) self.effect_Rank:PlayUIEffect(rankData.LevelResidentEffect, 0) UIUtils.SetActive(self.img_TitleBg, true) self:PlayUIAnimation("UIAnimationRankTitle") self:StopRepeatFunc(self.OnUpdateFun) end function UISyncSoloMainPanel:RefreshFormationHeroes() local formationList = MDL.SyncSolo.LoadSyncSoloFormation() self.heroFormationNumber = 0 for i = 2, 6, 2 do local mainHeroId = formationList[i - 1] local cell = self.group_Hero[i / 2] UIUtils.SetActive(cell.img_MainHero, mainHeroId > 0) UIUtils.SetActive(cell.img_MainEmpty, not (mainHeroId > 0) ) UIUtils.SetActive(cell.img_experience01, mainHeroId > 0) if mainHeroId > 0 then UTL.Item.SetHeroIconByHeroId(cell.img_MainHero, CTL.HeroAwaken.DecodeHeroId(mainHeroId)) self.heroFormationNumber = self.heroFormationNumber + 1 UIUtils.SetActive(cell.img_experience01, CTL.FairPlayCard.IsUsedExperienceCard(mainHeroId)) end local subHeroId = formationList[i] UIUtils.SetActive(cell.img_SubHero, subHeroId > 0) UIUtils.SetActive(cell.img_SubEmpty, not (subHeroId > 0)) UIUtils.SetActive(cell.img_experience02, subHeroId > 0) if subHeroId > 0 then UTL.Item.SetHeroIconByHeroId(cell.img_SubHero, CTL.HeroAwaken.DecodeHeroId(subHeroId)) self.heroFormationNumber = self.heroFormationNumber + 1 UIUtils.SetActive(cell.img_experience02, CTL.FairPlayCard.IsUsedExperienceCard(subHeroId)) end end end function UISyncSoloMainPanel:RefreshSeasonFreeHeroes() if self.loopScroll_FreeHero.Count > 0 then self.loopScroll_FreeHero:ClearCells() end -- 测试武将 local testHeroArray = MDL.SyncSolo.GetTestHeroArray() if #testHeroArray > 0 then for i, v in ipairs(testHeroArray) do self.loopScroll_FreeHero:AddData(v, 0) end end -- 限免武将 local seasonData = MDL.SyncSolo.GetSyncSoloSeasonInfo() if seasonData.freeHeroes then for i, v in ipairs(seasonData.freeHeroes) do local isTestHeroAndOpen, isTestHero, isOpen = MDL.SyncSolo.CheckIsTestHero(v) if not isTestHeroAndOpen then self.loopScroll_FreeHero:AddData(v, 0) end end end end function UISyncSoloMainPanel:OnMatchExpression(state) if CTL.TeamMatch.IsActivityMatchingById(LuaConst.ActivityType.SyncSolo) then self:UpdateTimer(state) else self:UpdateTimer(false) end end --打开每日首胜 function UISyncSoloMainPanel:OnClickOpenWinOfEveryDay() UIManager.OpenView(Const_UI_Lua.UIEnum.UISyncSoloBattleDailyReward) end --打开每周奖励 function UISyncSoloMainPanel:OnClickOpenRewardOfEveryWeek() UIManager.OpenView(Const_UI_Lua.UIEnum.UISyncSoloBattleWeeklyReward) end --显示每日首胜状态\周任务红点 function UISyncSoloMainPanel:ShowRewardState() local state = MDL.SyncSolo.GetFirstWinOfEveryDayState() if state == MDL.SyncSolo.RewardState.NotReach then --未完成 UIUtils.SetActive(self.img_Reward1,true) UIUtils.SetActive(self.img_Reward2,false) self.effect_Available:StopUIEffect() elseif state == MDL.SyncSolo.RewardState.NotGet then --未领取 UIUtils.SetActive(self.img_Reward1,false) UIUtils.SetActive(self.img_Reward2,true) self.effect_Available:PlayUIEffect() elseif state == MDL.SyncSolo.RewardState.Get then --已领取 UIUtils.SetActive(self.img_Reward1,false) UIUtils.SetActive(self.img_Reward2,true) self.effect_Available:StopUIEffect() end --红点 self.btn_Daily:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_DailyReward)) self.btn_weekly:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.FairPlay_SyncSolo_WeeklyCanGet)) end function UISyncSoloMainPanel:UpdateTimer(state) if state then local maxTime = MDL.TeamDungeon.GetMaxMatchTime() local durTime = UTL.Time.GetServerTimestamp() - MDL.TeamMatch.GetStartMatchingTime() self.cdTimer:SetAndContinueTimer(true, durTime, maxTime) self.btn_Match:SetText(Const_IDS.IDS_UI_Word20) self.effect_Matching:PlayUIEffect() self.btn_ChooseHero:SetGray(true) else self.cdTimer:EndTimer() if self.isOpenBPBattle then self.btn_Match:SetText(Const_IDS.IDS_FairPlay_IVITop) else self.btn_Match:SetText(Const_IDS.IDS_Team_3v3_StartMatch) end self.effect_Matching:StopUIEffect() self.btn_ChooseHero:SetGray(false) end end function UISyncSoloMainPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loopScroll_FreeHero then UTL.Item.SetItemCell(cellTable.item, data) -- 测试标签 local isTestHeroAndOpen, isTestHero, isOpen = MDL.SyncSolo.CheckIsTestHero(data) UIUtils.SetActive(cellTable.img_TestBg, isTestHeroAndOpen) end end function UISyncSoloMainPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loopScroll_FreeHero then if target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data) end end end -- 服务器热更数据或者测试时间结束,需要把已上阵测试武将下阵 function UISyncSoloMainPanel:RefreshSyncSoloLineUp() local isRefreshLineUp = false local lineUp = {} local formationList = MDL.SyncSolo.LoadSyncSoloFormation() for _,heroId in ipairs(formationList) do local isTestHeroAndOpen, isTestHero, isOpen = MDL.SyncSolo.CheckIsTestHero(heroId, true) if isTestHero and not isOpen and not MDL.HeroSelect.IsHasHero(heroId) and UTL.Item.GetItemStockCount(CTL.FairPlayCard.experienceCardId) <= 0 then isRefreshLineUp = true table.insert(lineUp, 0) else table.insert(lineUp, heroId) end end MDL.SyncSolo.SaveSyncSoloFormation(lineUp) self:RefreshFormationHeroes() self:RefreshSeasonFreeHeroes() end -- 测试武将到期倒计时 function UISyncSoloMainPanel:TestHeroUpdateRepeatFunc() self:RefreshSyncSoloLineUp() self:StopRepeatFunc(self.TestHeroUpdateRepeatFunc) local testHeroTimer = MDL.SyncSolo.GetTestHeroTimer() if testHeroTimer > 0 then self:StartRepeatFunc(self.TestHeroUpdateRepeatFunc, testHeroTimer) end end function UISyncSoloMainPanel:RefreshKingChallengeEntry() UIUtils.SetActive(self.btn_KingChallenge, CTL.KingChallenge.IsShowKingChallengeEntry()) self.btn_KingChallenge:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.FairPlay_KingChallenge)) end function UISyncSoloMainPanel:OnValueChanged(comp, value) if comp == self.toggle_UseCard then if CTL.TeamMatch.IsActivityMatchingById(LuaConst.ActivityType.SyncSolo) and self.toggle_UseCard.isOn ~= self.cardToggleIsOn then self.toggle_UseCard.isOn = self.cardToggleIsOn CTL.Tips.AddTipsMsg(Const_IDS["IDS_KingChallenge_Hint10"]) else MDL.FairPlayCard.ChangeFairPlayCardInfoReq(MDL.FairPlay.FairPlayType.Solo, value, MDL.FairPlayCard.GetIs1V1ContinuousUseExperienceCard()) end end end function UISyncSoloMainPanel:OpenBPBattleMode() if self.isOpenBPBattle then if not PersistentData.PlayerData:Get(OPEN_BP_BATTLE_NODE, false) then PersistentData.PlayerData:Set(OPEN_BP_BATTLE_NODE, true, true) self:OnButtonClicked(self.UITemplateTitlePanel.btn_Info) end end end return UISyncSoloMainPanel