local UIGuildActivityEscort = UIViewClass() -- [[ -- 势力押镖-活动说明主界面 -- ]] local ActivityEscortType = { Escort = 0, CutEscort = 1, } local GuildEscortFuncInfoID = 1735 -------------------- function UIGuildActivityEscort:OnCreated() self.perfectEscortData = DataSheetManager.GuildEscortData:GetDataByID(MDL.GuildEscort.PerfectEscort) local escortRewardID = DataSheetManager.ConstData:GetDataByID("EscortRewardShow1").IntValue local escortRewardCfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(escortRewardID) self.escortReward = DataSheetUtil.GetRewardClientShowItemTable(escortRewardCfg) escortRewardID = DataSheetManager.ConstData:GetDataByID("EscortRewardShow2").IntValue local cutEscortRewardCfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(escortRewardID) self.cutEscortReward = DataSheetUtil.GetRewardClientShowItemTable(cutEscortRewardCfg) end function UIGuildActivityEscort:OnOpened(context) self:RegistSystemEvent(EventID.GuildEscort_RefreshActivityCount, self.RefreshActivityCount) self.curToggleType = 0 self.rewardData = {} self:InitPanel() self:RefreshActivityCount() self:OnValueChanged(self.group_Stage2.group_Tab, 0) self:RefreshEntryRedPoint() UTL.UIRender.AdaptiveImageSizeFit(self.img_Scene, true) end function UIGuildActivityEscort:RefreshEntryRedPoint() if MDL.Activities.GetRedPointByID(LuaConst.ActivityType.GuildEscort) then MDL.RedPoint.OneTimeRedPointRequest(MDL.RedPoint.RedPointType.GuildEscort, 1, true, LuaConst.ActivityType.GuildEscort) end end function UIGuildActivityEscort:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildActivityEscort:OnButtonClicked(comp) if self.btn_Join == comp then CTL.GuildEscort.GotoGuildEscortScene(self.curToggleType == ActivityEscortType.Escort) elseif self.UITemplateTitlePanel.btn_close == comp then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif self.UITemplateTitlePanel.btn_Info == comp then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = GuildEscortFuncInfoID}) elseif self.btn_Rank == comp then CTL.Rank.OpenRankPanelByType(MDL.Rank.RankType.GuildEscort) elseif self.group_Stage2.btn_Info == comp then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildEscortRewardPreview) elseif self.btn_Report == comp then local isOpen = CTL.Activities.IsOpeningTime(LuaConst.ActivityType.GuildEscort) if isOpen then CTL.Tips.AddTipsMsg(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Escort_EndData)) else UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIGuildEscortReport) end else for i = 1, #self.rewardData do if self.group_Stage2.Content[i].event_Click == comp then UTL.ItemTips.ShowCommonTipsById(self.rewardData[i].ItemID) end end end end function UIGuildActivityEscort:OnValueChanged(comp, index) if comp == self.group_Stage2.group_Tab then self.curToggleType = index if self.curToggleType == ActivityEscortType.Escort then UIUtils.SetLabel(self.group_Stage2.lab_Desc, string.FormatByIdsId(Const_IDS.IDS_Escort_AwardUp, CTL.GuildEscort.EscortTeamAwardUp)) self:SetEscortReward(true) else UIUtils.SetLabel(self.group_Stage2.lab_Desc, UIUtils.GetLocalizedTxt(Const_IDS.IDS_Escort_RobAwardUp)) self:SetEscortReward(false) end end end -------------------- function UIGuildActivityEscort:InitPanel() -- 设置标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Escort_FunctionName) -- 设置每日开启时间 local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildEscort) local _, time = CTL.Activities.GetDetailsTimeDesc(activityData, true) UIUtils.SetLabel(self.group_Stage1.lab_Time1, string.FormatByIdsId(Const_IDS.IDS_Escort_StartTime2, time)) end -- 刷新活动剩余次数 function UIGuildActivityEscort:RefreshActivityCount() -- 设置(运镖、劫镖)剩余次数 local residueNum, limitNum = MDL.GuildEscort.GetEscortNumLimit() if residueNum <= 0 then self.group_Stage2.group_Tab:SetToggleText(1, "txtTimes", string.FormatByIdsId(Const_IDS.IDS_Escort_AwardNum, UTL.Color.FormatRedColor(residueNum), limitNum)) else self.group_Stage2.group_Tab:SetToggleText(1, "txtTimes", string.FormatByIdsId(Const_IDS.IDS_Escort_AwardNum, UTL.Color.FormatGreenColor(residueNum), limitNum)) end residueNum, limitNum = MDL.GuildEscort.GetCutEscortNumLimit() if residueNum <= 0 then self.group_Stage2.group_Tab:SetToggleText(2, "txtTimes", string.FormatByIdsId(Const_IDS.IDS_Escort_AwardNum, UTL.Color.FormatRedColor(residueNum), limitNum)) else self.group_Stage2.group_Tab:SetToggleText(2, "txtTimes", string.FormatByIdsId(Const_IDS.IDS_Escort_AwardNum, UTL.Color.FormatGreenColor(residueNum), limitNum)) end end -- 设置奖励数据 function UIGuildActivityEscort:SetEscortReward(isEscort) -- 设置奖励 local rewardList if isEscort then rewardList = self.escortReward else rewardList = self.cutEscortReward end for i, v in ipairs(rewardList) do self.rewardData[i] = v end for i = #self.rewardData, #rewardList + 1, -1 do table.remove(self.rewardData) end self:SetReward() end -- 通用设置奖励 function UIGuildActivityEscort:SetReward() for i, reward in ipairs(self.rewardData) do local item = self.group_Stage2.Content[i] if not item then item = self:InstantiateCollection(self.group_Stage2.Content, self.group_Stage2.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(item, reward.ItemID, reward.ItemNum) UIUtils.SetActive(item.gameObject, true) end for i = #self.rewardData + 1, #self.group_Stage2.Content do UIUtils.SetActive(self.group_Stage2.Content[i].gameObject, false) end end return UIGuildActivityEscort