local UIGuildBossBattle = UIViewClass() local UIGuildBossBattleView = require("View/GuildBoss/UIGuildBossBattleView") local TempRankDataTb = {} function UIGuildBossBattle:OnOpened(context) self.curSelectIsGuild = true self.bossHpView = nil self:RegistSystemEvent(EventID.UI_GuildBoss_RankRefresh,self.OnRankRefresh) self:RegistSystemEvent(EventID.UI_GuildBoss_EncourageRefresh, self.SetEncourageInfo) self:RegistSystemEvent(EventID.UIBattle_Level_SetUpBoss, self.SetUpBoss) self:RegistSystemEvent(EventID.UI_GuildBoss_Stagefresh, self.SetCountDown) self:RegistSystemEvent(EventID.UI_GuildAuctionBtnState_Refresh, self.RefreshGuildAuctionBtnInfo) self:OnRankRefresh() self:RefreshGuildAuctionBtnInfo() self.tab_state:SetState(0) self:SetCountDown() end function UIGuildBossBattle:RefreshGuildAuctionBtnInfo() local state = MDL.GuildAuction.GetTownHomeBtnShowType() if state == MDL.GuildAuction.TownHomeBtnState.None then self.state_InAuction:SetState(0) UIUtils.SetLabelText(self.lab_InAuction, Const_IDS["IDS_Auction_FunctionName"]) UIUtils.SetActive(self.auction_GroupInfo, false) else self.state_InAuction:SetState(1) UIUtils.SetActive(self.auction_GroupInfo, true) UIUtils.SetLabelText(self.lab_InAuction, Const_IDS["IDS_Auction_AuctionOpening"]) if state == MDL.GuildAuction.TownHomeBtnState.Guild then self.auction_StateType:SetState(1) elseif state == MDL.GuildAuction.TownHomeBtnState.Cross then self.auction_StateType:SetState(2) elseif state == MDL.GuildAuction.TownHomeBtnState.World then self.auction_StateType:SetState(0) end end end function UIGuildBossBattle:SetUpBoss(active, monsterId, entityID) if active then if not self.bossHpView then self.bossHpView = self.bossHPRoot:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIGuildBossBattleView), {entityID = entityID}) else self.bossHpView:ActiveUI({entityID = entityID}) end else if self.bossHpView then self.bossHpView:HideUI() end end end function UIGuildBossBattle:OnUpdateFun(deltaTime, timeSinceUpdate) MDL.Level.SendRoleLeaveFubenFromSetting() end function UIGuildBossBattle:SetCountDown() local curStateTimeInfo = MDL.GuildBoss.GetCurStateTimeInfo() if not curStateTimeInfo.stageOrder then return end if curStateTimeInfo.stageOrder == MDL.GuildBoss.Stage.Ready then local time = curStateTimeInfo.stageEndTimeStamp - UTL.Time.GetServerTimestamp() UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildBossMsg,{value = time}) UIUtils.SetActive(self.event_Auction, true) elseif curStateTimeInfo.stageOrder > MDL.GuildBoss.Stage.Fight3 then if BattleDataGetter.GetCurLevelType() == LuaConst.LevelType.GuildBossTown then local value = 0 for i=curStateTimeInfo.stageOrder+1,MDL.GuildBoss.Stage.RollAfter do value = value + DataSheetManager.GuildBossStage:GetDataByID_Order(1,i).StageTriggerTime end local time = curStateTimeInfo.stageEndTimeStamp - UTL.Time.GetServerTimestamp() + value if not UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGuildBossLoot) then MDL.GuildBoss.GuildBossRewardsStatusReq() MDL.GuildBoss.OpenRankView() UIUtils.SetActive(self.event_Auction, true) end if curStateTimeInfo.stageOrder == MDL.GuildBoss.Stage.RollAfter then self:StartRepeatFunc(self.OnUpdateFun, time) end self.group_Right.gameObject:SetActive(false) end end local value = 0 for i=curStateTimeInfo.stageOrder+1,MDL.GuildBoss.Stage.RollAfter do value = value + DataSheetManager.GuildBossStage:GetDataByID_Order(1,i).StageTriggerTime end self.txt_Time:ResetAndBeginTimer(false, value + curStateTimeInfo.stageEndTimeStamp - UTL.Time.GetServerTimestamp()) self:SetEncourageInfo() end function UIGuildBossBattle:SetEncourageInfo() local info = MDL.GuildBoss.GetEncourageInfo() if info then self.enhanceInfo = info self.btn_GuildEnhance:SetGray(info.guildEncouraged,true) if info.guildEncouraged then self.txt_GuildEnhance03.text = UTL.Color.FormatTextByColor("D5DEF4", info.guildBuffTimes) else self.txt_GuildEnhance03.text = info.guildBuffTimes end self.isGuildEnhance = info.guildEncouraged local maxCount = #DataSheetManager.ConstData:GetDataByID("GuildBossEncourageCostValue").IntListValue if info.selfBuffTimes == maxCount then self.txt_PlayerEnhance03.text = UTL.Color.FormatTextByColor("D5DEF4", info.selfBuffTimes) else self.txt_PlayerEnhance03.text = info.selfBuffTimes end self.btn_PlayerEnhance:SetGray(info.selfBuffTimes == maxCount,true) self.isMaxPlayerEnhance = info.selfBuffTimes == maxCount if info.selfBuffTimes == 0 then UIUtils.SetLabelText(self.txt_PlayerEnhance04, Const_IDS.IDS_GuildBoss_NotEncouraged) else self.txt_PlayerEnhance04.text = string.FormatByIdsId(Const_IDS.IDS_GuildBoss_GuildEncourageText ,info.selfBuffTimes*10) end if info.guildEncouraged then self.txt_GuildEnhance04.text = string.FormatByIdsId(Const_IDS.IDS_GuildBoss_PlayerEncourageText ,info.guildBuffTimes) else UIUtils.SetLabelText(self.txt_GuildEnhance04, Const_IDS.IDS_GuildBoss_NotEncouraged) end end end function UIGuildBossBattle:IsReadStage(stageOrder) local stageOrder = MDL.GuildBoss.GetCurStateTimeInfo().stageOrder return stageOrder == MDL.GuildBoss.Stage.Ready end function UIGuildBossBattle:IsBattleStage() local stageOrder = MDL.GuildBoss.GetCurStateTimeInfo().stageOrder return stageOrder > MDL.GuildBoss.Stage.Ready and stageOrder <= MDL.GuildBoss.Stage.Fight3 end function UIGuildBossBattle:IsEndStage() local stageOrder = MDL.GuildBoss.GetCurStateTimeInfo().stageOrder return stageOrder > MDL.GuildBoss.Stage.Fight3 end function UIGuildBossBattle:OnButtonClicked(comp) if comp == self.btn_Shezhi then UIManager.OpenView(Const_UI_Lua.UIEnum.UISettingMainPanel) elseif comp == self.btn_GuildEnhance then if self.isGuildEnhance then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildBoss_GuildEncourageLimit) elseif self:IsEndStage() then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1350_InfoCode_GuildBoss_ActivityNotOpen) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildBossInspire,{isGuild = true,count = self.enhanceInfo.guildBuffTimes , isGuildEnhance = self.isGuildEnhance}) end elseif comp == self.btn_PlayerEnhance then if self.isMaxPlayerEnhance then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildBoss_PlayerEncourageLimit) elseif self:IsEndStage() then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1350_InfoCode_GuildBoss_ActivityNotOpen) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildBossInspire,{isGuild = false,count = self.enhanceInfo.selfBuffTimes}) end elseif comp == self.btn_Exit then UTL.MessageBox.ShowOKCancelBox(Const_IDS.IDS_ExitBarrier, Const_IDS.IDS_GuildBoss_QuitConfirm, MDL.Level.SendRoleLeaveFubenFromSetting, nil) elseif comp == self.event_Auction then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildAuctionBase) end end function UIGuildBossBattle:OnValueChanged(comp, value) if comp == self.group_Tab then if value == 1 then self:ShowRank(MDL.GuildBoss.GetPlayerList(), false) self.tab_state:SetState(1) elseif value == 0 then self:ShowRank(MDL.GuildBoss.GetRankList(),true) self.tab_state:SetState(0) end end end function UIGuildBossBattle:OnCellInit(scrollRect, index, cellTable, data) if data.index <= 3 then cellTable.section_Rank:SetState(data.index-1) else cellTable.section_Rank:SetState(3) cellTable.txt_Rank.text = data.index end if data.id == MDL.GuildBoss.GetMyGuildDmg().id or data.acid == BattleDataGetter.GetAcID() then if data.serId and data.serId > 0 then UIUtils.SetLabel(cellTable.txt_Name, UTL.Color.FormatGreenColor(data.name)..string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverSuffixText1"], data.serId)) else UIUtils.SetLabel(cellTable.txt_Name, UTL.Color.FormatGreenColor(data.name)) end else if data.serId and data.serId > 0 then UIUtils.SetLabel(cellTable.txt_Name, data.name..string.FormatByIdsId(Const_IDS["IDS_CrossSever_SeverSuffixText1"], data.serId)) else UIUtils.SetLabel(cellTable.txt_Name, data.name) end end cellTable.txt_Score.text = UTL.String.GetCountStr(data.damage) end function UIGuildBossBattle:OnRankRefresh(msg) if self.curSelectIsGuild then self:ShowRank(MDL.GuildBoss.GetRankList(),true) else self:ShowRank(MDL.GuildBoss.GetPlayerList(),false) end end function UIGuildBossBattle:ShowRank(list,isGuild) if not list or #list == 0 then self.section_Empty.gameObject:SetActive(true) self.group_Mine.gameObject:SetActive(false) self.LoopScroll_GuildBossBattleRankDamage:ClearCells() if isGuild then UIUtils.SetLabelText(self.lab_Empty, Const_IDS.IDS_GuildBoss_RankingNoGuild) else UIUtils.SetLabelText(self.lab_Empty, Const_IDS.IDS_GuildBoss_RankingNoPlayer) end else if self.curSelectIsGuild ~= isGuild then -- 切换页签清空列表重置首位 self.LoopScroll_GuildBossBattleRankDamage:ClearCells() end self.section_Empty.gameObject:SetActive(false) self.group_Mine.gameObject:SetActive(true) table.clearArray(TempRankDataTb) if isGuild then local maxCount = DataSheetManager.ConstData:GetDataByID("GuildBossGuildRankShow").IntValue self:SetSelfInfo(MDL.GuildBoss.GetMyGuildDmg(),maxCount) for i=1,maxCount do if list[i] then table.insert(TempRankDataTb, list[i]) end end else local maxCount = DataSheetManager.ConstData:GetDataByID("GuildBossPlayerRankShow").IntValue self:SetSelfInfo(MDL.GuildBoss.GetMyDmg(),maxCount) for i=1,maxCount do if list[i] then table.insert(TempRankDataTb, list[i]) end end end self.LoopScroll_GuildBossBattleRankDamage:ReloadAll(TempRankDataTb) end self.curSelectIsGuild = isGuild end function UIGuildBossBattle:SetSelfInfo(data, maxValue) if data == nil or data.damage<=0 then self.group_Mine.gameObject:SetActive(false) return end self.group_Mine.gameObject:SetActive(true) if data.index > 0 and data.index <= 3 then self.txt_Empty.text = nil self.section_Rank:SetState(data.index-1) else if data.index > maxValue then self.section_Rank.gameObject:SetActive(false) UIUtils.SetLabelText(self.txt_Empty, Const_IDS.IDS_GuildBoss_EmptyText) else self.section_Rank.gameObject:SetActive(true) self.section_Rank:SetState(3) self.txt_Rank.text = data.index self.txt_Empty.text = nil end end UIUtils.SetLabel(self.txt_Name, UTL.Color.FormatGreenColor(data.name)) self.txt_Score.text = UTL.String.GetCountStr(data.damage) end return UIGuildBossBattle