local UIGuildBossMain = UIViewClass() local Common2DScenePrefab = ConstAssetPathConfig.Common2DScenePrefab local CLIENT_SHOW_ID = DataSheetManager.ConstData:GetDataByID("GuildBossRewardClientShow").IntValue function UIGuildBossMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_GuildBoss_MainRankRefresh,self.OnRankRefresh) self:RegistSystemEvent(EventID.UI_GuildBoss_TimeRefresh,self.SetBtnState) self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.BossShowScene) self:SetBossModel() self:ShowReward() self:SetBtnState() self:RefreshRedPoint() MDL.GuildBoss.GetGuildBossRankReq() self.tab_state:SetState(0) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_GuildBoss_FunctionName) UIManager.ActiveUIModle(false, "UIGuildBossMain") self:RegistSystemEvent(EventID.UI_CloseAndRecoverView, self.OnCloseAndRecoverView) end function UIGuildBossMain:RefreshRedPoint() if MDL.Activities.GetRedPointByID(LuaConst.ActivityType.GuildBoss) then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.GuildBoss, 1, true, LuaConst.ActivityType.GuildBoss) end end function UIGuildBossMain:OnClosed() UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) UIManager.ActiveUIModle(true, "UIGuildBossMain") end function UIGuildBossMain:OnRankRefresh(msg) self.rankList = msg self:ShowRank(self.rankList.guildRank,true) end function UIGuildBossMain:ShowRank(list,isGuild) if not list or #list == 0 then self.section_Empty.gameObject:SetActive(true) self.LoopScroll_Damage: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 self.group_Mine.gameObject:SetActive(false) else self.section_Empty.gameObject:SetActive(false) self.LoopScroll_Damage:ClearCells() self.group_Mine.gameObject:SetActive(true) if isGuild then local maxCount = DataSheetManager.ConstData:GetDataByID("GuildBossGuildRankShow").IntValue self:SetSelfInfo(self.rankList.myGuildDmg,maxCount,true) for i=1,maxCount do if list[i] then self.LoopScroll_Damage:AddData(list[i],0) end end else local maxCount = DataSheetManager.ConstData:GetDataByID("GuildBossPlayerRankShow").IntValue self:SetSelfInfo(self.rankList.myDmg,maxCount,false) for i=1,maxCount do if list[i] then self.LoopScroll_Damage:AddData(list[i],0) end end end end end function UIGuildBossMain:SetSelfInfo(data, maxValue,isGuild) if IsServerDataNotNil(data) == false 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.section_Rank:SetState(data.index-1) else if data.index > maxValue or data.index == 0 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 end end UIUtils.SetLabel(self.txt_Name, UTL.Color.FormatGreenColor(data.name)) if data.index ~= 0 then UIUtils.SetLabel(self.txt_Score, UTL.String.GetCountStr(data.damage)) else self.txt_Score.text = nil end end function UIGuildBossMain:ClearSelfInfo(data) self.section_Rank:SetState(3) self.txt_Name.text = nil self.txt_Score.text = nil self.txt_Rank.text = nil end function UIGuildBossMain:SetBossModel(bossId) local bossData = DataSheetManager.GuildBoss:GetDataByID(MDL.GuildBoss.ConstBossId) local bgTexturePath = ConstAssetPathConfig.bgTexturePath2 UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, Common2DScenePrefab, 1600, 0, 1600, bgTexturePath, true) UTL.UIRender.CreateNonPlayerModel(self.modelComponentDataHandle, bossData.BossShow, bossData.ModelScale, bossData.ShowEquipmentID, bossData.ModelLight, bossData.ModelOffset) UIUtils.SetLabelText(self.txt_BossName, Const_IDS[bossData.BossName]) local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildBoss) local date,time, extra = CTL.Activities.GetDetailsTimeDesc(activityData, true) self.lab_Time.text = date .. "\n" .. time end function UIGuildBossMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildBossMain: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_RewardPreview then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildBossReward) elseif comp == self.UITemplateTitlePanel.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.GuildBoss}) elseif comp == self.btn_Challenge then if MDL.Guild.IsHasGuild() then self:ClickEnterGuildBoss() else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild) end elseif comp == self.btn_Shop then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain, {TabEnum = CTL.PayMall.ShopMainTabEnum.ShiLi}) elseif comp == self.btn_Instruction then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildBossStrategy, nil, Const_UI_Lua.UIEnum.UIMultiplayerDungeonStrategy) else self:ClickReward(comp) end end function UIGuildBossMain:ClickEnterGuildBoss() if MDL.Guild.IsHasGuild() then if self.isStart then if CTL.TeamMatch.IsInMatching() then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_TeamDungeon1_Matching) else MDL.GuildBoss.EnterGuildBossReq() end elseif self.isEnd then CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_GuildBoss_ActivityEnd) else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1350_InfoCode_GuildBoss_ActivityNotOpen) end else CTL.Sound.PlayGameSound("UI_invalid") CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild) end end function UIGuildBossMain:OnValueChanged(comp, value) if comp == self.group_Tab then if value == 1 then self:ClearSelfInfo() if self.rankList then self:ShowRank(self.rankList.playerRank) end self.tab_state:SetState(1) elseif value == 0 then self:ClearSelfInfo() if self.rankList then self:ShowRank(self.rankList.guildRank,true) end self.tab_state:SetState(0) end end end function UIGuildBossMain:OnCellInit(scrollRect, index, cellTable, data) UIUtils.SetActive(cellTable.img_BG2, index % 2 == 1) -- index从0开始,偶数行显示底框 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.Guild.GetMyGuildInfo().guildId 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 UIUtils.SetLabel(cellTable.txt_Score, UTL.String.GetCountStr(data.damage)) end function UIGuildBossMain:ShowReward() self.rewards = {} local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(CLIENT_SHOW_ID) local itemTable = DataSheetUtil.GetRewardClientShowItemTable(cfg) for i, v in ipairs(itemTable) do self.rewards[i] = v.ItemID UTL.Item.SetItemCell(self.section_Reward[i].item, v.ItemID) end end function UIGuildBossMain:ClickReward(comp) for i,v in ipairs(self.section_Reward) do if v.item.event_Click == comp then UTL.ItemTips.ShowCommonTipsById(self.rewards[i]) end end end function UIGuildBossMain:SetBtnState() local state = CTL.Activities.GetState(LuaConst.ActivityType.GuildBoss) if state == CTL.Activities.ActivityState.Opening then self.isStart = true UIUtils.SetLabelText(self.txt_Challenge, Const_IDS.IDS_GuildBoss_Challenge) self.btn_Challenge:SetGray(false) elseif state == CTL.Activities.ActivityState.End then self.isEnd = true UIUtils.SetLabelText(self.txt_Challenge, Const_IDS.IDS_GuildBoss_AlreadyClosed) self.btn_Challenge:SetGray(true,true) self.isStart = false else self.isStart = false self.isEnd = false UIUtils.SetLabelText(self.txt_Challenge, Const_IDS.IDS_GuildBoss_NotOpen) self.btn_Challenge:SetGray(true,true) end end return UIGuildBossMain