local UIHeroMatch1v1Base = UIViewClass()
local HeroMatch1v1Race2 = DataSheetManager.ConstData:GetDataByID("HeroMatch1v1Race2").IntValue -- 筛选赛每日参与次数上限
-- 排序:id
local function SortStage(MatchStage_1, MatchStage_2)
return MatchStage_1.ID > MatchStage_2.ID
end
function UIHeroMatch1v1Base:OnOpened(context)
if MDL.HeroMatch1v1.IsShowHeroMatch1v1Entry() then
MDL.HeroMatch1v1.HeroMatchGetAllPlayerInfoRequest()
MDL.HeroMatch1v1.HeroMatchOpenRequest()
MDL.Rank.GetRankInfoReq(MDL.Rank.RankType.HeroMatch1v1, {isPreRank = false}, CTL.Rank.SortType.MyServer)
--标题
UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_HeroMatch1v1_Title)
self:RegistSystemEvent(EventID.UI_HeroMatch1v1_CloseView, self.OnBackButtonPressed) -- 赛程结束关闭界面
self:RegistSystemEvent(EventID.UI_HeroMatch1v1_RefreshInfo, self.RefreshHeroMatch1v1BaseView) -- 刷新界面信息
self.curSelectToggleIndex = 0
-- stage选中的cell index
self.selectIndex = 0
-- stage 上次选中cell index
self.lastSelectIndex = -1
self.btn_Attend:SetGray(true)
self:RefreshHeroMatch1v1BaseView()
if self.curStageID ~= MDL.HeroMatch1v1.Stage.ShowHero then
self:StartRepeatFunc(self.UpdateAllPlayerInfosRepeatFunc, 300) -- 5分钟刷新一次64强玩家信息
else
self:StopRepeatFunc(self.UpdateAllPlayerInfosRepeatFunc)
end
else
self:OnButtonClicked(self.UITemplateTitlePanel.btn_close)
end
end
function UIHeroMatch1v1Base:OnClosePanel()
end
---@public 5分钟刷新一次64强玩家信息
function UIHeroMatch1v1Base:UpdateAllPlayerInfosRepeatFunc(deltaTime, timeSinceUpdate)
MDL.HeroMatch1v1.HeroMatchGetAllPlayerInfoRequest()
end
---@public 赛季活动开始后入口状态变更
function UIHeroMatch1v1Base:UpdateAttendBtnStageRepeatFunc(deltaTime, timeSinceUpdate)
self.btn_Attend:SetGray(false)
end
function UIHeroMatch1v1Base:OnBackButtonPressed()
self:OnButtonClicked(self.UITemplateTitlePanel.btn_close)
end
function UIHeroMatch1v1Base: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.UITemplateTitlePanel.btn_Info then
UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView,{id = LuaConst.NoteID.HeroMatch1v1})
elseif comp == self.btn_WarZone then -- 战区
UIManager.OpenView(Const_UI_Lua.UIEnum.UIWarzoneList, {crossServerZoneGroupType = MDL.CrossServer.CrossServerZoneGroupType[LuaConst.ActivityType.HeroMatch1v1]})
elseif comp == self.btn_Reward then -- 奖励预览
UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1Reward)
elseif comp == self.btn_Formation then -- 布阵
if MDL.HeroMatch1v1.IsCountryHeroEnough() == false then
CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_MinTeamHeroNum, MDL.HeroMatch1v1.GetCurCountryDesc()))
return
end
UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1SelectOfficer, { freeLineupFuncType = MDL.FreeLineUp.FuncType.HeroMatch1v1, activityType = LuaConst.ActivityType.HeroMatch1v1 },
"DemonGod/UIDemonGodSelectOfficer")
elseif comp == self.btn_Guess then -- 话题竞猜
UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1Guessing)
elseif comp == self.btn_Watch then -- 观战奖励
UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1SubtitleReward)
elseif comp == self.btn_Attend then -- 参加活动
if MDL.HeroMatch1v1.IsCountryHeroEnough() == false then
CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_HeroMatch3v3_MinTeamHeroNum, MDL.HeroMatch1v1.GetCurCountryDesc()))
return
end
if BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown) then
CTL.Tips.AddTipsMsg(Const_IDS.IDS_HeroMatch1v1_BeInScene)
else
self:CloseView(true)
CTL.HeroMatch1v1.EnterBattleMatchLobby()
end
elseif comp == self.btn_GoToSeeWinner then
CTL.HeroMatch1v1.GoWorshipEvent()
self:CloseView(true)
elseif comp == self.btn_Store then
-- 商店跳转
UIManager.OpenView(Const_UI_Lua.UIEnum.UIHeroMatch1v1Store)
end
end
function UIHeroMatch1v1Base:OnCellInit(scrollRect, index, cellTable, data)
if data.ID <= MDL.HeroMatch1v1.Stage.Filtration_2 then
UIUtils.SetLabelText(cellTable.txt_Progress, Const_IDS.IDS_HeroMatch1v1_RaceOne)
else
UIUtils.SetLabel(cellTable.txt_Progress, string.FormatByIdsId(Const_IDS[data.InterfaceDes]))
end
if index == 0 then
cellTable.state_Line:SetState(2)
else
cellTable.state_Line:SetState(data.ID >= self.curStageID and 0 or 1)
end
if data.ID == self.selectStage then
cellTable.state_TabBg:SetState(1)
else
if data.ID <= MDL.HeroMatch1v1.Stage.Filtration_2 then
cellTable.state_TabBg:SetState(self.curStageID >= data.ID and 0 or 2)
if self.curStageID >= data.ID then
cellTable.state_ProgressBg:SetState(index == 0 and 1 or 0)
end
else
if self.curStageID <= MDL.HeroMatch1v1.Stage.Filtration_2 then
cellTable.state_TabBg:SetState(2)
else
cellTable.state_TabBg:SetState(data.ID >= self.curStageID and 0 or 2)
if index == 0 then
cellTable.state_ProgressBg:SetState(self.curStageID >= data.ID and 1 or 0)
end
end
end
end
cellTable.state_Scale:SetState(self.selectIndex - 1 == index and 1 or 0)
end
function UIHeroMatch1v1Base:OnCellClicked(scrollRect, index, cellTable, target, data)
if target == cellTable.btn_Select then
if data.ID ~= self.selectStage then
if data.ID <= MDL.HeroMatch1v1.Stage.Filtration_2 then
if self.curStageID >= MDL.HeroMatch1v1.Stage.Filtration_2 then
self.curSelectToggleIndex = self.selectStage ~= data.ID and 0 or self.curSelectToggleIndex
self.selectStage = data.ID
self.selectIndex = index
self:OpenHeroMatch1v1SubView()
end
else
if self.curStageID > MDL.HeroMatch1v1.Stage.Filtration_2 and data.ID >= self.curStageID then
self.curSelectToggleIndex = self.selectStage ~= data.ID and 0 or self.curSelectToggleIndex
self.selectStage = data.ID
self.selectIndex = index
self:OpenHeroMatch1v1SubView()
end
end
end
end
end
function UIHeroMatch1v1Base:OnValueChanged(comp, value)
if comp == self.group_Toggles then
if self.selectStage >= MDL.HeroMatch1v1.Stage.match_2T1 then
self.stageView:SetPlayerGroupInfo(value)
self.curSelectToggleIndex = value
end
end
end
function UIHeroMatch1v1Base:RefreshHeroMatch1v1BaseView()
local curStageID = MDL.HeroMatch1v1.GetCurStageID()
self.curSelectToggleIndex = self.selectStage ~= curStageID and 0 or self.curSelectToggleIndex
self.curStageID = curStageID
self.selectStage = curStageID
self.winnerStageInfo = MDL.HeroMatch1v1.GetMatchStageInfo(self.selectStage)
self.matchStageList = {}
if self.winnerStageInfo then
if self.selectStage >= MDL.HeroMatch1v1.Stage.Filtration_1 then
for k,v in DataSheetManager.MatchStage:GetEnumerator() do
if v.ID >= MDL.HeroMatch1v1.Stage.match_2T1 then
table.insert(self.matchStageList, v)
end
end
end
if #self.matchStageList > 0 then
table.sort(self.matchStageList, SortStage)
if MDL.HeroMatch1v1.GetMatchStageInfo(MDL.HeroMatch1v1.Stage.Filtration_2) then
table.insert(self.matchStageList, 1, DataSheetManager.MatchStage:GetDataByID(MDL.HeroMatch1v1.Stage.Filtration_2))
else
table.insert(self.matchStageList, 1, DataSheetManager.MatchStage:GetDataByID(MDL.HeroMatch1v1.Stage.Filtration_1))
end
table.insert(self.matchStageList, DataSheetManager.MatchStage:GetDataByID(MDL.HeroMatch1v1.Stage.ShowHero))
end
self:OpenHeroMatch1v1SubView()
-- 设置上一次选中默认页签,初始-1
self.lastSelectIndex = self.selectIndex
end
self.btn_GoToSeeWinner:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.HeroMatch1v1_WorshipReward))
end
function UIHeroMatch1v1Base:OpenHeroMatch1v1SubView()
UIUtils.SetActive(self.btn_Guess, true)
UIUtils.SetActive(self.btn_Watch, true)
UIUtils.SetActive(self.btn_Attend, true)
UIUtils.SetActive(self.btn_Formation, true)
UIUtils.SetActive(self.btn_GoToSeeWinner, false)
UIUtils.SetActive(self.group_Info, true)
UIUtils.SetActive(self.group_Toggles, true)
UIUtils.SetActive(self.group_Progress, true)
UIUtils.SetActive(self.img_BgBottom, false)
UIUtils.SetActive(self.img_Bottom, true)
self.curMatchTimeID = MDL.HeroMatch1v1.GetCurMatchTimeID()
self.winnerStageInfo = MDL.HeroMatch1v1.GetMatchStageInfo(self.selectStage)
local MatchTime = DataSheetManager.MatchTime:GetDataByID(self.curMatchTimeID)
self:StopRepeatFunc(self.UpdateAttendBtnStageRepeatFunc)
if self.curMatchTimeID < MDL.HeroMatch1v1.Enum_BigStage.Display then
if self.winnerStageInfo.state == MDL.HeroMatch1v1.Enum_State.Finish then
self.btn_Attend:SetGray(true, false)
else
if UTL.Time.IsServerInOpeningTime(MatchTime.StartTime, MatchTime.EndTime) then
self.btn_Attend:SetGray(false)
else
self.btn_Attend:SetGray(true, false)
local offsetTime = UTL.Time.GetServerIntervalTimeByTimeId(MatchTime.StartTime)
self:StartRepeatFunc(self.UpdateAttendBtnStageRepeatFunc, offsetTime > 0 and offsetTime or offsetTime + UTL.Time.TotalSecondsOneDay)
end
end
else
self.btn_Attend:SetGray(true, false)
end
UIUtils.SetActive(self.btn_Attend, not BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown))
if self.selectStage <= MDL.HeroMatch1v1.Stage.Filtration_2 then -- 筛选赛
UIUtils.SetActive(self.img_BgBottom, true)
UIUtils.SetActive(self.group_Toggles, false)
UIUtils.SetActive(self.group_Progress, false)
UIUtils.SetActive(self.btn_Watch, false)
if self.lastSelectIndex ~= self.selectIndex then
self.subView:CloseAll()
self.stageView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroMatch1v1Stage1_Filtration))
end
else
self.subView:CloseAll()
if self.selectStage == MDL.HeroMatch1v1.Stage.ShowHero then -- 冠军展示期
UIUtils.SetActive(self.img_Bottom, false)
UIUtils.SetActive(self.btn_Guess, false)
UIUtils.SetActive(self.btn_Watch, false)
UIUtils.SetActive(self.btn_Attend, false)
UIUtils.SetActive(self.btn_Formation, false)
UIUtils.SetActive(self.btn_GoToSeeWinner, true)
UIUtils.SetActive(self.group_Info, false)
UIUtils.SetActive(self.group_Toggles, false)
self.stageView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroMatch1v1Stage6_Supremacy))
self.stageView:SetPlayerGroupInfo()
elseif self.selectStage == MDL.HeroMatch1v1.Stage.match_2T1 then -- 冠军赛
UIUtils.SetActive(self.img_BgBottom, true)
UIUtils.SetActive(self.group_Toggles, false)
self.stageView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroMatch1v1Stage5))
elseif self.selectStage == MDL.HeroMatch1v1.Stage.match_4T2 then -- 4进2
UIUtils.SetActive(self.group_Toggles, false)
self.stageView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroMatch1v1Stage4))
elseif self.selectStage == MDL.HeroMatch1v1.Stage.match_8T4 then -- 8进4
UIUtils.SetActive(self.group_Toggles, false)
self.stageView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroMatch1v1Stage3))
elseif self.selectStage >= MDL.HeroMatch1v1.Stage.match_16T8 then -- 16进8 以及大于16人的比赛都用同一个子界面
self.stageView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIHeroMatch1v1Stage2), {stageID = self.selectStage})
UTL.Toggle.InitToggleGroupByIDS(self.group_Toggles, "txt", {Const_IDS.IDS_HeroMatch1v1_Team1, Const_IDS.IDS_HeroMatch1v1_Team2, Const_IDS.IDS_HeroMatch1v1_Team3, Const_IDS.IDS_HeroMatch1v1_Team4})
self.group_Toggles:SetToggleCompActive(1, "img_Line", false)
local myGroupNum = MDL.HeroMatch1v1.GetMyGroupAndIndex(self.selectStage) - 1
if self.curSelectToggleIndex > 0 then
self.group_Toggles:SelectIndex(self.curSelectToggleIndex)
else
self.group_Toggles:SelectIndex(myGroupNum)
end
if self.curSelectToggleIndex == myGroupNum then
if self.selectStage >= MDL.HeroMatch1v1.Stage.match_2T1 then
self.stageView:SetPlayerGroupInfo(myGroupNum)
self.curSelectToggleIndex = myGroupNum
end
end
end
end
self.cdTimer:EndTimer()
if self.selectStage == MDL.HeroMatch1v1.Stage.ShowHero then
UIUtils.SetActive(self.tips_Attend, false)
else
local stageInfo = MDL.HeroMatch1v1.GetMatchStageInfo(MDL.HeroMatch1v1.GetCurStageID())
local isShowTipsAttend = BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.CrossHeroMatchTown) and stageInfo.state ~= MDL.HeroMatch1v1.Enum_State.Finish
UIUtils.SetActive(self.tips_Attend, isShowTipsAttend)
if isShowTipsAttend then
local startTimestamp = stageInfo.stateEndTime
local leftTime = startTimestamp - UTL.Time.GetServerTimestamp() > 0 and startTimestamp - UTL.Time.GetServerTimestamp() or 0
if stageInfo.state == MDL.HeroMatch1v1.Enum_State.Battle then
self.cdTimer:ResetAndBeginCustomTimer(false, leftTime, 0, string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_SkipBattleTime).."\n{0}:{1}:{2}")
else
self.cdTimer:ResetAndBeginCustomTimer(false, leftTime, 0, string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_MatchingTime).."\n{0}:{1}:{2}")
end
end
end
if #self.matchStageList > 0 then
for k,v in ipairs(self.matchStageList) do
if v.ID == self.selectStage then
self.selectIndex = k - 1
break
end
end
self.loop_Progress:ReloadAll(self.matchStageList)
end
if self.selectStage ~= MDL.HeroMatch1v1.Stage.ShowHero then
self:RefreshCurStageInfo()
end
end
function UIHeroMatch1v1Base:RefreshCurStageInfo()
UIUtils.SetActive(self.txt_Chances, true)
self.myMatchInfo = MDL.HeroMatch1v1.GetMyMatchInfo()
self.matchStageCfg = DataSheetManager.MatchStage:GetDataByID(self.curStageID)
self.matchTimeCfg = DataSheetManager.MatchTime:GetDataByID(self.matchStageCfg.NowStage)
if self.curStageID <= MDL.HeroMatch1v1.Stage.Filtration_2 then -- 筛选赛
local winScore = DataSheetManager.ConstData:GetDataByID("HeroMatch1v1WinScore").IntValue
local loseScore = DataSheetManager.ConstData:GetDataByID("HeroMatch1v1LoseScore").IntValue
self:SetRule(string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_PromotionCondition1, winScore, loseScore)) -- 筛选赛结束后,总胜场多者晋级
self:SetTimer()
UIUtils.SetLabelText(self.lab_Chances, Const_IDS.IDS_HeroMatch1v1_SurplusNum) -- 剩余可参与场次
local todayNum = self.myMatchInfo.todayNum and self.myMatchInfo.todayNum or 0
UIUtils.SetLabel(self.txt_Chances, string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_SurplusNum1, HeroMatch1v1Race2, HeroMatch1v1Race2 - todayNum))
elseif self.curStageID == MDL.HeroMatch1v1.Stage.match_2T1 then -- 冠军赛
self:SetRule(Const_IDS.IDS_HeroMatch1v1_PromotionCondition3) -- 比拼3轮,每轮3局2胜,赢得2轮者胜出
self:SetGuessing()
self:SetTimer()
elseif self.curStageID == MDL.HeroMatch1v1.Stage.match_4T2 then -- 4进2
self:SetRule(Const_IDS.IDS_HeroMatch1v1_PromotionCondition3) -- 比拼3轮,每轮3局2胜,赢得2轮者胜出
self:SetGuessing()
self:SetTimer()
elseif self.curStageID == MDL.HeroMatch1v1.Stage.match_8T4 then -- 8进4
self:SetRule(Const_IDS.IDS_HeroMatch1v1_PromotionCondition3) -- 三局两胜
self:SetGuessing()
self:SetTimer()
elseif self.curStageID >= MDL.HeroMatch1v1.Stage.match_16T8 then -- 16进8 以及大于16人的比赛都用同一个子界面
self:SetRule(Const_IDS.IDS_HeroMatch1v1_PromotionCondition2) -- 三局两胜
self:SetGuessing()
self:SetTimer()
end
self:SetRecord()
end
function UIHeroMatch1v1Base:SetTimer()
UIUtils.SetLabel(self.lab_Time, string.Concat(UIUtils.GetLocalizedTxt(Const_IDS[self.matchStageCfg.InterfaceDes]), UIUtils.GetLocalizedTxt(Const_IDS.IDS_HeroMatch1v1_ActivityTime)))
local starTime = UTL.Time.GetDiffLocalStrById(self.matchTimeCfg.StartTime)
local endTime = UTL.Time.GetDiffLocalStrById(self.matchTimeCfg.EndTime)
if self.curStageID >= MDL.HeroMatch1v1.Stage.match_2T1 and self.curStageID <= MDL.HeroMatch1v1.Stage.match_64T32 then
local curStageInfo = MDL.HeroMatch1v1.GetMatchStageInfo(self.curStageID)
local month, day, hourMinute = UTL.Time.FormatTimeSimple(curStageInfo.stateEndTime)
if GameAppInfo.IsVietnamPackage() then
UIUtils.SetLabel(self.txt_Time, string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_ActivityTime1, starTime, endTime, day, month))
else
UIUtils.SetLabel(self.txt_Time, string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_ActivityTime1, month, day, starTime, endTime))
end
else
local MatchServerInfo = MDL.HeroMatch1v1.GetHeroMatch1v1AllInfo()
local dayNum = 0
for k,v in DataSheetManager.MatchTime:GetEnumerator() do
dayNum = dayNum + v.Day
if v.ID + 1 == self.curMatchTimeID then
if self.curStageID == MDL.HeroMatch1v1.Stage.Filtration_2 then
dayNum = dayNum + 1
end
local month, day, hourMinute = UTL.Time.FormatTimeSimple(MatchServerInfo.startTm + dayNum * UTL.Time.TotalSecondsOneDay)
if GameAppInfo.IsVietnamPackage() then
UIUtils.SetLabel(self.txt_Time, string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_ActivityTime1, starTime, endTime, day, month))
else
UIUtils.SetLabel(self.txt_Time, string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_ActivityTime1, month, day, starTime, endTime))
end
return
end
end
end
end
function UIHeroMatch1v1Base:SetRecord()
local myRankDesc, myRank = CTL.HeroMatch1v1.GetMyCurRankInfoDesc()
if self.myMatchInfo and self.myMatchInfo.myStage and self.myMatchInfo.myStage > 0 then
UIUtils.SetLabelText(self.lab_PersonalScore, Const_IDS.IDS_Chat_BestRank) -- 最好成绩
else
UIUtils.SetLabelText(self.lab_PersonalScore, Const_IDS.IDS_HeroMatch1v1_NowResult) -- 当前成绩
end
UIUtils.SetLabel(self.txt_PersonalScore, myRankDesc)
end
function UIHeroMatch1v1Base:SetRule(rule)
UIUtils.SetLabelText(self.lab_Rule, Const_IDS.IDS_HeroMatch1v1_PromotionCondition) -- 晋级条件
UTL.String.SetLabelContent(self.txt_Rule, rule)
end
function UIHeroMatch1v1Base:SetGuessing()
UIUtils.SetLabel(self.lab_Chances,
string.FormatByIdsId(Const_IDS.IDS_HeroMatch1v1_LeftPickNum,
self.matchTimeCfg.GuessTimes - self.myMatchInfo.battleBetNum,
self.matchTimeCfg.GuessTimes)) -- 今日剩余竞猜次数:%s/%s
UIUtils.SetActive(self.txt_Chances, false)
end
return UIHeroMatch1v1Base