--[[ 驻地聚会活动左侧提示栏 ]] local UITownActivityGuide = UIViewClass() local EventSystem = require('Event/EventSystem') function UITownActivityGuide:OnCreated() self.todayActivityType = 0 self.isButtonGotoShow = true self.lastReqPanelInfoTime = 0 self.TotalActivityScore = 1 self.activityBoxState = 0 self.lastActivityState = -1 end function UITownActivityGuide:OnOpened(context) self:RegistSystemEvent(EventID.UI_GuildParty_LeftExpCount, self.RefreshLeftExpCount) self:RegistSystemEvent(EventID.UI_GuildParty_UpdateActivityPanel, self.RefreshActivityPanel) self:RegistSystemEvent(EventID.UI_GuildParty_RefreshActivityData, self.RefreshActivityData) self:RegistSystemEvent(EventID.UI_GuildParty_SubActivityEnd, self.OnSubActivityEnd) local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildParty) UIUtils.SetLabelText(self.lab_Title, Const_IDS[activityData.Activity]) self.lastReqPanelInfoTime = 0 self:RefreshLeftExpCount() self:InitTodayActivityType() self:StartRepeatFunc(self.OnUpdateFun, 1) self:OnUpdateFun(0, 0) end function UITownActivityGuide:RefreshLeftExpCount() local leftCount, TotalCount = MDL.GuildParty.GetActivityExpTimes() UIUtils.SetLabel(self.group_Exp.txt_Times, string.format("%s/%s", leftCount, TotalCount)) self.group_Exp.bar_Exp.value = leftCount*1.0/TotalCount if self.todayActivityType == LuaConst.ActivityType.GuildParty_Collect then self:RefreshCollectBoxCount() end end function UITownActivityGuide:InitTodayActivityType() self.todayActivityType = CTL.GuildParty.GetTodayActivityType() UIUtils.SetActive(self.group_Exam.gameObject, self.todayActivityType == LuaConst.ActivityType.GuildParty_Exam) UIUtils.SetActive(self.group_Drink.gameObject, self.todayActivityType == LuaConst.ActivityType.GuildParty_Drink) UIUtils.SetActive(self.group_Box.gameObject, self.todayActivityType == LuaConst.ActivityType.GuildParty_Collect) UIUtils.SetActive(self.group_BoxInfo, false) if self.todayActivityType == LuaConst.ActivityType.GuildParty_Exam then self:InitExamData() self:RefreshActivityPanel() elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Drink then self:InitGuildPartyDrinkData() self:RefreshActivityPanel() elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Collect then self:InitGuildPartyCollectData() end end function UITownActivityGuide:OnSubActivityEnd() if self.todayActivityType == LuaConst.ActivityType.GuildParty_Exam then self:SetExamState(false) elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Drink then self:SetDrinkState(false) elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Collect then self:SetCollectState(false) end end function UITownActivityGuide:RefreshActivityPanel() local score, boxState = MDL.GuildParty.GetActivityPanelInfo(); if self.todayActivityType == LuaConst.ActivityType.GuildParty_Exam then self.group_Exam.bar_Integral.value = score*1.0/self.TotalActivityScore self.activityBoxState = boxState if self.activityBoxState >= 1 then self.group_Exam.group_Box:SetState(self.activityBoxState-1) end if self.activityBoxState == 2 then self.group_Exam.effect_shine:PlayUIEffect() else self.group_Exam.effect_shine:StopUIEffect() end elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Drink then self.group_Drink.bar_Integral.value = score*1.0/self.TotalActivityScore self.activityBoxState = boxState if self.activityBoxState >= 1 then self.group_Drink.group_Box:SetState(self.activityBoxState-1) end if self.activityBoxState == 2 then self.group_Drink.effect_shine:PlayUIEffect() else self.group_Drink.effect_shine:StopUIEffect() end end end function UITownActivityGuide:RefreshActivityData() if self.todayActivityType == LuaConst.ActivityType.GuildParty_Exam then self:RefreshExamData() elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Drink then self:RefreshDrinkData() elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Collect then self:RefreshCollectData() end end ----------------------------------------------答题面板--------------------------------------------- function UITownActivityGuide:InitExamData() local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildParty_Exam) self.TotalActivityScore = DataSheetManager.ConstData:GetDataByID("GuildPartyAnsweringGuildRewardLimit").IntValue UIUtils.SetLabelText(self.group_Exam.lab_Name, Const_IDS[activityData.Activity]) self:RefreshExamData() if CTL.GuildParty.IsSubActivityEnd() then self:SetExamState(false) else self:SetExamState(true) end end function UITownActivityGuide:RefreshExamData() local curExamData, totalCount = CTL.GuildParty.GetCurExamData() if curExamData then UIUtils.SetLabel(self.group_Exam.txt_Tip, nil) UIUtils.SetActive(self.group_Exam.btn_Exam, true) UIUtils.SetLabel(self.group_Exam.txt_Num, string.format("(%s/%s)", curExamData.index, totalCount)) elseif CTL.GuildParty.IsSubActivityEnd(false) then UIUtils.SetLabel(self.group_Exam.txt_Tip, nil) UIUtils.SetLabel(self.group_Exam.txt_Num, string.format("(%s/%s)", totalCount, totalCount)) else UIUtils.SetLabel(self.group_Exam.txt_Num, string.format("(%s/%s)", 0, totalCount)) end end function UITownActivityGuide:OnButtonClicked(comp) if comp == self.group_Exp.btn_Goto then CTL.GuildParty.GoToGuildPartyArea() elseif comp == self.group_Exam.btn_Exam then if CTL.GuildParty.IsSubActivityEnd(true) then return end if not CTL.GuildParty.IsSubActivityOpen(true) then return end CTL.GuildParty.OpenGuildPartyExamView() elseif comp == self.btn_Info then CTL.GuildParty.OpenGuildPartyDesc() elseif comp == self.group_Exam.ButtonBox or comp == self.group_Drink.ButtonBox then if self.activityBoxState == 2 then MDL.GuildParty.ReqReceiveBox() elseif self.activityBoxState == 1 then --未达到条件 self:ShowBoxRewardInfo() CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildParty_CannotGetGuildReward"]) elseif self.activityBoxState == 3 then --已经领取过 self:ShowBoxRewardInfo() CTL.Tips.AddTipsMsg(Const_IDS["IDS_GuildParty_AlreadyGotGuildReward"]) end elseif comp == self.group_Drink.btn_Rank then if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UIGuildPartyDrinkRank) then UIManager.CloseView(Const_UI_Lua.UIEnum.UIGuildPartyDrinkRank) else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildPartyDrinkRank, nil, "Guild/UIGuildPartyDrinkRank") end else if comp == self.btn_Close then UIUtils.SetActive(self.group_BoxInfo, false) return end if comp == self.item1.event_Click then UTL.ItemTips.ShowCommonTipsById(self.boxRewards[1].ItemID) elseif comp == self.item2.event_Click then UTL.ItemTips.ShowCommonTipsById(self.boxRewards[2].ItemID) end end end function UITownActivityGuide:SetExamState(isOpening) UIUtils.SetActive(self.group_Exam.btn_Exam, isOpening and CTL.GuildParty.IsSubActivityOpen()) UIUtils.SetActive(self.group_Exam.group_End.gameObject, not isOpening) end function UITownActivityGuide:OnUpdateFun(deltaTime, timeSinceUpdate) UIUtils.SetLabel(self.lab_Time, UTL.Time.FormatTimeSeconds(CTL.GuildParty.GetGulildPartyLeftTime())) if timeSinceUpdate - self.lastReqPanelInfoTime >= 2 then self.lastReqPanelInfoTime = timeSinceUpdate if CTL.GuildParty.IsSubActivityOpen() and not CTL.GuildParty.IsSubActivityEnd() then MDL.GuildParty.ReqGetActivityPanel() end end if CTL.GuildParty.IsSelfInActivityArea() and self.isButtonGotoShow then self.isButtonGotoShow = false UIUtils.SetActive(self.group_Exp.btn_Goto, false) UIUtils.SetActive(self.group_Exp.group_Ing, true) end if not CTL.GuildParty.IsSelfInActivityArea() and not self.isButtonGotoShow then self.isButtonGotoShow = true UIUtils.SetActive(self.group_Exp.btn_Goto, true) UIUtils.SetActive(self.group_Exp.group_Ing, false) end if not CTL.GuildParty.IsSubActivityEnd() then local activityState, activityStateLeftTime = 0, 0 local txt_Tip, txt_Time, txt_Next = nil, nil, nil if self.todayActivityType == LuaConst.ActivityType.GuildParty_Exam then activityState, activityStateLeftTime = CTL.GuildParty.GetCurExamTimeData() txt_Tip, txt_Time, txt_Next = self.group_Exam.txt_Tip, nil, nil elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Drink then activityState, activityStateLeftTime = CTL.GuildParty.GetCurDrinkTimeData() txt_Tip, txt_Time, txt_Next = self.group_Drink.txt_Tip, self.group_Drink.txt_Time, self.group_Drink.txt_Next else activityState, activityStateLeftTime = CTL.GuildParty.GetCurCollectTimeData() txt_Tip, txt_Time, txt_Next = self.group_Box.txt_Tip, self.group_Box.txt_Time, self.group_Box.txt_Next end if self.lastActivityState ~= activityState then self.lastActivityState = activityState if txt_Time and txt_Next then if self.lastActivityState == 1 then UIUtils.SetActive(txt_Time, true) UIUtils.SetLabel(txt_Next, nil) elseif self.lastActivityState == 2 then UIUtils.SetActive(txt_Time, false) UIUtils.SetLabel(txt_Next, nil) else UIUtils.SetActive(txt_Time, false) UIUtils.SetLabel(txt_Next, nil) end end end if self.lastActivityState == 0 then local openLeftTime = CTL.GuildParty.GetSubActivityTimeData() if self.todayActivityType == LuaConst.ActivityType.GuildParty_Exam then UIUtils.SetLabel(txt_Tip, string.FormatByIdsKey("IDS_GuildParty_QAOpenCountDown", UTL.Time.FormatTimeSeconds(openLeftTime))) elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Drink then UIUtils.SetLabel(txt_Tip, string.FormatByIdsKey("IDS_GuildParty_ToastOpenCountDown", UTL.Time.FormatTimeSeconds(openLeftTime))) else UIUtils.SetLabel(txt_Tip, string.FormatByIdsKey("IDS_GuildParty_TreasureOpenCountDown", UTL.Time.FormatTimeSeconds(openLeftTime))) end elseif self.lastActivityState == 1 and txt_Time then UIUtils.SetLabel(txt_Time, string.FormatByIdsKey("IDS_TimeSecond", activityStateLeftTime)) elseif self.lastActivityState == 2 and txt_Next then UIUtils.SetLabel(txt_Next, string.FormatByIdsKey("IDS_GuildParty_ToastWaitingCountdown", activityStateLeftTime)) end end end ----------------------------------------------对饮--------------------------------------------- function UITownActivityGuide:InitGuildPartyDrinkData() local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildParty_Drink) self.TotalActivityScore = DataSheetManager.ConstData:GetDataByID("GuildPartyToastGuildRewardLimit").IntValue UIUtils.SetLabelText(self.group_Drink.lab_Name, Const_IDS[activityData.Activity]) if CTL.GuildParty.IsSubActivityEnd() then self:SetDrinkState(false) else self:SetDrinkState(true) end self:RefreshDrinkData() end function UITownActivityGuide:SetDrinkState(isOpening) UIUtils.SetActive(self.group_Drink.group_06, CTL.GuildParty.IsSubActivityOpen() and isOpening) UIUtils.SetActive(self.group_Drink.group_04, CTL.GuildParty.IsSubActivityOpen() and isOpening) UIUtils.SetLabel(self.group_Drink.txt_Tip, nil) UIUtils.SetActive(self.group_Drink.group_End, not isOpening) end function UITownActivityGuide:RefreshDrinkData() local curCount, totalCount, drinkPairData = CTL.GuildParty.GetCurDrinkData() if CTL.GuildParty.IsSubActivityEnd(false) then UIUtils.SetLabel(self.group_Drink.txt_Round, string.FormatByIdsKey("IDS_GuildParty_ToastRound", totalCount, totalCount)) else UIUtils.SetLabel(self.group_Drink.txt_Round, string.FormatByIdsKey("IDS_GuildParty_ToastRound", curCount, totalCount)) end if drinkPairData then UIUtils.SetActive(self.group_Drink.group_06, true) if drinkPairData.state == 1 or drinkPairData.state == 5 then UIUtils.SetActive(self.group_Drink.group_04, true) UIUtils.SetLabel(self.group_Drink.txt_Tip, nil) UIUtils.SetLabel(self.group_Drink.txt_Player, drinkPairData.aimName) UIUtils.SetActive(self.group_Drink.img_Finish, drinkPairData.state == 5) elseif drinkPairData.state == 2 then UIUtils.SetActive(self.group_Drink.group_04, false) UIUtils.SetLabelText(self.group_Drink.txt_Tip, Const_IDS["IDS_GuildParty_ToastNoTargetReminder"]) elseif drinkPairData.state == 3 then UIUtils.SetActive(self.group_Drink.group_04, false) UIUtils.SetLabelText(self.group_Drink.txt_Tip, Const_IDS["IDS_GuildParty_ToastTip2"]) elseif drinkPairData.state == 4 then UIUtils.SetActive(self.group_Drink.group_04, false) UIUtils.SetLabelText(self.group_Drink.txt_Tip, Const_IDS["IDS_GuildParty_ToastTip1"]) end else UIUtils.SetLabel(self.group_Drink.txt_Player, nil) UIUtils.SetActive(self.group_Drink.img_Finish, false) end end ----------------------------------------------宝箱--------------------------------------------- function UITownActivityGuide:InitGuildPartyCollectData() local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildParty_Collect) UIUtils.SetLabelText(self.group_Box.lab_Name, Const_IDS[activityData.Activity]) self:RefreshCollectBoxCount() if CTL.GuildParty.IsSubActivityEnd() then self:SetCollectState(false) else self:SetCollectState(true) end self:RefreshCollectData() end function UITownActivityGuide:SetCollectState(isOpening) UIUtils.SetActive(self.group_Box.group_06, CTL.GuildParty.IsSubActivityOpen() and isOpening) UIUtils.SetLabel(self.group_Box.txt_Tip, nil) UIUtils.SetActive(self.group_Box.group_End, not isOpening) end function UITownActivityGuide:RefreshCollectBoxCount() local hasBoxCount, maxCount = CTL.GuildParty.GetCollectCountData() UIUtils.SetLabel(self.group_Box.txt_Num, string.FormatByIdsKey("IDS_GuildParty_TreasureLootNum", hasBoxCount, maxCount)) end function UITownActivityGuide:RefreshCollectData() local curCount, totalCount = CTL.GuildParty.GetCurCollectData() if CTL.GuildParty.IsSubActivityEnd(false) then UIUtils.SetLabel(self.group_Box.txt_Round, string.FormatByIdsKey("IDS_GuildParty_ToastRound", totalCount, totalCount)) else UIUtils.SetActive(self.group_Box.group_06, curCount>=1) UIUtils.SetLabel(self.group_Box.txt_Round, string.FormatByIdsKey("IDS_GuildParty_ToastRound", curCount, totalCount)) end UIUtils.SetLabel(self.group_Box.txt_Tip, nil) end function UITownActivityGuide:ShowBoxRewardInfo() UIUtils.SetActive(self.group_BoxInfo, true) local score = MDL.GuildParty.GetActivityPanelInfo(); if self.todayActivityType == LuaConst.ActivityType.GuildParty_Exam then self.boxRewards = DataSheetManager.GuildPartakeReward:GetDataByID(1).Item_Table UIUtils.SetLabel(self.txt_BoxInfo, string.FormatByIdsId(Const_IDS["IDS_GuildParty_BoxTip1"], score ,self.TotalActivityScore)) elseif self.todayActivityType == LuaConst.ActivityType.GuildParty_Drink then self.boxRewards = DataSheetManager.GuildPartakeReward:GetDataByID(2).Item_Table UIUtils.SetLabel(self.txt_BoxInfo, string.FormatByIdsId(Const_IDS["IDS_GuildParty_BoxTip1"], score ,self.TotalActivityScore)) end UTL.Item.SetItemCell(self.item1, self.boxRewards[1].ItemID, self.boxRewards[1].ItemNum) UTL.Item.SetItemCell(self.item2, self.boxRewards[2].ItemID, self.boxRewards[2].ItemNum) end return UITownActivityGuide