local UIGuildWarPreparationMap = UIViewClass() local RoomTypes = MDL.GuildWar.RoomTypes local MAXPLAYERCOUNT = 21 local WAR_ASSIST_COUNT = 3 function UIGuildWarPreparationMap:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_GuildWar_Phase2) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, false) self:RegistSystemEvent(EventID.UI_GuildWarGroupInfosUpdate, self.ShowInfos) self:RegistSystemEvent(EventID.UI_GuildWarArrayOpen,self.OnArrayOpen) MDL.GuildWar.C2GGetGuildWarPrepareInfo() local info = MDL.GuildWar.GetWarInfo() local time1 = info.battleOpenTime - DataSheetManager.ConstData:GetDataByID("GuildWarPrepareDeadlineTime").IntValue local time2 = info.battleOpenTime - DataSheetManager.ConstData:GetDataByID("GuildWarMemberPrepareDeadlineTime").IntValue self.txt_Countdown2.text = string.FormatByIdsId(Const_IDS.IDS_GuildWar_FormationTime1, os.date(UTL.Time.FormatDateEnum.HM, time2)) self.txt_Countdown1.text = string.FormatByIdsId(Const_IDS.IDS_GuildWar_FormationTime2, os.date(UTL.Time.FormatDateEnum.HM, time1)) end function UIGuildWarPreparationMap:ShowInfos(groupInfos) self:SetGroupInfo(groupInfos[1]) self:SetGroupInfo(groupInfos[2]) local players = {} for i, v in ipairs(groupInfos[3].players) do table.insert(players, v) end for i, v in ipairs(groupInfos[4].players) do table.insert(players, v) end for i, v in ipairs(groupInfos[5].players) do table.insert(players, v) end self:SetGroupInfo(groupInfos[3], players) end function UIGuildWarPreparationMap:OnArrayOpen(active) self.node.gameObject:SetActive(active) end function UIGuildWarPreparationMap:SetGroupInfo(data, players) local gs = 0 local obj = self.groups[data.roomType] local count = 0 local isSelf = false local maxCount = players and MAXPLAYERCOUNT * WAR_ASSIST_COUNT or MAXPLAYERCOUNT players = players or data.players for i,v in ipairs(players) do if v.isHasPlayer then gs = gs + v.headInfo.gsSum count = count + 1 if v.headInfo.acid == BattleDataGetter.GetAcID() then isSelf = true end end end local countStr if count == maxCount then countStr = UTL.Color.FormatRedColor(count) .."/"..maxCount else countStr = count .."/"..maxCount end UIUtils.SetLabel(obj.txt_Member, countStr) UIUtils.SetLabel(obj.txt_TitleNumber, UTL.String.GetCountStr(gs)) if isSelf then obj.effect_SwordCrash:PlayUIEffect() else obj.effect_SwordCrash:StopUIEffect() end end function UIGuildWarPreparationMap:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildWarPreparationMap:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_ModifyTeam then local info = MDL.GuildWar.GetWarInfo() if info.Stage == MDL.GuildWar.Stages.StageTypePrepare then if MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle,MDL.Guild.AuthorityEnum.GuildWarPrepareEdit) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarArray,{1,isEditor = true}) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_EditAuthority) end else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_NotInFormationTime) end else for i,v in ipairs(self.groups) do if v.btn_CheckOut == comp then self:ClickOpenView(i) end end end end function UIGuildWarPreparationMap:ClickOpenView(index) local info = MDL.GuildWar.GetWarInfo() if info.Stage == MDL.GuildWar.Stages.StageTypePrepare then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarArray,{index}) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_NotInFormationTime) end end function UIGuildWarPreparationMap:GetPlayerName(name) local count = UTL.String.GetStrCharCount(name,1) if count > 2 then name = UTL.String.CutZHStrByLength(name,2).."..." end return name end function UIGuildWarPreparationMap:OnClosed() UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info, true) end return UIGuildWarPreparationMap