local SlgGvE_Controller = {} local private = {} local EventSystem = require('Event/EventSystem') local SLG_GVE_SEASON_START_TIME = "SLG_GVE_SEASON_START_TIME" local SLG_GVE_SEASON_STATE = "SLG_GVE_SEASON_STATE" local SLG_GVE_ILLUSTRATE_ATUO_OPEN = "SLG_GVE_ILLUSTRATE_ATUO_OPEN" local SLG_GVE_NEW_AUCTION_ATUO_OPEN = "SLG_GVE_NEW_AUCTION_ATUO_OPEN" local SLG_MARK_CONTENT_KEY = "SLG_MARK_CONTENT_KEY" --slg地图格子的UI尺寸 SlgGvE_Controller.GRID_UI_WIDTH = 384 SlgGvE_Controller.GRID_UI_HEIGHT = 270 --slg小地图导出原图尺寸 SlgGvE_Controller.MiniMap_WIDTH = 56 SlgGvE_Controller.MiniMap_HEIGHT = 80 --slg地图的最大长宽数量 SlgGvE_Controller.DRAG_LIMIT_HORIZONTAL_NUM = 100 SlgGvE_Controller.DRAG_LIMIT_VERTICAL_NUM = 120 SlgGvE_Controller.MaterialsItemId = {2230,2231,2232} SlgGvE_Controller.LayerType = { Btn = 1, AtlasIcon = 2, ImageIcon = 4, Frame = 8, AttackingExp = 16, --攻打表现 BloodTimer = 32, --血条倒计时 } --Collection类型的layer SlgGvE_Controller.CollectionLayerType = { [SlgGvE_Controller.LayerType.Btn] = true, [SlgGvE_Controller.LayerType.BloodTimer] = true, } --Image类型的layer 1:Image 2:HalfImage SlgGvE_Controller.ImageLayerType = { [SlgGvE_Controller.LayerType.AtlasIcon] = 1, [SlgGvE_Controller.LayerType.ImageIcon] = 1, [SlgGvE_Controller.LayerType.Frame] = 1, [SlgGvE_Controller.LayerType.AttackingExp] = 1, } SlgGvE_Controller.LineupEnterType = { lineUpOrBattle = 1, --布阵或出征(扫荡) onlyLineUp = 2, --仅布阵 } private.maxOfficalLv = 0 private.officialLvTaskCfg = {} --官爵任务配置数据[officialLv {taskCfgList}] private.lastBattleGridIndex = 0 --上次战斗进入的地块gridId private.talentGroupMaxLv = {} --天赋组最大等级[talentGroupID maxLv] private.rankBossCfgs = {} --排行榜的bossCfg local OccupyFramePath_Empty = ConstAssetPathConfig.OccupyFramePath_Empty local OccupyFramePath_Mine = ConstAssetPathConfig.OccupyFramePath_Mine local OccupyFramePath_Guild = ConstAssetPathConfig.OccupyFramePath_Guild local OccupyFramePath_Friend = ConstAssetPathConfig.OccupyFramePath_Friend local AttackExp_Attacking = ConstAssetPathConfig.AttackExp_Attacking local AttackExp_Thief = ConstAssetPathConfig.AttackExp_Thief function SlgGvE_Controller.OnStartup() EventSystem.Regist(EventID.FunctionUnlockUpdate, private.RefreshInfoByFunction) EventSystem.Regist(EventID.UI_SlgGvE_Official_Update_Info, private.SetOfficialAndTalentRedPoint) EventSystem.Regist(EventID.UI_SlgGvE_Talent_Update_Info, private.SetTalentRedPoint) EventSystem.Regist(EventID.UI_SlgGvE_Material_Update_Info, private.SetTalentRedPoint) EventSystem.Regist(EventID.UI_SlgGvE_SeasonTime_Update, private.CheckSeasonStatus) EventSystem.Regist(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE, private.RefreshActivityUIRedPoint) EventSystem.Regist(EventID.UI_Guild_SelfInfoRefresh, private.CheckRedPoint) -- 势力变更(新加入势力) EventSystem.Regist(EventID.UI_GuildAuctionBtnState_Refresh, private.CheckAcutionRedPoint) EventSystem.Regist(EventID.UI_Guild_AuctionShareBonusRefresh, private.CheckAcutionRedPoint) --初始化缓存静态数据 for _, v in DataSheetManager.SlgGvEOfficialTask:GetEnumerator() do private.maxOfficalLv = v.OfficialTitleID if not private.officialLvTaskCfg[v.OfficialTitleID] then private.officialLvTaskCfg[v.OfficialTitleID] = {} end table.insert(private.officialLvTaskCfg[v.OfficialTitleID], v) end for _, v in DataSheetManager.SlgGvETalentData:GetEnumerator() do private.talentGroupMaxLv[v.GveTalentGroupID] = v.GveTalentLevel end for _, v in DataSheetManager.SlgGvEPlotData:GetEnumerator() do if v.GveMapType == 4 then --精英城池 table.insert(private.rankBossCfgs, v) elseif v.GveMapType == 5 and v.GveMapLevel == 1 then --boss城池,只算第一次的 table.insert(private.rankBossCfgs, v) end end end --GMS开关变化时刷新 function private.RefreshInfoByFunction(funcId, isUnlock) if funcId == MDL.Unlock.FunctionType.SlgGvE then if not isUnlock then private.CloseAll() else private.CheckRedPoint() end end end --离开势力 function SlgGvE_Controller.OnLeaveGuild() private.CloseAll() MDL.SlgGvE.ClearAllGrid() private.RemoveMarkContentNotice() end function private.CloseAll() UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvEMain) SlgGvE_Controller.CloseAllPopUpUI() SlgGvE_Controller.MarkGridIndex(nil, false) private.CheckRedPoint() end --region 红点 (信息球) function private.CheckRedPoint() private.SetOfficialAndTalentRedPoint() private.CheckSeasonStatus() private.CheckAcutionRedPoint() SlgGvE_Controller.RefreshInfoReminder() end function SlgGvE_Controller.SetSeasonRedPoint() PersistentData.PlayerData:Set(SLG_GVE_SEASON_START_TIME, MDL.SlgGvE.GetSeasonStartTime(), true) PersistentData.PlayerData:Set(SLG_GVE_SEASON_STATE, MDL.SlgGvE.GetSeasonState(), true) CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Season) end function private.RefreshActivityUIRedPoint(redpoint) SlgGvE_Controller.RefreshInfoReminder() EventSystem.Dispatch(EventID.UI_Activity_Refresh_Single_RedPoint, LuaConst.ActivityType.SlgGvE, redpoint) end function SlgGvE_Controller.RefreshInfoReminder() CTL.HomeMain.RemoveMainNotice(CTL.HomeMain.NoticeType.SlgGvE) local info = MDL.SlgGvE.GetAttackingCityOrBossInfo() local redpoint = CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE) if MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SlgGvE) and (redpoint or info.deadLine) then CTL.HomeMain.AddMainNotice(CTL.HomeMain.NoticeType.SlgGvE) end end function private.SetOfficialAndTalentRedPoint() private.SetOfficialRedPoint() private.SetTalentRedPoint() end function private.SetOfficialRedPoint() if not MDL.Guild.IsHasGuild() or not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SlgGvE) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Official) return end if MDL.SlgGvE.GetSeasonState() ~= MDL.SlgGvE.SeasonState.Playing then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Official) return end --可领取官爵奖励 local curOfficalLv = MDL.SlgGvE.GetCurOfficalLv() if SlgGvE_Controller.IsFinishedAllTask(curOfficalLv) and not MDL.SlgGvE.IsCurOfficalLvRewardReceived(curOfficalLv) then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Official) return end --任务可领取 if private.IsHasReceivableTask() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Official) return end CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Official) end function private.IsHasReceivableTask() local taskDataMap = MDL.SlgGvE.GetOfficalTasksDataMap(MDL.SlgGvE.GetCurOfficalLv()) for _, v in pairs(taskDataMap) do if v.taskState == MDL.SlgGvE.OfficialTaskState.Finished then return true end end return false end function private.SetTalentRedPoint() if not MDL.Guild.IsHasGuild() or not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SlgGvE) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Talent) return end if MDL.SlgGvE.GetSeasonState() ~= MDL.SlgGvE.SeasonState.Playing then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Talent) return end --可升级天赋时 if private.IsHasTalentCanUp() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Talent) return end CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Talent) end --是否有天赋可升级 function private.IsHasTalentCanUp() if MDL.SlgGvE.GetSeasonState() ~= MDL.SlgGvE.SeasonState.Playing then return false end local talentAllInfoMap = MDL.SlgGvE.GetTalentAllInfoMap() local curOfficalLv = MDL.SlgGvE.GetCurOfficalLv() for lv, infoList in pairs(talentAllInfoMap) do if lv <= curOfficalLv then --到达可升级官爵等级 for _, talentInfo in ipairs(infoList) do if SlgGvE_Controller.IsCanUpTalent(talentInfo.talentCfg) then return true end end end end return false end --赛季状态发生变化 function private.CheckSeasonStatus() if not MDL.Guild.IsHasGuild() or not MDL.SlgGvE.GetSeasonStartTime() or not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SlgGvE) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Season) CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Thief) return end if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.End then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Season) CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Thief) private.SetOfficialAndTalentRedPoint() return end if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.Showing then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Season) CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Thief) private.SetOfficialAndTalentRedPoint() else local startTime = PersistentData.PlayerData:Get(SLG_GVE_SEASON_START_TIME) or 0 if startTime < MDL.SlgGvE.GetSeasonStartTime() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Season) else local seasonState = PersistentData.PlayerData:Get(SLG_GVE_SEASON_STATE) or 0 if seasonState ~= MDL.SlgGvE.SeasonState.Playing and MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.Playing then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Season) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Season) end end end end function SlgGvE_Controller.ClickInfoReminder(sourceId) local mapInfo = MDL.SlgGvE.GetAttackingCityOrBossInfo() if mapInfo.landId then local str = string.FormatByIdsId(Const_IDS.IDS_SlgGve_Main_Hint_14, CTL.SlgGvE.GetGridQualityColorName(mapInfo.landId)) UTL.MessageBox.ShowOKCancelBox(nil, str, function() CTL.ItemSources.ExecuteSourceFunctionById(sourceId, nil, {gveMapID = mapInfo.landId}) end) else CTL.ItemSources.ExecuteSourceFunctionById(sourceId) end end function private.CheckAcutionRedPoint() if not MDL.Guild.IsHasGuild() or not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SlgGvE) then CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Auction) return end --有分红 或者 新拍卖未查看 if private.GetNewAcutionIsViewedRedPoint() or SlgGvE_Controller.GetAcutionShareBonusRedPoint() then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Auction) return end CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Auction) end function SlgGvE_Controller.GetAcutionShareBonusRedPoint() if MDL.Guild.IsHasGuild() then return MDL.Guild.CanReceiveSlgGvEWeekAuctionBonus() end return false end function private.GetNewAcutionIsViewedRedPoint() if not MDL.GuildAuction.IsOpenAuctionByType(MDL.GuildAuction.AllAuctionType.SlgGvE) then return false end local lastOpenStamp = PersistentData.PlayerData:Get(SLG_GVE_NEW_AUCTION_ATUO_OPEN) if not lastOpenStamp or (lastOpenStamp < UTL.Time.GetServerTimestamp() and UTL.Time.IsTimestampCrossDay(lastOpenStamp)) then return true end return false end --endregion 红点(信息球) function SlgGvE_Controller.TryOpenNewAuctionOpenView() if not MDL.GuildAuction.IsOpenAuctionByType(MDL.GuildAuction.AllAuctionType.SlgGvE) then return end local lastOpenStamp = PersistentData.PlayerData:Get(SLG_GVE_NEW_AUCTION_ATUO_OPEN) if not lastOpenStamp or (lastOpenStamp < UTL.Time.GetServerTimestamp() and UTL.Time.IsTimestampCrossDay(lastOpenStamp)) then PersistentData.PlayerData:Set(SLG_GVE_NEW_AUCTION_ATUO_OPEN, MDL.GuildAuction.GetAuctionEndTime(MDL.GuildAuction.AllAuctionType.SlgGvE), true) private.CheckAcutionRedPoint() UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvEAuctionBase) UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvEAuctionTipsPanel) end return false end function SlgGvE_Controller.IsCanUpTalent(talentCfg) if MDL.SlgGvE.GetSeasonState() ~= MDL.SlgGvE.SeasonState.Playing then return false end local curOfficalLv = MDL.SlgGvE.GetCurOfficalLv() if talentCfg.FrontHonorTitleID > curOfficalLv then --到达可升级官爵等级 return false end if #talentCfg.CostItem_Table > 0 and SlgGvE_Controller.GetTalentUnlockStatusAndConditions(talentCfg) then --未满级并满足解锁条件 if private.IsMaterialEnough(talentCfg.CostItem_Table) then --材料是否足够 return true end end return false end function private.IsMaterialEnough(costItem) for _, v in ipairs(costItem) do if MDL.SlgGvE.GetMaterialNum(v.Item) < v.ItemNum then return false end end return true end --天赋是否满足解锁升级下级条件 --若未解锁,并返回解锁条件 function SlgGvE_Controller.GetTalentUnlockStatusAndConditions(talentCfg) local curOfficalLv = MDL.SlgGvE.GetCurOfficalLv() local isMeetOfficalCondition = false --是否满足官爵条件 local isMeetTalentCondition = false --是否满足天赋条件 local officalConditionStr, talentConditionStr if curOfficalLv >= talentCfg.FrontHonorTitleID then isMeetOfficalCondition = true else local officalCfg = DataSheetManager.SlgGvEOfficialLevel:GetDataByOfficialTitleLevel(talentCfg.FrontHonorTitleID) officalConditionStr = string.FormatByIdsKey("IDS_SlgGve_Talent_Hint_11", UIUtils.GetLocalizedTxt(Const_IDS[officalCfg.OfficialTitleName])) end if talentCfg.FrontGveTalentID and talentCfg.FrontGveTalentID ~= 0 then if MDL.SlgGvE.IsTalentUnlock(talentCfg.FrontGveTalentID) then isMeetTalentCondition = true else isMeetTalentCondition = false local talentCfg = DataSheetManager.SlgGvETalentData:GetDataByGveTalentID(talentCfg.FrontGveTalentID) talentConditionStr = string.FormatByIdsKey("IDS_SlgGve_Talent_Hint_10", UIUtils.GetLocalizedTxt(Const_IDS[talentCfg.GveTalentName]), talentCfg.GveTalentLevel) end else isMeetTalentCondition = true end return isMeetOfficalCondition and isMeetTalentCondition, officalConditionStr, talentConditionStr end --天赋的加成 --加成列表{addName, addValue} function SlgGvE_Controller.GetNormalTalentAddInfoList(talentCfg) local addList = {} local params = talentCfg.ParameterRule_Table for i, v in ipairs(params) do if talentCfg.GveTalentType == 1 or talentCfg.GveTalentType == 2 then --加全员/属性队列属性加成 local attrData = DataSheetManager.AttrData:GetDataByID(v.GveTalentAddParameter1) table.insert(addList,{addName = UIUtils.GetLocalizedTxt(Const_IDS[attrData.Name]), addValue = "+"..v.GveTalentAddParameter2}) elseif talentCfg.GveTalentType == 3 then --产出加成 local addName = "" if v.GveTalentAddParameter1 == 1 then addName = UIUtils.GetLocalizedTxt(Const_IDS["IDS_SlgGve_Talent_Des_16"]) elseif v.GveTalentAddParameter1 == 2 then addName = UIUtils.GetLocalizedTxt(Const_IDS["IDS_SlgGve_Talent_Des_17"]) elseif v.GveTalentAddParameter1 == 3 then addName = UIUtils.GetLocalizedTxt(Const_IDS["IDS_SlgGve_Talent_Des_18"]) end table.insert(addList,{addName = addName, addValue = string.FormatByIdsId(Const_IDS.IDS_SlgGve_Main_Hint_1, v.GveTalentAddParameter2*60)}) elseif talentCfg.GveTalentType == 8 then --领地上限扩充 table.insert(addList,{addName = UIUtils.GetLocalizedTxt(Const_IDS[talentCfg.GveTalentDes]), addValue = "+"..v.GveTalentAddParameter1}) else logging.error(LTAG.ERROR,"检查天赋 ",talentCfg.GveTalentID," 的类型 ", talentCfg.GveTalentType) end end return addList end function SlgGvE_Controller.OpenSlgGvEMain(gveMapID, gridIndex) if not BattleDataGetter.IsOnlineTownLevel() then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Chat_NoTurn) return end if not MDL.Guild.IsHasGuild() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_1319_InfoCode_Guild_PlayerNotInGuild"]) return end if not MDL.Unlock.IsUnlock(MDL.Unlock.FunctionType.SlgGvE) then CTL.Tips.AddTipsMsg(Const_IDS.IDS_ERRORCODE_3013_InfoCode_FunctionLock) return end if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.End then UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvEMain) return end UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvEMain, { gveMapID = gveMapID, gridIndex = gridIndex}) end function SlgGvE_Controller.CloseAllPopUpUI() UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvEOfficialMain) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvETalentMain) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvETalentLvUp) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvETradePanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvESelectOfficer) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvELineUp) UIManager.CloseView(Const_UI_Lua.UIEnum.UIChannelChatMain) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvEIllustrate) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvEMiniMap) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvEAuctionTipsPanel) UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvERank) if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISlgGvEAuctionInfo) or UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISlgGvEAuctionBase) or UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISlgGvEAuctionShareOutBonus) then CTL.HomeMain.CloseViewBackHomeMain() end EventSystem.Dispatch(EventID.UI_SlgGve_CloseGridTips) end function SlgGvE_Controller.GetMaxOfficalLv() return private.maxOfficalLv end function SlgGvE_Controller.SetLastBattleGridIndex(gridIndex) private.lastBattleGridIndex = gridIndex end function SlgGvE_Controller.GetLastBattleGridIndex() return private.lastBattleGridIndex end function SlgGvE_Controller.GetOfficialLvTaskCfgList(officialLv) return private.officialLvTaskCfg[officialLv] end function SlgGvE_Controller.GetTalentGroupMaxLv(talentGroupID) return private.talentGroupMaxLv[talentGroupID] end function SlgGvE_Controller.IsFinishedAllTask(officialLv) local curCompletedTaskNum = SlgGvE_Controller.GetOfficialReceivedTaskNum(officialLv) local allTaskNum = #private.officialLvTaskCfg[officialLv] return curCompletedTaskNum == allTaskNum end --已领奖任务数量 function SlgGvE_Controller.GetOfficialReceivedTaskNum(officialLv) local count = 0 local tasksData = MDL.SlgGvE.GetOfficalTasksDataMap(officialLv) for _, v in pairs(tasksData) do if v.taskState == 2 then count = count + 1 end end return count end function SlgGvE_Controller.GetTriggerTaskTotalProgress(triggerIDInfo) local data = triggerIDInfo if data.UnlockCondition == LuaConst.TriggerType.SlgGvE_Talent_Level then --SlgGvE:天赋权柄x到达y级 return 1 else return triggerIDInfo.UnlockConditionParamA end end function SlgGvE_Controller.GetTriggrtUnlockConditionPlotName(data) local plotName local param = tonumber(data.UnlockConditionParamB) if param == 1 then plotName = UIUtils.GetLocalizedTxt(Const_IDS["IDS_SlgGve_Plot_Name_6"]) elseif param == 2 then plotName = UIUtils.GetLocalizedTxt(Const_IDS["IDS_SlgGve_Plot_Name_7"]) elseif param == 3 then plotName = UIUtils.GetLocalizedTxt(Const_IDS["IDS_SlgGve_Plot_Name_8"]) else logging.error(LTAG.ERROR,"Trigger 占领X个Z类型地块,UnlockConditionParamB 参数有误或需新增类型", data.UnlockConditionParamB) end return plotName end function SlgGvE_Controller.OpenHeroSelectOfficer(teamId) UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvESelectOfficer, { freeLineupFuncType = MDL.FreeLineUp.FuncType.SlgGvE, activityType = LuaConst.ActivityType.SlgGvE, teamId = teamId }, Const_UI_Lua.UIEnum.UIDemonGodSelectOfficer) end function SlgGvE_Controller.ShowBattleUI() EventSystem.Regist(EventID.UI_UIBattleCountDownPanel_CloseEvent, private.RunLevel) UIManager.OpenView(Const_UI_Lua.UIEnum.UIBattleCountDownFormalPanel, {3}) CTL.HomeMain.OpenBattleSceneUI() NotSyncBattleSetter.PauseLevel(true) --参考爬塔,进关时设定可以显示胜利pose LuaInputManager.EnqueueSpecialCommand(LuaConst.SpecialCommandType.SetCanShowVictoryPose) end function private.RunLevel() NotSyncBattleSetter.PauseLevel(false) EventSystem.UnRegist(EventID.UI_UIBattleCountDownPanel_CloseEvent,private.RunLevel) end function SlgGvE_Controller.ShowSlgGvESummaryPanel(msg) logging.log(LTAG.LOG, "战斗结算信息", msg.gveInfo) UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvESummaryPanel, msg) end function SlgGvE_Controller.SetCurSelectTeamId(teamId) private.curSelectTeamId = teamId end function SlgGvE_Controller.GetCurSelectTeamId() return private.curSelectTeamId end function SlgGvE_Controller.OpenLineUp(enterType, plotId, isEnemySoldier, pointIndex, isSweep) if MDL.SlgGvE.GetSeasonState() ~= MDL.SlgGvE.SeasonState.Playing then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SlgGve_Season_Hint_4"]) return end UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvELineUp, { enterType = enterType, plotId = plotId, isEnemySoldier = isEnemySoldier ,pointIndex = pointIndex, isSweep = isSweep}) end function SlgGvE_Controller.TryOpenUISlgGvEIllustrate() local isOpened = PersistentData.PlayerData:Get(SLG_GVE_ILLUSTRATE_ATUO_OPEN) if not isOpened then PersistentData.PlayerData:Set(SLG_GVE_ILLUSTRATE_ATUO_OPEN, true, true) UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvEIllustrate) end end function SlgGvE_Controller.GetRankBossCfgs() return private.rankBossCfgs end function SlgGvE_Controller.GetGridParam(gridIndex, layerType) local type, info, middleIndex = MDL.SlgGvE.GetGridInfo(gridIndex) if info == nil then return false end if layerType == SlgGvE_Controller.LayerType.Btn then if type ~= MDL.SlgGvE.GridType.Block then return true end elseif layerType == SlgGvE_Controller.LayerType.Frame then if type == MDL.SlgGvE.GridType.Block then return false end if info.hasOccupy == false then return true, OccupyFramePath_Empty else if MDL.SlgGvE.CheckGridMyOccupied(gridIndex) then return true, OccupyFramePath_Mine elseif type == MDL.SlgGvE.GridType.Normal_1 or type == MDL.SlgGvE.GridType.Normal_2 or type == MDL.SlgGvE.GridType.Normal_3 then return true, OccupyFramePath_Friend else return true, OccupyFramePath_Guild end end elseif layerType == SlgGvE_Controller.LayerType.AtlasIcon then if type == MDL.SlgGvE.GridType.Normal_1 or type == MDL.SlgGvE.GridType.Normal_2 or type == MDL.SlgGvE.GridType.Normal_3 then local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(info.gveMapID) return true, gridCfg.GveMapIcon end elseif layerType == SlgGvE_Controller.LayerType.ImageIcon then if type == MDL.SlgGvE.GridType.Block then if string.isNilOrEmpty(info) then return false else return true, info end elseif type == MDL.SlgGvE.GridType.Elite or type == MDL.SlgGvE.GridType.Boss then if middleIndex > 0 then return false else local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(info.gveMapID) return true, gridCfg.GveMapIcon end end elseif layerType == SlgGvE_Controller.LayerType.AttackingExp then if middleIndex > 0 then return false end --展示期不显示 if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.Showing then return false end if type == MDL.SlgGvE.GridType.Normal_1 or type == MDL.SlgGvE.GridType.Normal_2 or type == MDL.SlgGvE.GridType.Normal_3 then --判断是否有贼兵 if MDL.SlgGvE.CheckGridIndexHasThief(gridIndex) then return true, AttackExp_Thief end end if type ~= MDL.SlgGvE.GridType.Block then if info.attackState then return true, AttackExp_Attacking end end elseif layerType == SlgGvE_Controller.LayerType.BloodTimer then if middleIndex > 0 then return false end local scaleType = 0 if type == MDL.SlgGvE.GridType.Elite then scaleType = 0 if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.Showing then return true, 0, nil, 0, 0, SlgGvE_Controller.GetGridTitle(gridIndex), scaleType else local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(info.gveMapID) if gridCfg.IsDisplayResetTime and info.resetDeadLine > 0 then return true, info.resetDeadLine, Const_IDS.IDS_SlgGve_Enemy_Hint_14, info.bossMaxHp, info.bossCurHp, SlgGvE_Controller.GetGridTitle(gridIndex), scaleType else if info.hasOccupy == false then return true, 0, nil, info.bossMaxHp, info.bossCurHp, SlgGvE_Controller.GetGridTitle(gridIndex), scaleType else return true, 0, nil, 0, 0, SlgGvE_Controller.GetGridTitle(gridIndex), scaleType end end end elseif type == MDL.SlgGvE.GridType.Boss then scaleType = 1 if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.Showing then return true, 0, nil, 0, 0, SlgGvE_Controller.GetGridTitle(gridIndex), scaleType else local curHp, maxHp = 0, 0 if info.hasEnemy == true or info.hasOccupy == false then curHp, maxHp = info.bossCurHp, info.bossMaxHp end local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(info.gveMapID) if info.rebornTime > 0 then return true, info.rebornTime, Const_IDS.IDS_SlgGve_Enemy_Hint_18, maxHp, curHp, SlgGvE_Controller.GetGridTitle(gridIndex), scaleType elseif gridCfg.IsDisplayResetTime and info.resetDeadLine > 0 then return true, info.resetDeadLine, Const_IDS.IDS_SlgGve_Enemy_Hint_14, maxHp, curHp, SlgGvE_Controller.GetGridTitle(gridIndex), scaleType else return true, 0, nil, maxHp, curHp, SlgGvE_Controller.GetGridTitle(gridIndex), scaleType end end else local hasThief, endTime = MDL.SlgGvE.CheckGridIndexHasThief(gridIndex) if hasThief then return true, endTime, Const_IDS.IDS_SlgGve_Enemy_Hint_15, 0 end end end return false end function SlgGvE_Controller.GetGridTitle(gridIndex) local gridCfg = MDL.SlgGvE.GetGridCfg(gridIndex) if gridCfg then local x, y = UTL.SLG.IndexToPosition(gridIndex) return string.format("%s(%s,%s)", string.FormatByIdsId(Const_IDS[gridCfg.GveMapName], gridCfg.GveMapLevel), x, y) end return nil end function SlgGvE_Controller.CollectAllBlock(result) local SlgGvEBlockData = require("Modules/SlgGvE/SlgGvEBlockData") local blockCfg = SlgGvEBlockData.BlockCfg local blockIndexes = blockCfg[1] local templateIds = blockCfg[2] for i, blockIndex in ipairs(blockIndexes) do if result[blockIndex] == nil then result[blockIndex] = "" end local templateId = templateIds[i] SlgGvE_Controller.CollectBlockIndexByTemplateId(SlgGvEBlockData, templateId, blockIndex, result) end end --收集阻碍模板所有阻碍格子 function SlgGvE_Controller.CollectBlockIndexByTemplateId(baseData, templateId, index, result) local templateCfg = baseData.BlockTemplateCfg[templateId] local blockUnits = templateCfg[1] local xOffsets = templateCfg[2] local yOffsets = templateCfg[3] for i, v in ipairs(blockUnits) do local xOffset = xOffsets[i] local yOffset = yOffsets[i] local x, y = UTL.SLG.IndexToPosition(index) local unitX, unitY = x + xOffset, y + yOffset local key = UTL.SLG.PositionToIndex(unitX, unitY) if result[key] == nil then result[key] = "" end --单元格子 local blockUnitCfg = baseData.BlockUnitCfg[v] local blockUnitXOffsets = blockUnitCfg[1] local blockUnitYOffsets = blockUnitCfg[2] local blockUnitImage = blockUnitCfg[3] for j, blockUnitXOffset in ipairs(blockUnitXOffsets) do local blockUnitYOffset = blockUnitYOffsets[j] if j == 1 then result[UTL.SLG.PositionToIndex(unitX + blockUnitXOffset, unitY + blockUnitYOffset)] = blockUnitImage else local key = UTL.SLG.PositionToIndex(unitX + blockUnitXOffset, unitY + blockUnitYOffset) if result[key] == nil then result[key] = "" end end end end end function SlgGvE_Controller.GetLimitRectPosition() local limitUILeftValue, limitUIRightValue, limitUITopValue, limitUIBottomValue local middleIndex = UTL.SLG.PositionToIndex(MDL.SlgGvE.GRID_SIZE / 2, MDL.SlgGvE.GRID_SIZE / 2) local leftTopIndex, leftBottomIndex, rightTopIndex, rightBottomIndex = UTL.SLG.GetDragLimitRectIndex(middleIndex, SlgGvE_Controller.DRAG_LIMIT_HORIZONTAL_NUM, SlgGvE_Controller.DRAG_LIMIT_VERTICAL_NUM) local uiPositionX1, uiPositionY1 = UTL.SLG.PositionToUIPosition(UTL.SLG.IndexToPosition(leftTopIndex)) --左上角位置 local uiPositionX2, uiPositionY2 = UTL.SLG.PositionToUIPosition(UTL.SLG.IndexToPosition(rightTopIndex)) --右上角位置 local uiPositionX3, uiPositionY3 = UTL.SLG.PositionToUIPosition(UTL.SLG.IndexToPosition(rightBottomIndex)) --右下角位置 local uiPositionX4, uiPositionY4 = UTL.SLG.PositionToUIPosition(UTL.SLG.IndexToPosition(leftBottomIndex)) --左下角位置 limitUILeftValue = uiPositionX1 limitUITopValue = uiPositionY1 local height_1 = math.abs(uiPositionY1 - uiPositionY4) local height_2 = math.abs(uiPositionY2 - uiPositionY3) local width = math.abs(uiPositionX1 - uiPositionX2) local rectSize = math.min(height_1, height_2, width) if rectSize == width then limitUIRightValue = uiPositionX2 else limitUIRightValue = uiPositionX1 + rectSize end limitUIBottomValue = uiPositionY1 - rectSize return limitUILeftValue, limitUIRightValue, limitUITopValue, limitUIBottomValue end --Editor Only function SlgGvE_Controller.ExportGrids() local result = {} local blockSet = {} local configSet = {} UTL.SLG.InitSlgMap(MDL.SlgGvE.GRID_SIZE, SlgGvE_Controller.GRID_UI_WIDTH, SlgGvE_Controller.GRID_UI_HEIGHT) local limitUILeftValue, limitUIRightValue, limitUITopValue, limitUIBottomValue = SlgGvE_Controller.GetLimitRectPosition() SlgGvE_Controller.CollectAllBlock(blockSet) --local middleIndex = UTL.SLG.PositionToIndex(MDL.SlgGvE.GRID_SIZE / 2, MDL.SlgGvE.GRID_SIZE / 2) local middleIndex = 13676 --改成以汉中城为中心,而不是菱形中心 for i, v in DataSheetManager.SlgGvEPlotPosition:GetEnumerator() do for i, index in ipairs(v.GveMapPlotPosition) do configSet[index] = true end end local allSet = {} UTL.SLG.CollectRectGrids(UTL.SLG.PositionToIndex(MDL.SlgGvE.GRID_SIZE / 2, MDL.SlgGvE.GRID_SIZE / 2), SlgGvE_Controller.DRAG_LIMIT_HORIZONTAL_NUM, SlgGvE_Controller.DRAG_LIMIT_VERTICAL_NUM, allSet) --先将重复的和范围外的清除 for index, v in pairs(allSet) do if blockSet[index] or configSet[index] then allSet[index] = nil else local posX, posY = UTL.SLG.IndexToPosition(index) local uiX, uiY = UTL.SLG.PositionToUIPosition(posX, posY) if uiX >= limitUILeftValue and uiX <= limitUIRightValue and uiY >= limitUIBottomValue and uiY <= limitUITopValue then else allSet[index] = nil end end end --按尺寸分组,分成尺寸5*6划分成24组 local groupCount = 24 local widthSize = 5 local heightSize = 6 local uiMiddleX, uiMiddleY = UTL.SLG.PositionToUIPosition(UTL.SLG.IndexToPosition(middleIndex)) local leftFixedValue = math.abs(limitUILeftValue - uiMiddleX) / (groupCount + 1) local rightFixedValue = math.abs(limitUIRightValue - uiMiddleX) / (groupCount + 1) local topFixedValue = math.abs(limitUITopValue - uiMiddleY) / (groupCount + 1) local bottomFixedValue = math.abs(limitUIBottomValue - uiMiddleY) / (groupCount + 1) for i = 1, groupCount do local x = widthSize * i local y = heightSize * i local key = x .. "*" .. y result[key] = {} for index, _ in pairs(allSet) do local posX, posY = UTL.SLG.IndexToPosition(index) local uiX, uiY = UTL.SLG.PositionToUIPosition(posX, posY) local middleLeftValue = uiMiddleX - i * leftFixedValue local middleRightValue = uiMiddleX + i * rightFixedValue local middleTopValue = uiMiddleY + i * topFixedValue local middleBottomValue = uiMiddleY - i * bottomFixedValue if uiX >= middleLeftValue and uiX <= middleRightValue and uiY >= middleBottomValue and uiY <= middleTopValue then allSet[index] = nil result[key][index] = true end end end --剩余的进最后一组 for index, v in pairs(allSet) do result[groupCount * widthSize .. "*" .. groupCount * heightSize][index] = true end local content = nil for key, indexes in pairs(result) do if content == nil then content = key .. ":[" else content = content .. "]\n" .. key .. ":[" end local count = 0 for index, _ in pairs(indexes) do if count == 0 then content = content .. index else content = content .. "," .. index end count = count + 1 end end content = content .. "]" LuaExt.FileWriteText("result.txt", content) return result end function SlgGvE_Controller.ExportMiniMapGrids() local blockSet = {} local configSet = {} UTL.SLG.InitSlgMap(MDL.SlgGvE.GRID_SIZE, SlgGvE_Controller.GRID_UI_WIDTH, SlgGvE_Controller.GRID_UI_HEIGHT) local limitUILeftValue, limitUIRightValue, limitUITopValue, limitUIBottomValue = SlgGvE_Controller.GetLimitRectPosition() SlgGvE_Controller.CollectAllBlock(blockSet) local middleIndex = UTL.SLG.PositionToIndex(MDL.SlgGvE.GRID_SIZE / 2, MDL.SlgGvE.GRID_SIZE / 2) for i, v in DataSheetManager.SlgGvEPlotPosition:GetEnumerator() do for i, index in ipairs(v.GveMapPlotPosition) do configSet[index] = true end end local result = {} UTL.SLG.CollectRectGrids(middleIndex, SlgGvE_Controller.DRAG_LIMIT_HORIZONTAL_NUM, SlgGvE_Controller.DRAG_LIMIT_VERTICAL_NUM, result) for index, v in pairs(result) do if blockSet[index] or configSet[index] then result[index] = nil end local posX, posY = UTL.SLG.IndexToPosition(index) local uiX, uiY = UTL.SLG.PositionToUIPosition(posX, posY) if uiX >= limitUILeftValue and uiX <= limitUIRightValue and uiY >= limitUIBottomValue and uiY <= limitUITopValue then else result[index] = nil end end for i, v in pairs(result) do result[i] = 1 end for i, v in pairs(configSet) do result[i] = 2 end for i, v in pairs(blockSet) do result[i] = 0 end local content = nil for i, v in pairs(result) do if content == nil then content = i .. "," .. v else content = content .. "\n" .. i .. "," .. v end end LuaExt.FileWriteText("result.txt", content) return result end --计算当前贼兵的战力 function SlgGvE_Controller.GetCurThiefGs(thiefLevel) local baseGs = MDL.SlgGvE.GetGvEConstData().StandardGS local openDay = MDL.Player.GetPersonalServerDayCount() for i, v in DataSheetManager.SlgGvEOpenDay:GetEnumerator() do if openDay >= v.OpenDayMin and openDay <= v.OpenDayMax then for i, v in ipairs(v.EnemyScale_Table) do if v.EnemyLevel == thiefLevel then return math.ceil(v.EnemyGSScale * baseGs) end end end end return baseGs end function SlgGvE_Controller.GetMaterialEarnNum(cfgNum) local count = MDL.SlgGvE.GetGvEConstData().GveHoldRewardTime return cfgNum * (60 / count) end function SlgGvE_Controller.GetGridQualityColorName(gridId) local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(gridId) local mapName = UIUtils.GetLocalizedTxt(Const_IDS[gridCfg.GveMapName]) if gridCfg.GveMapType == MDL.SlgGvE.GridType.Elite then mapName = UTL.Color.FormatQualityText(mapName, LuaConst.QualityColor.Orange) elseif gridCfg.GveMapType == MDL.SlgGvE.GridType.Boss then mapName = UTL.Color.FormatQualityText(mapName, LuaConst.QualityColor.Red) end return mapName end function SlgGvE_Controller.CheckGridIfLinked(index) local type, info = MDL.SlgGvE.GetGridInfo(index) if type == MDL.SlgGvE.GridType.Elite or type == MDL.SlgGvE.GridType.Boss then local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(info.gveMapID) local posCfg = DataSheetManager.SlgGvEPlotPosition:GetDataByGveMapPositionID(gridCfg.GveMapPositionID) for _, index in ipairs(posCfg.GveMapPlotPosition) do if private.CheckGridsIfOccupied(UTL.SLG.GetLinkedGridIndexes(index)) then return true, false end if private.CheckGridsIfMembersOccupied(UTL.SLG.GetLinkedGridIndexes(index)) then return true, false end end else if private.CheckGridsIfOccupied(UTL.SLG.GetLinkedGridIndexes(index)) then return true, true end if private.CheckGridsIfMembersOccupied(UTL.SLG.GetLinkedGridIndexes(index)) then return true, false end end return false, false end function SlgGvE_Controller.CheckIfGridLineUp(index) local isThief = MDL.SlgGvE.CheckGridIndexHasThief(index) if isThief then --贼兵不用判断 return true end if MDL.SlgGvE.IsOtherPlayerAttacking(index) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SlgGve_BattleArray_Hint_9"]) --其他玩家正在攻打 return false end local type = MDL.SlgGvE.GetGridInfo(index) if type == MDL.SlgGvE.GridType.Elite then --精英地块不用判断上限 elseif type == MDL.SlgGvE.GridType.Boss then --boss地块判断出征时间 if UTL.Time.IsServerInOpeningTime(MDL.SlgGvE.GetGvEConstData().BossStopTime1, MDL.SlgGvE.GetGvEConstData().BossStopTime2) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_SlgGve_BattleArray_Hint_19"]) return false end else if MDL.SlgGvE.GetMyOccupyGridCount() >= MDL.SlgGvE.GetPlotLimit() then CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_1067_IDS_ERRORCODE_1067_InfoCode_SlgGve"]) --已达到可占领领地上限,无法发起进攻 return false end end if SlgGvE_Controller.CheckGridIfLinked(index) == false then --判断地块是否相邻 CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_4101_IDS_ERRORCODE_4101_InfoCode_SlgGve"]) return false end return true end function private.CheckGridsIfOccupied(...) local count = select('#', ...) for i = 1, count do local index = select(i, ...) if MDL.SlgGvE.CheckGridMyOccupied(index) then return true end end return false end function private.CheckGridsIfMembersOccupied(...) if MDL.SlgGvE.IsCanBorrowRoad() == false then return false end local count = select('#', ...) for i = 1, count do local index = select(i, ...) local type, info, middleIndex = MDL.SlgGvE.GetGridInfo(index) if type ~= MDL.SlgGvE.GridType.Block then if info.hasOccupy == true then return true end end end return false end --标记地块位置 function SlgGvE_Controller.MarkGridIndex(index, isManual) if index == nil then if isManual then CTL.Tips.AddTipsMsg(Const_IDS.IDS_SlgGve_Main_Hint_20) end private.markGridIndex = nil else local type, info, middleIndex = MDL.SlgGvE.GetGridInfo(index) if middleIndex > 0 then private.markGridIndex = middleIndex else private.markGridIndex = index end if isManual then CTL.Tips.AddTipsMsg(Const_IDS.IDS_SlgGve_Main_Hint_19) end end end function SlgGvE_Controller.GetMarkGridIndex() return private.markGridIndex end function SlgGvE_Controller.CheckMyOccupyGridRed() --贼兵红点 if MDL.SlgGvE.GetThiefGridInfo() ~= nil then CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Thief) else CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Thief) end end function SlgGvE_Controller.OpenMiniMap(index) UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvEMiniMap, { gridIndex = index }) end function SlgGvE_Controller.ProcessMarkContent(info) if private.markContentRecord == nil then private.markContentRecord = PersistentData.PlayerData:Get(SLG_MARK_CONTENT_KEY) if private.markContentRecord == nil then private.markContentRecord = {} end end if string.isNilOrEmpty(info.markContent) == false and private.markContentRecord[info.gveMapID] ~= info.markContent then private.markContentNotice = true end end function SlgGvE_Controller.AddMarkContent(id, content) private.markContentRecord[id] = content end function SlgGvE_Controller.GetMarkContentNotice() return private.markContentNotice or false end function SlgGvE_Controller.ClearMarkContentNotice() private.markContentNotice = false for i, v in DataSheetManager.SlgGvEPlotPosition:GetEnumerator() do local _, info = MDL.SlgGvE.GetGridInfo(v.GveMapPlotPosition[1]) private.markContentRecord[info.gveMapID] = info.markContent end PersistentData.PlayerData:Set(SLG_MARK_CONTENT_KEY, private.markContentRecord, true) end function private.RemoveMarkContentNotice() private.markContentNotice = false private.markContentRecord = nil PersistentData.PlayerData:Set(SLG_MARK_CONTENT_KEY, private.markContentRecord, true) end return SlgGvE_Controller