--[[ 军团驻地活动入口 ]] local UIGuildActivityDrinkEntry = UIViewClass() function UIGuildActivityDrinkEntry:OnCreated() self.GuildPartyRewardItemIds = nil; self.SubGuildPartyRewardItemIds = nil; end function UIGuildActivityDrinkEntry:OnOpened(context) self:SetGuildPartyTotalInfo(); self:SetSubActivityTotalInfo(); end function UIGuildActivityDrinkEntry:SetGuildPartyTotalInfo() local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildParty); -- 设置标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[activityData.Activity]); UIUtils.SetLabelText(self.group_Stage1.lab_Title, Const_IDS["IDS_GuildParty_PhaseParty"]); UIUtils.SetLabel(self.group_Stage1.lab_Time, UTL.Time.GetBeginAndEndTime(activityData.Time_Table)); UIUtils.SetLabelText(self.group_Stage1.lab_RewardTitle, Const_IDS["IDS_GuildParty_PartyReward"]); local leftCount, TotalCount = MDL.GuildParty.GetActivityExpTimes(); UIUtils.SetLabel(self.group_Stage1.txt_RewardCount, string.FormatByIdsKey("IDS_GuildParty_PartyRewardNumIntro", leftCount, TotalCount)); local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(activityData.RewardShow) local rewardDatas = DataSheetUtil.GetRewardClientShowItemTable(cfg) self.GuildPartyRewardItemIds = {} for i, rewardData in ipairs(rewardDatas) do local contentItem = self.group_Stage1.group_Reward[i] if not contentItem then contentItem = self:InstantiateCollection(self.group_Stage1.group_Reward, self.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(contentItem, rewardData.ItemID, rewardData.ItemNum) UIUtils.SetActive(contentItem.gameObject, true) self.GuildPartyRewardItemIds[i] = rewardData.ItemID end for i = #rewardDatas + 1, #self.group_Stage1.group_Reward do UIUtils.SetActive(self.group_Stage1.group_Reward[i].gameObject, false) end UIUtils.SetLabelText(self.group_Stage1.lab_Desc, Const_IDS[activityData.ActivityDes]); end function UIGuildActivityDrinkEntry:GetTodayActivityId() local curWeekDay = UTL.Time.GetServerWeekday(); local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildParty); for __, subActivityId in ipairs(activityData.childID) do local subActivityData = DataSheetManager.ActivityData:GetDataByID(subActivityId); for __, timeData in ipairs(subActivityData.Time_Table) do local refreshTimeData = DataSheetManager.TimeRefresh:GetDataByID(timeData.StartTime); if refreshTimeData.Timer == UTL.Time.TimeType.DAILY or (refreshTimeData.Timer == UTL.Time.TimeType.WEEKLY and refreshTimeData.Day == curWeekDay) then return subActivityId; end end end end function UIGuildActivityDrinkEntry:SetSubActivityTotalInfo() local todayActivityId = self:GetTodayActivityId(); local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildParty); for index, subActivityId in ipairs(activityData.childID) do local subActivityData = DataSheetManager.ActivityData:GetDataByID(subActivityId); self.group_Stage2.group_Tab:SetToggleIDS(index, "txtName", Const_IDS[subActivityData.Activity]) self.group_Stage2.group_Tab:SetToggleCompActive(index, "img_Today", todayActivityId == subActivityId) local timeDesc = UTL.Time.GetDateDescAndTime(subActivityData.Time_Table) self.group_Stage2.group_Tab:SetToggleText(index, "lab_Date", timeDesc) if todayActivityId == subActivityId then self.group_Stage2.group_Tab:SelectIndex(index-1); local startTimeStr = UTL.Time.GetDiffLocalStrById(subActivityData.Time_Table[1].StartTime) UIUtils.SetLabel(self.group_Stage2.lab_Time, string.FormatByIdsKey("IDS_AutoOpenTime", startTimeStr)); end end end function UIGuildActivityDrinkEntry:OnValueChanged(comp, value) if comp == self.group_Stage2.group_Tab then local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildParty); local subActivityData = DataSheetManager.ActivityData:GetDataByID(activityData.childID[value+1]); self:SetSubActivityDetailInfo(subActivityData); end end function UIGuildActivityDrinkEntry:SetSubActivityDetailInfo(subActivityData) UIUtils.SetLabelText(self.group_Stage2.lab_Title, Const_IDS["IDS_GuildParty_PhasePlay"]); UIUtils.SetLabelText(self.group_Stage2.lab_RewardTitle, Const_IDS["IDS_GuildParty_PlayReward"]); local cfg = DataSheetManager.RewardClientShow:GetDataByClientShowID(subActivityData.RewardShow) local rewardDatas = DataSheetUtil.GetRewardClientShowItemTable(cfg) self.SubGuildPartyRewardItemIds = {} for i, rewardData in ipairs(rewardDatas) do local contentItem = self.group_Stage2.group_Reward[i] if not contentItem then contentItem = self:InstantiateCollection(self.group_Stage2.group_Reward, self.itemTemplate_Reward.gameObject) end UTL.Item.SetItemCell(contentItem, rewardData.ItemID, rewardData.ItemNum) UIUtils.SetActive(contentItem.gameObject, true) self.SubGuildPartyRewardItemIds[i] = rewardData.ItemID end for i = #rewardDatas + 1, #self.group_Stage2.group_Reward do UIUtils.SetActive(self.group_Stage2.group_Reward[i].gameObject, false) end UIUtils.SetLabelText(self.group_Stage2.lab_Desc, Const_IDS[subActivityData.ActivityDes]); end function UIGuildActivityDrinkEntry:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildActivityDrinkEntry: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.UITemplateTitlePanel.btn_Info then CTL.GuildParty.OpenGuildPartyDesc() elseif comp == self.group_Stage1.btn_Info then local maxCount = DataSheetManager.ConstData:GetDataByID("GuildPartyHookRewardMaxNum").IntValue; local tipStr = string.FormatByIdsKey("IDS_GuildParty_PartyRewardTips", maxCount); UIManager.OpenView(Const_UI_Lua.UIEnum.UIDescriptionPanel,{target = self.group_Stage1.btn_Info, posType = LuaConst.DescriptionPanelType.Center, text = tipStr}); elseif comp == self.btn_Join then if CTL.GuildParty.CanGotoGuildPartyScene(true) then if CTL.GuildParty.GoToGuildPartyArea() then UIManager.RecoverTopView(); CTL.HomeMain.CloseOpenView(); end end else for index, itemCell in ipairs(self.group_Stage1.group_Reward) do if comp == itemCell.event_Click then UTL.ItemTips.ShowCommonTipsById(self.GuildPartyRewardItemIds[index], false, false); end end for index, itemCell in ipairs(self.group_Stage2.group_Reward) do if comp == itemCell.event_Click then UTL.ItemTips.ShowCommonTipsById(self.SubGuildPartyRewardItemIds[index], false, false); end end end end return UIGuildActivityDrinkEntry