local UIGuildWarMain = UIViewClass() local Stages = MDL.GuildWar.Stages local FightStages = MDL.GuildWar.FightStages function UIGuildWarMain:OnOpened(context) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_ActivityName_GuildWar) self:RegistSystemEvent(EventID.UI_GuildWarStageUpdate,self.UpdateInfo) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar, self.SetRedPoint) MDL.GuildWar.SendGetGuildWarInfo() if self.loc_Title.CurState==0 then UIUtils.SetLocalizationImage(self.img_Title, "slz_msz_slzb.png") end self:RefreshActivityRedPoint() UTL.UIRender.AdaptiveImageSizeFit(self.bg, true) self.UITemplateTitlePanel.state_Title:SetState(1) end function UIGuildWarMain:RefreshActivityRedPoint() if MDL.Activities.GetRedPointByID(LuaConst.ActivityType.GuildWar) then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.GuildWar, 1, true, LuaConst.ActivityType.GuildWar) end end function UIGuildWarMain:UpdateInfo() local info = MDL.GuildWar.GetWarInfo() self:SetTimeInfo(info) self:SetBtnText(info) self:OpenSubView(info) self:SetRedPoint() end function UIGuildWarMain:SetRedPoint() local active = CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_GuildWar) self.event_Receive:SetRedPoint(active) end function UIGuildWarMain:SetTimeInfo(info) if info.Stage == Stages.StageTypeNone then local timeValue = info.signUpOpenTime - UTL.Time.GetServerTimestamp() self:SetCdTime(timeValue) UIUtils.SetLabelText(self.txt_LimitTime1,Const_IDS.IDS_GuildWar_PrepareToSign) elseif info.Stage == Stages.StageTypeSignUp then local timeValue = info.prepareOpenTime - UTL.Time.GetServerTimestamp() self:SetCdTime(timeValue) UIUtils.SetLabelText(self.txt_LimitTime1,Const_IDS.IDS_GuildWar_DeadlineOfSign) elseif info.Stage == Stages.StageTypePrepare then local timeValue = info.battleOpenTime - UTL.Time.GetServerTimestamp() self:SetCdTime(timeValue) UIUtils.SetLabelText(self.txt_LimitTime1,Const_IDS.IDS_GuildWar_PrepareToBattle) elseif info.Stage == Stages.StageTypeBattle then if info.isFightEnd and (info.fightStage ==FightStages.FirstFighting or info.fightStage ==FightStages.SecondFighting) then UIUtils.SetLabelText(self.txt_LimitTime1,Const_IDS.IDS_GuildWar_Waiting) self.txt_LimitTime2:EndTimer() elseif info.fightStage == FightStages.FirstEnd then local timeValue = info.nextStartTime - UTL.Time.GetServerTimestamp() self:SetCdTime(timeValue) UIUtils.SetLabelText(self.txt_LimitTime1,Const_IDS.IDS_GuildWar_PrepareToBattle) else UIUtils.SetLabelText(self.txt_LimitTime1,Const_IDS.IDS_GuildWar_Fighting) self.txt_LimitTime2:EndTimer() end else self.txt_LimitTime2:EndTimer() self.txt_LimitTime1.text = nil end local selectIndex = 0 self.brightState:SetState(0) if info.Stage == Stages.StageTypeNone then self.Slider.value = 0 self.brightState:SetState(0) elseif info.Stage == Stages.StageTypeSignUp then selectIndex = 1 self.Slider.value = 0.126 self.brightState:SetState(1) elseif info.Stage == Stages.StageTypePrepare then selectIndex = 2 self.Slider.value = 0.379 self.brightState:SetState(2) elseif info.Stage == Stages.StageTypeBattle then selectIndex = 3 self.Slider.value = 0.632 self.brightState:SetState(3) elseif info.Stage == Stages.StageTypeEnd then selectIndex = 4 self.Slider.value = 0.884 self.brightState:SetState(4) end local times = {info.signUpOpenTime, info.prepareOpenTime, info.battleOpenTime, info.battleEndTime} for i,v in ipairs(self.stages) do v.localLab_UnTime.text = os.date(UTL.Time.FormatDateEnum.YMDHM, times[i]) v.localLab_Time.text = os.date(UTL.Time.FormatDateEnum.YMDHM, times[i]) if i <= selectIndex then v.lab_Switch:SetState(1) else v.lab_Switch:SetState(0) end end UIUtils.SetActive(self.btn_Kuafu, CTL.GuildWar.IsCrossServerSettled()) self.txt_Num.text = string.FormatByIdsId(Const_IDS.IDS_GuildWar_ScheduleTitle,info.issue) end function UIGuildWarMain:SetCdTime(timeValue) if timeValue > UTL.Time.TotalSecondsOneDay then self.txt_LimitTime2:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Time2),1,1) self.txt_LimitTime2:ResetAndBeginTimer(false,timeValue,0) else self.txt_LimitTime2:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS.IDS_GuildWar_Time1),1,2) self.txt_LimitTime2:ResetAndBeginTimer(false,timeValue,0) end end function UIGuildWarMain:SetBtnText(info) if info.Stage == Stages.StageTypeNone then self.event_Receive:SetText(Const_IDS.IDS_GuildWar_Sign) self.event_Receive:SetGray(false) elseif info.Stage == Stages.StageTypeSignUp then if info.isSignUp then self.event_Receive:SetText(Const_IDS.IDS_GuildWar_Signed) self.event_Receive:SetGray(true,true) else self.event_Receive:SetText(Const_IDS.IDS_GuildWar_Sign) self.event_Receive:SetGray(false) end elseif info.Stage == Stages.StageTypePrepare then if info.isSignUp then self.event_Receive:SetText(Const_IDS.IDS_GuildWar_Formation) self.txt_SignEnd.text = nil self.event_Receive.gameObject:SetActive(true) self.event_Receive:SetGray(false) else self.event_Receive.gameObject:SetActive(false) UIUtils.SetLabelText(self.txt_SignEnd, Const_IDS.IDS_GuildWar_NotSignWar) end elseif info.Stage == Stages.StageTypeBattle then if info.fightStage == FightStages.FirstEnd then self.event_Receive.gameObject:SetActive(true) --UIUtils.SetLabelText(self.txt_SignEnd, Const_IDS.IDS_GuildWar_Phase4) self.event_Receive:SetText(Const_IDS.IDS_GuildWar_ToBattle) elseif info.fightStage >= FightStages.SecondEnd then self.event_Receive.gameObject:SetActive(false) UIUtils.SetLabelText(self.txt_SignEnd, Const_IDS.IDS_GuildWar_Phase4) else if info.isSignUp then self.event_Receive:SetText(Const_IDS.IDS_GuildWar_ToBattle) self.txt_SignEnd.text = nil self.event_Receive.gameObject:SetActive(true) self.event_Receive:SetGray(false) else self.event_Receive.gameObject:SetActive(false) UIUtils.SetLabelText(self.txt_SignEnd, Const_IDS.IDS_GuildWar_NotSignWar) end end elseif info.Stage == Stages.StageTypeEnd then self.event_Receive.gameObject:SetActive(false) UIUtils.SetLabelText(self.txt_SignEnd, Const_IDS.IDS_GuildWar_WarEnded) end end function UIGuildWarMain:OpenSubView(info) self.subView:CloseAll() if info.Stage == Stages.StageTypeNone then self.first_Title.gameObject:SetActive(true) self.event_Receive:SetGray(true,true) elseif info.Stage <= Stages.StageTypeSignUp then self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildWarSingUpView), info) self.first_Title.gameObject:SetActive(false) else self.first_Title.gameObject:SetActive(false) self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildWarReadyView), info) end end function UIGuildWarMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildWarMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.event_Receive then local info = MDL.GuildWar.GetWarInfo() if info.Stage == Stages.StageTypeSignUp then if info.isSignUp then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_GuildSigned) else MDL.GuildWar.GuildWarSignUpReq() end elseif info.Stage == Stages.StageTypeBattle then local lineUpHeroCount = MDL.Player.GetLineUpHeroCount() if lineUpHeroCount < 6 then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1024_InfoCode_PeopleNotEnough) return end MDL.GuildWar.EnterGuild() MDL.GuildWar.SetClickCommandBtn(nil) elseif info.Stage == Stages.StageTypeNone then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildWar_NotStartToSign) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarPreparationMap) end elseif comp == self.btn_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarRewardIntroduction) elseif comp == self.btn_Wall then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarWallOfFame) elseif comp == self.btn_Score then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarPastScoreList) elseif comp == self.btn_Shop then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.ShiLi}) elseif comp == self.UITemplateTitlePanel.btn_Info then CTL.GuildWar.OpenGuildWarNoteView() elseif comp == self.btn_Intro then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarBattleGround) elseif comp == self.btn_Kuafu then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildWarCrossServerActivities) end end function UIGuildWarMain:OnClosed() self.UITemplateTitlePanel.state_Title:SetState(0) end return UIGuildWarMain