local UIGuildMineMain = UIViewClass() local GuildMineMainRefreshCDTime = DataSheetManager.ConstData:GetDataByID("MineRefresh").IntValue -- 主界面刷新CD local EventSystem = require('Event/EventSystem') function UIGuildMineMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_GuildMine_CloseView, self.OnBackButtonPressed) -- GMS self:RegistSystemEvent(EventID.UI_Guild_BeKickOutRefresh, self.GuildBeKickOut) -- 被踢出势力 self:RegistSystemEvent(EventID.UI_GuildMine_MyMine_Create, self.RefreshMyMineInfo) -- 创建开始挖矿 self:RegistSystemEvent(EventID.UI_GuildMine_Refresh_OtherMineList, self.RefreshMinInfoList) -- 刷新矿区 self:RegistSystemEvent(EventID.UI_GuildMine_Refresh_LootNum, self.UpdateGuildMineRewardTimes) -- 掠夺次数 self:RegistSystemEvent(EventID.UI_GuildMine_Refresh_HelpBtnRedPoint, self.RefreshHelpBtnRedPoint) -- 刷新援助按钮红点 self:RegistSystemEvent(EventID.UI_GuildMine_Refresh_DailyBtnRedPoint, self.RefreshDailyBtnRedPoint) -- 刷新日志按钮红点 self:RegistSystemEvent(EventID.UI_GuildMine_MineFinish, self.OpenGuildMineReward) -- 刷新日志按钮红点 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Mine_Title) UIUtils.SetActive(self.UITemplateTitlePanel.btn_Info.gameObject, true) self:InitMineMainPanel() self:StartRepeatFunc(self.RepeatFuncContinue, 5 * UTL.Time.TotalSecondsOneMinute) self:OpenGuildMineReward() end function UIGuildMineMain:RepeatFuncContinue(deltaTime, timeSinceUpdate) MDL.GuildMine.GetMineInterfaceInfoRequest(MDL.GuildMine.InterfaceType.Continue) end function UIGuildMineMain:OnClosed() MDL.GuildMine.GetMineInterfaceInfoRequest(MDL.GuildMine.InterfaceType.Close) EventSystem.Dispatch(EventID.UI_Activity_Refresh_ListOrder) end function UIGuildMineMain:GuildBeKickOut() CTL.Tips.AddTipsMsg(Const_IDS.IDS_Mine_UnableMine) --你已无势力,无法采矿 self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildMineMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGuildMineMain: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 local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildMine).Time_Table[1] local _, timeStr = UTL.Time.GetDateDescAndTimeById(activityData.StartTime, activityData.EndTime) local countryDayLimit = DataSheetManager.ConstData:GetDataByID("CountryDayLimit").IntValue UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.GuildMine, params = {timeStr, UTL.Time.GetDiffLocalStrById(1), countryDayLimit}}) else if CTL.Activities.IsActivityInOpeningTime(LuaConst.ActivityType.GuildMine) then if comp == self.btn_Help then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildMineHelpPopUp) elseif comp == self.btn_DailyRecord then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildMineDailyRecord) elseif comp == self.btn_Array then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildMineSelectOfficer, { freeLineupFuncType = MDL.FreeLineUp.FuncType.GuildMine, activityType = LuaConst.ActivityType.GuildMine }, Const_UI_Lua.UIEnum.UIDemonGodSelectOfficer) elseif comp == self.btn_MyMine then local myMine = MDL.GuildMine.GetMyMineInfo().mineBaseShowInfo if myMine and myMine.mineLevel > 0 then return end if CTL.GuildMine.IsFormationFinished(self.curKingdom) then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildMineMyMine) else CTL.GuildMine.OpenSelectOfficerMessageBox() end elseif comp == self.btn_Add then CTL.GuildMine.OpenTimeUpView() elseif comp == self.btn_Refresh then if self.RefreshTime == 0 then MDL.GuildMine.GetMineInterfaceInfoRequest(MDL.GuildMine.InterfaceType.Refresh) MDL.GuildMine.SetLastRefreshTime(UTL.Time.GetServerTimestamp()) self:SetRefreshCDTimerButtonState() end else for k,mine_Cell in ipairs(self.Mine_template) do if comp == mine_Cell.btn_Mine then local otherMine = MDL.GuildMine.GetOtherMineList()[k] if otherMine then local mineInfo = otherMine.mineInfo if mineInfo then local mineData = DataSheetManager.MineQuality:GetDataByID(mineInfo.mineBaseShowInfo.mineLevel) if mineInfo.mineBaseShowInfo.mineBeginTime + mineData.CollectTime * UTL.Time.TotalSecondsOneMinute - UTL.Time.GetServerTimestamp() > 0 then if mineInfo.minePlayerShowInfo.playerAcid == BattleDataGetter.GetAcID() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Mine_UnablePlunder1) -- 无法掠夺自己的矿场 else if mineInfo.mineGuildShowInfo.guildId == MDL.Guild.GetMyGuildId() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Mine_UnablePlunder2) -- 无法掠夺同势力玩家的矿场 else if mineInfo.mineGuildShowInfo.countryId == MDL.Country.GetMyCountryId() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Mine_UnablePlunder3) -- 无法掠夺同国家玩家的矿场 else UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildMinePlunderPopUp, {mineInfo = mineInfo, mineData = mineData}) end end end else MDL.GuildMine.GetMineInterfaceInfoRequest(MDL.GuildMine.InterfaceType.Open) CTL.Tips.AddTipsMsg(Const_IDS.IDS_Mine_Completed) -- 该矿场已收获完毕 end end end end end end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_RebelStrike_NotAtActivityTime) -- 不在活动时段内 end end end function UIGuildMineMain:InitMineMainPanel() self.curKingdom = MDL.GuildMine.GetMineCurKingdomId() self:SetRefreshCDTimerButtonState() self:UpdateGuildMineRewardTimes() self:SetKingdomAndTime() self:RefreshMinInfoList() self:RefreshDailyBtnRedPoint(MDL.GuildMine.GetMineLootRedPoint()) self:RefreshHelpBtnRedPoint(MDL.GuildMine.GetMineAssRedPoint()) end function UIGuildMineMain:RefreshMinInfoList() self:RefreshMyMineInfo() self:RefreshOtherMineList() end function UIGuildMineMain:SetRefreshCDTimerButtonState() self.RefreshTime = MDL.GuildMine.GetLastRefreshTime() + GuildMineMainRefreshCDTime - UTL.Time.GetServerTimestamp() self.state_RefreshTime:SetState(self.RefreshTime > 0 and 1 or 0) if self.RefreshTime > 0 then self.btn_Refresh:SetGray(true) self.txt_RefreshLock:ResetAndBeginTimer(false, self.RefreshTime, 0) self:StartRepeatFunc(self.RepeatFuncRefreshTimeState, self.RefreshTime, 1) else self.btn_Refresh:SetGray(false, true) self.RefreshTime = 0 end end function UIGuildMineMain:RepeatFuncRefreshTimeState(deltaTime, timeSinceUpdate) self.RefreshTime = 0 self.btn_Refresh:SetGray(false, true) self.state_RefreshTime:SetState(0) MDL.GuildMine.SetLastRefreshTime(0) self:StopRepeatFunc(self.RepeatFuncRefreshTimeState) end function UIGuildMineMain:UpdateGuildMineRewardTimes() local hasCount = MDL.GuildMine.MineDailyFreePlunderNum + MDL.GuildMine.GetMinePurchaseNum() - MDL.GuildMine.GetMineLootNum() UIUtils.SetLabel(self.txt_PlundersTimes, string.FormatByIdsId(Const_IDS.IDS_Mine_PlundersTimes, string.format("%s/%s", hasCount > 0 and UTL.Color.FormatGreenColor(hasCount) or UTL.Color.FormatRedColor(hasCount), MDL.GuildMine.MineDailyFreePlunderNum))) end function UIGuildMineMain:SetKingdomAndTime() if self.curKingdom > 0 and self.curKingdom <= 4 then -- 国家 UIUtils.SetLabel(self.txt_Limit, string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_10, CTL.Country.GetCountryNameWithColorAndColon(self.curKingdom))) CTL.HeroSelect.SetCountry(self.curKingdom, self.group_Flag) self.state_CountryBG:SetState(self.curKingdom - 1) else self.state_CountryBG:SetState(4) end local activityData = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.GuildMine).Time_Table[1] local openTypeDesc, openTimeConfig = UTL.Time.GetDateDescAndTimeById(activityData.StartTime, activityData.EndTime) UIUtils.SetLabel(self.txt_ActivityTime, string.FormatByIdsId(Const_IDS.IDS_NationClimbTower_OpenTime_2, openTypeDesc, openTimeConfig)) end -- 可抢夺区域 function UIGuildMineMain:RefreshOtherMineList() self.OtherMineList = MDL.GuildMine.GetOtherMineList() for k,mine_Cell in ipairs(self.Mine_template) do local mineInfo = self.OtherMineList[k] mine_Cell.state_Empty:SetState(mineInfo and 1 or 0) if mineInfo then self:SetMinePlayerInfo(mineInfo, mine_Cell) end end end -- 自己矿区 function UIGuildMineMain:RefreshMyMineInfo() local hasCount = MDL.GuildMine.MineDailyCollectNum - MDL.GuildMine.GetMineCollectNum() UIUtils.SetLabel(self.txt_MiningTimes, string.FormatByIdsId(Const_IDS.IDS_Mine_MiningTimes, string.format("%s/%s", hasCount > 0 and UTL.Color.FormatGreenColor(hasCount) or UTL.Color.FormatRedColor(hasCount), MDL.GuildMine.MineDailyCollectNum))) local myMine = MDL.GuildMine.GetMyMineInfo().mineBaseShowInfo self.state_MyMine:SetState((myMine and myMine.mineLevel > 0) and 1 or 0) if myMine and myMine.mineLevel > 0 then local mineData = DataSheetManager.MineQuality:GetDataByID(myMine.mineLevel) UIUtils.SetImageByAssetBundle(self.img_Mine, mineData.MineIcon) self.effect_MyMine:PlayUIEffect() self.state_MineTimePos:SetState(myMine.mineLevel - 1) local MyMineTimer = (myMine.mineBeginTime + mineData.CollectTime * UTL.Time.TotalSecondsOneMinute) - UTL.Time.GetServerTimestamp() UIUtils.SetActive(self.group_MyTime, MyMineTimer > 0) if MyMineTimer > 0 then self.txt_MyTime:ResetAndBeginTimer(false, MyMineTimer, 0) self:StartRepeatFunc(self.RepeatFuncMyMineTimer, MyMineTimer, 1) end else self.effect_MyMine:StopUIEffect() end end function UIGuildMineMain:RepeatFuncMyMineTimer(deltaTime, timeSinceUpdate) UIUtils.SetActive(self.group_MyTime, false) self.effect_MyMine:PlayUIEffect() MDL.GuildMine.GetMineInterfaceInfoRequest(MDL.GuildMine.InterfaceType.Open) self:StopRepeatFunc(self.RepeatFuncMyMineTimer) end function UIGuildMineMain:SetMinePlayerInfo(data, playerComp) local playerInfo = data.mineInfo.minePlayerShowInfo local guildInfo = data.mineInfo.mineGuildShowInfo local baseShowInfo = data.mineInfo.mineBaseShowInfo local lineupInfo = data.mineInfo.mineLineUpShowInfo local mineData = DataSheetManager.MineQuality:GetDataByID(baseShowInfo.mineLevel) UIUtils.SetImageByAssetBundle(playerComp.img_Mine, mineData.MineIcon) playerComp.state_InfoBG:SetState(guildInfo.countryId > 0 and 0 or 1) if guildInfo.countryId > 0 then local countryData = DataSheetManager.CountryBase:GetDataByID(guildInfo.countryId) if playerComp.Loc_Country.CurState == 0 then playerComp.group_CountryState:SetState(guildInfo.countryId - 1) else UIUtils.SetLabelText(playerComp.lab_CountryTC, Const_IDS[countryData.CountryTC]) end end if baseShowInfo.mineLevel == DataSheetManager.MineQuality:GetDataCount() then playerComp.effect_GoldMine:PlayUIEffect() else playerComp.effect_GoldMine:StopUIEffect() end if baseShowInfo.isInBattle then playerComp.effect_Fight:PlayUIEffect() else playerComp.effect_Fight:StopUIEffect() end if baseShowInfo.playerIsEnemy then playerComp.effect_Enemy:PlayUIEffect() else playerComp.effect_Enemy:StopUIEffect() end UIUtils.SetActive(playerComp.group_None, baseShowInfo.beLootTimes >= mineData.PlunderTimes) playerComp.state_NonePos:SetState(baseShowInfo.mineLevel - 1) local isCanPlunder = MDL.GuildMine.MineDailyFreePlunderNum + MDL.GuildMine.GetMinePurchaseNum() - MDL.GuildMine.GetMineLootNum() > 0 UIUtils.SetActive(playerComp.arrow, baseShowInfo.beLootTimes < mineData.PlunderTimes and not baseShowInfo.isInBattle and isCanPlunder) -- 名字 UIUtils.SetLabel(playerComp.txt_PlayerName, playerInfo.playerName) -- 设置区服 UIUtils.SetLabel(playerComp.txt_Server, CTL.CrossServer.GetServerShowStr(playerInfo.playerServerId)) --战力 UIUtils.SetLabel(playerComp.txt_CENum, lineupInfo.playerLineUpGs) -- 设置军团标记 if string.isNilOrEmpty(guildInfo.guildEmblemContent) then UIUtils.SetActive(playerComp.group_PlayerGuild.gameObject, false) else UIUtils.SetActive(playerComp.group_PlayerGuild.gameObject, true) UIUtils.SetLabel(playerComp.txt_Guild, guildInfo.guildEmblemContent) UIUtils.SetLabel(playerComp.txt_GuildName, guildInfo.guildName) local guildEmblemCfg = DataSheetManager.GuildEmblem:GetDataByID(guildInfo.guildEmblemFrame) UTL.Item.SetAtlasSprite(playerComp.img_GuildIcon, "UI_Guild", guildEmblemCfg.Image) end end function UIGuildMineMain:RefreshHelpBtnRedPoint(isRed) self.btn_Help:SetRedPoint(isRed) end function UIGuildMineMain:RefreshDailyBtnRedPoint(isRed) self.btn_DailyRecord:SetRedPoint(isRed) end function UIGuildMineMain:OpenGuildMineReward() local balancMineInfo = MDL.GuildMine.GetBalanceMine() if balancMineInfo.mineLevel and balancMineInfo.mineLevel > 0 then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGuildMineReward) end end return UIGuildMineMain