local UISlgGvEMain = UIViewClass() local EventSystem = require("Event/EventSystem") local DragOffset = 1 local bit = require("bit") local SLG_Utility = UTL.SLG --格子UI尺寸 local ITEM_WIDTH = CTL.SlgGvE.GRID_UI_WIDTH local ITEM_HEIGHT = CTL.SlgGvE.GRID_UI_HEIGHT --一些常量偏移量 local NUM_EDIT_LIMIT = 50 local FRAME_WIDTH = 370 local FRAME_HEIGHT = 262 local Offset_Mark = 80 local DISTANCE_OFFSET = 5 local FONT_LIMIT = 39 local Const_Effect_Paths = { ConstAssetPathConfig.SLGGVEScene2,ConstAssetPathConfig.SLGGVEScene3, ConstAssetPathConfig.SLGGVEScene4,ConstAssetPathConfig.SLGGVEScene5,ConstAssetPathConfig.SLGGVEScene6 } local Const_Effect_Interval = 10 --特效刷新间隔 function UISlgGvEMain:OnCreated() UIUtils.SetActive(self.mask, true) SLG_Utility.InitSlgMap(MDL.SlgGvE.GRID_SIZE, ITEM_WIDTH, ITEM_HEIGHT) self.markGridTf = self.head_defenders.gameObject.transform self.templateImageObj = self.Image.gameObject self.templateHalfImageObj = self.HalfImage.gameObject self.templateButtonObj = self.ButtonCol.gameObject self.templateBloodTimerObj = self.BloodTimer.gameObject self.btnLayerTf = self.layer_Btn.gameObject.transform self.bloodTimerTf = self.layer_BloodTimer.gameObject.transform self:RegistTriggerEvent(self.dragRoot, UIEventTriggerType.Drag) self:RegistTriggerEvent(self.dragRoot, UIEventTriggerType.EndDrag) self:RegistTriggerEvent(self.img_map, UIEventTriggerType.PointerDown) self.obj_GridSelectList = { [1] = self.obj_GridSelect, } self.group_MiniMapOccupiedList = { [1] = self.item_occupied, } self.obj_GridSelect.transform:SetSizeDelta(FRAME_WIDTH, FRAME_HEIGHT) self.sourceGridContainer = {} self.viewGridInstanceDict = {} --视野内的格子集合(Component) self.viewGridCollectionDict = {} --视野内的格子集合(Collection) self.poolGridInstanceDict = {} --池子中的格子集合 self.poolGridCollectionDict = {} self.imagePathDict = {} --用来防止相同image重复加载 for i, layerType in pairs(CTL.SlgGvE.LayerType) do if CTL.SlgGvE.CollectionLayerType[layerType] then self.viewGridCollectionDict[layerType] = {} self.poolGridCollectionDict[layerType] = {} else self.viewGridInstanceDict[layerType] = {} self.poolGridInstanceDict[layerType] = {} end if CTL.SlgGvE.ImageLayerType[layerType] then self.imagePathDict[layerType] = {} end end self.indexLayerTypeMapping = {} --视野内索引集合 self.eliteBossGrids = {} self:InitSLGParam() self.effectTf = self.group_Effect.gameObject.transform self.isEffectMiddle = true end function UISlgGvEMain:OnOpened(context) self:RegistSystemEvent(EventID.UI_SlgGvE_Official_Update_Info, self.RefreshOfficialInfo) self:RegistSystemEvent(EventID.UI_SlgGvE_Material_Update_Info, self.RefreshMaterialsGain) self:RegistSystemEvent(EventID.UI_SlgGve_UpdateMyOccupyGridInfo, self.OnUpdateMyOccupyGridInfo) self:RegistSystemEvent(EventID.UI_SlgGvE_Update_PrivilegeEndTime, self.RefreshSeasonPrivilege) self:RegistSystemEvent(EventID.UI_SlgGvE_SeasonTime_Update, self.RefreshSeasonTime) self:RegistSystemEvent(EventID.UI_SlgGve_UpdateGridInfo, self.UpdateGridInfo) self:RegistSystemEvent(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Talent, self.RefreshTalentBtnRedpoint) self:RegistSystemEvent(EventID.UI_SlgGve_SelectGridIndex, self.OnForceSelectGrid) self:RegistSystemEvent(EventID.UI_SlgGve_OpenGridTips, self.OnOpenGridTips) self:RegistSystemEvent(EventID.UI_SlgGvE_Talent_Update_Info, self.RefreshOccupiedLandNum) self:RegistSystemEvent(EventID.UI_GuildAuctionBtnState_Refresh, self.RefreshAuctionBtn) self:RegistSystemEvent(EventID.UI_GuildAuctionBase_RefreshPanel, self.RefreshAuctionBtn) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_SlgGve_Title) UIUtils.SetActive(self.group_seasontips, false) UIUtils.SetActive(self.group_landtips, false) UIUtils.SetActive(self.btn_CloseTips, false) self:RefreshOfficialInfo() self:RefreshMaterialsGain() self:RefreshTalentBtnRedpoint() self:OnUpdateMyOccupyGridInfo() self:RefreshSeasonPrivilege() self:RefreshSeasonTime() self:PlaySound() self:RefreshAuctionBtn() self:RefreshRankBtn() CTL.ChannelChat.SetLastSelectChannelChat(MDL.ChannelChat.ChannelCfgId.Legion) CTL.SlgGvE.SetSeasonRedPoint() MDL.SlgGvE.GVEMainPanelReq(true) CTL.SlgGvE.TryOpenUISlgGvEIllustrate() self.chatView = self.subView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UIBattleChatDlg), { isHideReminder = true }) self.chatView.gameObject.transform:SetAnchoredPosition(-500, 0, 0) self.hasEditGridPermission = MDL.Guild.JobHasPermission(MDL.Guild.GetMyGuildInfo().jobTitle, MDL.Guild.AuthorityEnum.SlgGvEEditMark) end function UISlgGvEMain:RefreshAuctionBtn() CTL.SlgGvE.TryOpenNewAuctionOpenView() local isOpenAuction = MDL.GuildAuction.IsOpenAuctionByType(MDL.GuildAuction.AllAuctionType.SlgGvE) if isOpenAuction then self.state_auction:SetState(0) else self.state_auction:SetState(1) end self.btn_auction:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Auction)) local offset = MDL.GuildAuction.GetAuctionEndTime(MDL.GuildAuction.AllAuctionType.SlgGvE) - UTL.Time.GetServerTimestamp() if offset > 0 then self.auction_timer_event:ResetAndBeginCustomTimer(false, offset, 0, "{0}:{1}", 1) end end function UISlgGvEMain:RefreshRankBtn() UIUtils.SetActive(self.btn_progress, MDL.SlgGvE.IsRankOpen()) UIUtils.SetActive(self.btn_progress1, MDL.SlgGvE.IsRankOpen()) end function UISlgGvEMain:PlaySound() CTL.Sound.PlayGameSound("amb_pause") CTL.Sound.PlayGameSound("MUSIC_hanzhong") CTL.Sound.PlayGameSound("SFX_hanzhong", true) end function UISlgGvEMain:OnForceSelectGrid(gridIndex) UIUtils.SetActive(self.mask, false) if self.context then if self.context.gveMapID then local index = MDL.SlgGvE.GetEliteBossGridIndex(self.context.gveMapID) if index then self:OnSelectGridIndex(index) self.context = nil return end elseif self.context.gridIndex then self:OnSelectGridIndex(self.context.gridIndex) self.context = nil return end end if gridIndex == 0 then self:OnSelectGridIndex(SLG_Utility.PositionToIndex(MDL.SlgGvE.GRID_SIZE / 2, MDL.SlgGvE.GRID_SIZE / 2)) else self:OnSelectGridIndex(gridIndex) end end function UISlgGvEMain:OnUpdateMyOccupyGridInfo() self:RefreshOccupiedLandNum() local thiefIndex, time = MDL.SlgGvE.GetThiefGridInfo() if thiefIndex then UIUtils.SetActive(self.btn_event, true) local offset = time - UTL.Time.GetServerTimestamp() if offset > 0 then self.timer_event:ResetAndBeginCustomTimer(false, offset, 0, "{0}:{1}:{2}", 1) end else UIUtils.SetActive(self.btn_event, false) end --更新我自己的地块 local num = 0 for index, _ in MDL.SlgGvE.PairsMyOccupyGridInfo() do if self.indexLayerTypeMapping[index] then self:HandleGridLayer(index) end num = num + 1 if self.group_MiniMapOccupiedList[num] == nil then self.group_MiniMapOccupiedList[num] = TK2API.InstantiateObject(self.item_occupied.gameObject, self.img_map.transform, false):GetComponent(typeof(UnityEngine.UI.Image)) end UIUtils.SetLocalPosition(self.group_MiniMapOccupiedList[num], self:GetItemMiniMapPosition(index)) end end function UISlgGvEMain:RefreshOfficialInfo() local curOfficialLv = MDL.SlgGvE.GetCurOfficalLv() local curOfficialCfg = DataSheetManager.SlgGvEOfficialLevel:GetDataByOfficialTitleLevel(curOfficialLv) local curCompletedTaskNum = CTL.SlgGvE.GetOfficialReceivedTaskNum(curOfficialLv) local allTaskNum = #CTL.SlgGvE.GetOfficialLvTaskCfgList(curOfficialLv) local str = "%s:%s/%s" self.lab_task.text = string.format(str, UIUtils.GetLocalizedTxt(Const_IDS.IDS_SlgGve_Main_Hint_27), curCompletedTaskNum, allTaskNum) self.icon_fill.fillAmount = curCompletedTaskNum / allTaskNum self.task_btn:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Official)) UIUtils.SetImageByAssetBundle(self.icon_task, curOfficialCfg.OfficialTitleIcon) end function UISlgGvEMain:RefreshMaterialsGain() for i = 1, 3 do local itemId = CTL.SlgGvE.MaterialsItemId[i] UTL.Item.ItemSquareIcon(self.group_material[i].icon_material, nil, itemId) local itemNameAndDesc = UTL.Item.GetItemDataSpliceByType(itemId) self.group_material[i].lab_name.text = itemNameAndDesc.Name self.group_material[i].lab_num.text = string.FormatByIdsId(Const_IDS.IDS_SlgGve_Main_Hint_1, MDL.SlgGvE.GetMaterialGainSpeed(itemId)) end end function UISlgGvEMain:RefreshSeasonPrivilege() self.seasonPrivilegeLeftTime = MDL.SlgGvE.GetSeasonPrivilegeLeftTime() if self.seasonPrivilegeLeftTime > 0 then self:StopRepeatFunc(self.OnUpdateFun) self:StartRepeatFunc(self.OnUpdateFun, 1) UIUtils.SetActive(self.btn_season, true) UIUtils.SetLabel(self.privilege_time, UTL.Time.FormatTimeClockBySeconds(self.seasonPrivilegeLeftTime)) else UIUtils.SetActive(self.btn_season, false) UIUtils.SetActive(self.group_seasontips, false) end end function UISlgGvEMain:OnUpdateFun(deltaTime, timeSinceUpdate) if self.seasonPrivilegeLeftTime <= 0 then self:StopRepeatFunc(self.OnUpdateFun) UIUtils.SetActive(self.btn_season, false) UIUtils.SetActive(self.group_seasontips, false) else self.seasonPrivilegeLeftTime = self.seasonPrivilegeLeftTime - 1 UIUtils.SetLabel(self.privilege_time, UTL.Time.FormatTimeClockBySeconds(self.seasonPrivilegeLeftTime)) end end function UISlgGvEMain:RefreshSeasonTime() if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.Playing then self.time_State:SetState(0) local dayStr = string.FormatByIdsId(Const_IDS.IDS_SlgGve_Season_Hint_7, UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_1)) local hourStr = string.FormatByIdsId(Const_IDS.IDS_SlgGve_Season_Hint_7, UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_2)) local minStr = string.FormatByIdsId(Const_IDS.IDS_SlgGve_Season_Hint_7, UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_3)) local secStr = string.FormatByIdsId(Const_IDS.IDS_SlgGve_Season_Hint_7, UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_4)) self.time_countdown:SetDHMSStr(dayStr, hourStr, minStr, secStr) local time = MDL.SlgGvE.GetSeasonShowTime() - UTL.Time.GetServerTimestamp() self.time_countdown:ResetAndBeginCustomTimer(false, time, 0, 1) elseif MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.End then self.time_State:SetState(2) local dayStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_1) local hourStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_2) local minStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_3) local secStr = UIUtils.GetLocalizedTxt(Const_IDS.IDS_NewYearActivity_DirectGiftTimeHint_4) self.season_open_time:SetDHMSStr(dayStr, hourStr, minStr, secStr) local time = MDL.SlgGvE.GetSeasonStartTime() - UTL.Time.GetServerTimestamp() self.season_open_time:ResetAndBeginCustomTimer(false, time, 0, 1) else self.time_State:SetState(1) UIUtils.SetLabelText(self.time_showing, Const_IDS.IDS_SlgGve_Season_Hint_8) end --休赛期不播放特效 if MDL.SlgGvE.GetSeasonState() == MDL.SlgGvE.SeasonState.End then for i, v in ipairs(self.group_Effect) do v:StopUIEffect() end self:StopRepeatFunc(self.QueuePlayEffect) else self:QueuePlayEffect() self:StartRepeatFunc(self.QueuePlayEffect, Const_Effect_Interval, -1) end self:UpdateGridInfo() end function UISlgGvEMain:RefreshOccupiedLandNum() local occupiedLandNum = MDL.SlgGvE.GetMyOccupyGridCount() local str = occupiedLandNum .. "/" .. MDL.SlgGvE.GetPlotLimit() self.lab_OccupiedLand.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_SlgGve_Main_Hint_9) .. str end function UISlgGvEMain:RefreshEliteBossGrid() local occupiedCount, maxCount = MDL.SlgGvE.GetEliteBossGridCount() local str = occupiedCount .. "/" .. maxCount self.lab_Medal.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_SlgGve_Main_Hint_16) .. str end function UISlgGvEMain:RefreshTalentBtnRedpoint() self.btn_talent:SetRedPoint(CTL.RedPoint.GetRedPointActive(CTL.RedPoint.RedPointKey.Guild_Activity_SlgGvE_Talent)) end function UISlgGvEMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UISlgGvEMain:OnButtonClicked(comp) if self:ClickGridBtn(comp) == false then if self.selectGridIndex then self:CancelSelectGrid() end if comp == self.UITemplateTitlePanel.btn_close then self:CloseView() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then local banditDailyResetTime = MDL.SlgGvE.GetGvEConstData().BanditDailyResetTime local time1 = UTL.Time.GetLocalTimeDesc(banditDailyResetTime[1]) local time2 = UTL.Time.GetLocalTimeDesc(banditDailyResetTime[2]) local time3 = UTL.Time.GetLocalTimeDesc(MDL.SlgGvE.GetGvEConstData().BossStopTime1) local time4 = UTL.Time.GetLocalTimeDesc(MDL.SlgGvE.GetGvEConstData().BossStopTime2) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.SlgGvEMain, params = { time1, time2, time3, time4 }}) elseif comp == self.task_btn then UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvEOfficialMain) elseif comp == self.btn_season then UIUtils.SetActive(self.group_seasontips, true) UIUtils.SetActive(self.btn_CloseTips, true) elseif comp == self.btn_trade then 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.UISlgGvETradePanel) elseif comp == self.btn_talent then UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvETalentMain) elseif comp == self.btn_lineup then CTL.SlgGvE.OpenLineUp(CTL.SlgGvE.LineupEnterType.onlyLineUp) elseif comp == self.btn_Medal then UIUtils.SetActive(self.group_SiegeProgress, true) UIUtils.SetActive(self.btn_CloseTips, true) self.isOpenEliteBoss = true MDL.SlgGvE.CollectEliteBossGrids(self.eliteBossGrids) self.loop_SiegeProgress:ReloadAll(self.eliteBossGrids) CTL.SlgGvE.ClearMarkContentNotice() UIUtils.SetActive(self.group_NewInfoTips, CTL.SlgGvE.GetMarkContentNotice()) elseif comp == self.btn_OccupiedLand then UIUtils.SetActive(self.group_landtips, true) UIUtils.SetActive(self.btn_CloseTips, true) self.loop_landtips:ReloadAll(MDL.SlgGvE.GetSortedOccupiedGrids()) elseif comp == self.btn_event then local thiefIndex = MDL.SlgGvE.GetThiefGridInfo() self:OnSelectGridIndex(thiefIndex) if self.selectGridIndex ~= thiefIndex then self:SelectGrid(thiefIndex) end elseif comp == self.btn_CloseTips then UIUtils.SetActive(self.group_seasontips, false) UIUtils.SetActive(self.group_landtips, false) UIUtils.SetActive(self.group_SiegeProgress, false) self.isOpenEliteBoss = false self.isEditingId = nil UIUtils.SetActive(self.btn_CloseTips, false) elseif comp == self.head_defenders.item_head then self:OnSelectGridIndex(CTL.SlgGvE.GetMarkGridIndex()) self:HandleMarkGrid() elseif comp == self.event_Explain then UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvEIllustrate) elseif comp == self.btn_auction then UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UISlgGvEAuctionBase, nil, Const_UI_Lua.UIEnum.UIGuildAuctionBase) elseif comp == self.btn_EnlargeMap then CTL.SlgGvE.OpenMiniMap(self.showCenterIndex) elseif comp == self.btn_search then if UIManager.IsViewOpened(Const_UI_Lua.UIEnum.UISlgGvESearchTips) == false then UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvESearchTips) end elseif comp == self.btn_progress or comp == self.btn_progress1 then UIManager.OpenView(Const_UI_Lua.UIEnum.UISlgGvERank) end else UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvESearchTips) end end function UISlgGvEMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_landtips then local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(data.gveMapID) cellTable.lab_name.text = string.format(UIUtils.GetLocalizedTxt(Const_IDS[gridCfg.GveMapName]), gridCfg.GveMapLevel) local posX, posY = SLG_Utility.IndexToPosition(data.pointIndex) cellTable.lab_position.text = string.format("(%s,%s)", posX, posY) elseif scrollRect == self.loop_SiegeProgress then local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(data.gveMapID) UIUtils.SetImageByAssetBundle(cellTable.img_HeroHead, gridCfg.GveEnemypIcon) UIUtils.SetLabelText(cellTable.lab_name, Const_IDS[gridCfg.GveMapName]) cellTable.lab_power.text = string.FormatByIdsId(Const_IDS.IDS_Storm_FightCapacity, data.EnemyGS) cellTable.Fill.fillAmount = data.bossCurHp / data.bossMaxHp UIUtils.SetActive(cellTable.img_red, gridCfg.GveMapType == MDL.SlgGvE.GridType.Boss) if data.hasOccupy and not data.hasEnemy then UIUtils.SetGray(cellTable.img_HeroHead, true) else UIUtils.SetGray(cellTable.img_HeroHead, false) end if gridCfg.IsDisplayResetTime and data.resetDeadLine > 0 then cellTable.state_occupied:SetState(0) local offset = data.resetDeadLine - UTL.Time.GetServerTimestamp() if offset > 0 then cellTable.lab_time:ResetAndBeginCustomTimer(false, offset, 0, "{0}:{1}:{2}", 1) else cellTable.lab_time:EndTimer() end else cellTable.state_occupied:SetState(1) end if CTL.SlgGvE.GetMarkGridIndex() then local _, info = MDL.SlgGvE.GetGridInfo(CTL.SlgGvE.GetMarkGridIndex()) if data.gveMapID == info.gveMapID then UIUtils.SetActive(cellTable.icon_mark, true) else UIUtils.SetActive(cellTable.icon_mark, false) end else UIUtils.SetActive(cellTable.icon_mark, false) end --编辑 if self.isEditingId == data.gveMapID then cellTable.obj_InputField.enabled = true cellTable.obj_InputField.characterLimit = FONT_LIMIT UIUtils.SetActive(cellTable.group_mask, true) UIUtils.SetLabelText(cellTable.Placeholder, Const_IDS.IDS_SlgGve_Redact_Hint_1) UIUtils.SetActive(cellTable.group_Btn, true) UIUtils.SetActive(cellTable.btn_1, true) UIUtils.SetLabelText(cellTable.lab_1, Const_IDS.IDS_Btn_Save) UIUtils.SetActive(cellTable.btn_2, true) UIUtils.SetLabelText(cellTable.lab_2, Const_IDS.IDS_Cancel) else cellTable.obj_InputField.enabled = false cellTable.obj_InputField.characterLimit = 0 if string.isNilOrEmpty(data.markContent) then UIUtils.SetActive(cellTable.group_mask, false) else UIUtils.SetActive(cellTable.group_mask, true) cellTable.obj_InputField.text = data.markContent end if self.hasEditGridPermission == false then UIUtils.SetActive(cellTable.group_Btn, false) else UIUtils.SetActive(cellTable.group_Btn, true) if string.isNilOrEmpty(data.markContent) then UIUtils.SetActive(cellTable.btn_1, true) UIUtils.SetLabelText(cellTable.lab_1, Const_IDS.IDS_HeroMatch3v3_Edit) UIUtils.SetActive(cellTable.btn_2, false) else UIUtils.SetActive(cellTable.btn_1, true) UIUtils.SetLabelText(cellTable.lab_1, Const_IDS.IDS_HeroMatch3v3_Edit) UIUtils.SetActive(cellTable.btn_2, true) UIUtils.SetLabelText(cellTable.lab_2, Const_IDS.IDS_SlgGve_Redact_Hint_5) end end end end end function UISlgGvEMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_landtips then if target == cellTable.btn_position then self:OnSelectGridIndex(data.pointIndex) end elseif scrollRect == self.loop_SiegeProgress then if target == cellTable.btn_go then self:OnSelectGridIndex(MDL.SlgGvE.GetEliteBossGridIndex(data.gveMapID)) self:HandleMarkGrid() elseif target == cellTable.item_head then if CTL.SlgGvE.GetMarkGridIndex() then local _, info = MDL.SlgGvE.GetGridInfo(CTL.SlgGvE.GetMarkGridIndex()) if data.gveMapID == info.gveMapID then CTL.SlgGvE.MarkGridIndex(nil, true) else CTL.SlgGvE.MarkGridIndex(MDL.SlgGvE.GetEliteBossGridIndex(data.gveMapID), true) end else CTL.SlgGvE.MarkGridIndex(MDL.SlgGvE.GetEliteBossGridIndex(data.gveMapID), true) end self.loop_SiegeProgress:RefreshCells(false) self:HandleMarkGrid() elseif target == cellTable.btn_1 then if self.isEditingId == data.gveMapID then local input = cellTable.obj_InputField.text local length = UTL.String.GetStrLen(input) if length > NUM_EDIT_LIMIT then CTL.Tips.AddTipsMsg(Const_IDS.IDS_LiaoTian_Longtext) return end CTL.SlgGvE.AddMarkContent(data.gveMapID, input) MDL.SlgGvE.GVELandMarkReq(data.gveMapID, input) self.isEditingId = nil else if string.isNilOrEmpty(data.markContent) then cellTable.obj_InputField.text = nil end self.isEditingId = data.gveMapID end self.loop_SiegeProgress:RefreshCells(false) elseif target == cellTable.btn_2 then if self.isEditingId == data.gveMapID then self.isEditingId = nil self.loop_SiegeProgress:RefreshCells(false) else UTL.MessageBox.ShowOKCancelBox(nil, Const_IDS.IDS_SlgGve_Redact_Hint_3, function() MDL.SlgGvE.GVELandMarkReq(data.gveMapID, "") end, nil) end end end end function UISlgGvEMain:OnClosed() MDL.SlgGvE.GVEMainPanelReq(false) self:RestoreSound() UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvESearchTips) end function UISlgGvEMain:RestoreSound() CTL.Sound.PlayGameSound("amb_resume") CTL.Sound.StopGameSound("SFX_hanzhong") if BattleDataGetter.IsOnlineTownLevel() then CTL.Sound.ResumeLevelSound() end end function UISlgGvEMain:InitSLGParam() local screenX, screenY = UIUtils.UIRoot:GetSizeDelta() self.dragLimitUILeftValue, self.dragLimitUIRightValue, self.dragLimitUITopValue, self.dragLimitUIBottomValue = CTL.SlgGvE.GetLimitRectPosition() --计算好阈值,减少判断重复计算 self.dragLimitUILeftValue = self.dragLimitUILeftValue + screenX / 2 self.dragLimitUIRightValue = self.dragLimitUIRightValue - screenX / 2 self.dragLimitUITopValue = self.dragLimitUITopValue - screenY / 2 self.dragLimitUIBottomValue = self.dragLimitUIBottomValue + screenY / 2 --根据分辨率计算出一屏所需的行列数 self.horizontalMaxNum = math.ceil(screenX / ITEM_WIDTH) + 6 --两边各预留3列 self.verticalMaxNum = math.ceil(screenY / ITEM_HEIGHT) + 6 --判断是否在视野中的坐标值 self.viewLeftPosX = -screenX / 2 self.viewRightPosX = screenX / 2 self.viewTopPosY = screenY / 2 self.viewBottomPosY = -screenY / 2 --中心点的UI位置 local uiX, uiY = SLG_Utility.PositionToUIPosition(MDL.SlgGvE.GRID_SIZE / 2, MDL.SlgGvE.GRID_SIZE / 2) self.middleIndexPosX = uiX self.middleIndexPosY = uiY --小地图的缩放比例 local bgWidth, bgHeight = self.img_map.transform:GetSizeDelta() self.scaleRate_X = (bgWidth - 4) / CTL.SlgGvE.MiniMap_WIDTH self.scaleRate_Y = (bgHeight - 20) / CTL.SlgGvE.MiniMap_HEIGHT self.miniMapMiddlePosX, self.miniMapMiddlePosY = UTL.SLG.PositionToUnitUIPosition(MDL.SlgGvE.GRID_SIZE / 2, MDL.SlgGvE.GRID_SIZE / 2) end function UISlgGvEMain:UpdateMiniMapBoss() MDL.SlgGvE.CollectEliteBossGrids(self.eliteBossGrids) local templateObj = self.group_boss[1].gameObject for index, v in ipairs(self.eliteBossGrids) do local cfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(v.gveMapID) local item = self.group_boss[index] if item == nil then item = self:InstantiateCollection(self.group_boss, templateObj) end local index = MDL.SlgGvE.GetEliteBossGridIndex(cfg.GveMapID) UIUtils.SetLocalPosition(item.gameObject, self:GetItemMiniMapPosition(index)) if cfg.GveMapType == MDL.SlgGvE.GridType.Boss then item.state_image:SetState(1) UIUtils.SetImageByAssetBundle(item.img_HeroHeadBg02, cfg.CityIcon) else item.state_image:SetState(0) UIUtils.SetImageByAssetBundle(item.img_HeroHeadBg, cfg.CityIcon) end end end function UISlgGvEMain:IsInDragLimit(targetUIPosX, targetUIPosY) if -targetUIPosX <= self.dragLimitUILeftValue or -targetUIPosX >= self.dragLimitUIRightValue then return true end if -targetUIPosY <= self.dragLimitUIBottomValue or -targetUIPosY >= self.dragLimitUITopValue then return true end return false end function UISlgGvEMain:OnDrag(comp, eventData) local x = eventData.delta.x * DragOffset local y = eventData.delta.y * DragOffset if x == 0 and y == 0 then return end local oriPosX, oriPosY = self.dragRoot:GetLocalPosition() local tarUIPosX, tarUIPosY = oriPosX + x, oriPosY + y if self:IsInDragLimit(tarUIPosX, tarUIPosY) then return end local tarX, tarY = self.moveCenterX - x, self.moveCenterY - y self:HandleDragOffset(tarX, tarY, tarUIPosX, tarUIPosY) self:HandleEffectPos(true) end function UISlgGvEMain:OnEndDrag() self:HandleEffectPos(false) self:HandleMarkGrid() end function UISlgGvEMain:ClickGridBtn(comp) for gridIndex, v in pairs(self.viewGridCollectionDict[CTL.SlgGvE.LayerType.Btn]) do if v.Button == comp then local type, info, middleIndex = MDL.SlgGvE.GetGridInfo(gridIndex) if self.selectGridIndex == gridIndex or self.selectGridIndex == middleIndex then self:CancelSelectGrid() else if middleIndex > 0 then self:SelectGrid(middleIndex) else self:SelectGrid(gridIndex) end end return true end end return false end --取消选中格子 function UISlgGvEMain:CancelSelectGrid() self.gridTipsView:CloseAll() self:HandleSelectUI(false) self.selectGridIndex = nil UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvESearchTips) end --选中格子 function UISlgGvEMain:SelectGrid(index) self.selectGridIndex = index self:HandleSelectUI(true, index) if self.gridTipsView:IsViewOpened(Const_UI_Lua.UIEnum.UISlgGvETips) then EventSystem.Dispatch(EventID.UI_SlgGve_UpdateGridTips, index) else self.gridTipsView:OpenView(GetViewClass(Const_UI_Lua.UIEnum.UISlgGvETips), { gridIndex = index }) end local oriPosX, oriPosY = self.dragRoot:GetLocalPosition() EventSystem.Dispatch(EventID.UI_SlgGve_RefreshGridTipsPos, oriPosX, oriPosY) end function UISlgGvEMain:HandleSelectUI(state, index) if state == false then for i, v in ipairs(self.obj_GridSelectList) do UIUtils.SetParent(v, self.group_Select) end else for i, v in ipairs(self.obj_GridSelectList) do UIUtils.SetParent(v, self.group_Select) end local set = MDL.SlgGvE.TryGetLinkedGridSet(index) if set == nil then self:SetGridUI(self.obj_GridSelectList[1], self.group_LastSibling, index) else local count = 0 for i, v in pairs(set) do local grid = self.viewGridCollectionDict[CTL.SlgGvE.LayerType.Btn][i] if grid then count = count + 1 if count > #self.obj_GridSelectList then local cloneSelectObj = TK2API.InstantiateObject(self.obj_GridSelect.gameObject, self.group_LastSibling, false):GetComponent(typeof(UnityEngine.UI.Image)) table.insert(self.obj_GridSelectList, cloneSelectObj) end self:SetGridUI(self.obj_GridSelectList[count], self.group_LastSibling, i) end end end end end function UISlgGvEMain:HandleDragOffset(tarCenterX, tarCenterY, tarUIPosX, tarUIPosY) local newCenterIndex = SLG_Utility.GetNextCenterIndex(self.showCenterIndex, tarCenterX, tarCenterY) self.dragRoot:SetLocalPosition(tarUIPosX, tarUIPosY) self.moveCenterX = tarCenterX self.moveCenterY = tarCenterY self:UpdateViewGrids(newCenterIndex) self.showCenterIndex = newCenterIndex UIUtils.SetLocalPosition(self.item_pos, self:GetItemMiniMapPosition(self.showCenterIndex)) EventSystem.Dispatch(EventID.UI_SlgGve_RefreshGridTipsPos, tarUIPosX, tarUIPosY) end function UISlgGvEMain:UpdateGridInfo() self:UpdateMiniMapBoss() for gridIndex, _ in pairs(self.indexLayerTypeMapping) do self:HandleGridLayer(gridIndex) end self:RefreshEliteBossGrid() if self.isOpenEliteBoss == true then MDL.SlgGvE.CollectEliteBossGrids(self.eliteBossGrids) self.loop_SiegeProgress:ReloadAll(self.eliteBossGrids) end UIUtils.SetActive(self.group_NewInfoTips, CTL.SlgGvE.GetMarkContentNotice()) end function UISlgGvEMain:OnSelectGridIndex(index) index = self:TryFindNearestCenterIndex(index) local posX, posY = SLG_Utility.PositionToUIPosition(SLG_Utility.IndexToPosition(index)) self.showCenterIndex = index self:UpdateViewGrids(index) self.moveCenterX, self.moveCenterY = posX, posY self.dragRoot:SetLocalPosition(-posX, -posY) self:HandleMarkGrid() UIUtils.SetLocalPosition(self.item_pos, self:GetItemMiniMapPosition(self.showCenterIndex)) CTL.Sound.PlayGameSound("UI_click_add") end function UISlgGvEMain:TryFindNearestCenterIndex(index) local posX, posY = SLG_Utility.PositionToUIPosition(SLG_Utility.IndexToPosition(index)) if self:IsInDragLimit(-posX, -posY) == false then return index end local offsetX, offsetY if posX >= self.middleIndexPosX and posY >= self.middleIndexPosY then offsetX = -ITEM_WIDTH offsetY = -ITEM_HEIGHT elseif posX >= self.middleIndexPosX and posY < self.middleIndexPosY then offsetX = -ITEM_WIDTH offsetY = ITEM_HEIGHT elseif posX < self.middleIndexPosX and posY >= self.middleIndexPosY then offsetX = ITEM_WIDTH offsetY = -ITEM_HEIGHT elseif posX < self.middleIndexPosX and posY < self.middleIndexPosY then offsetX = ITEM_WIDTH offsetY = ITEM_HEIGHT end return self:TryFindNearestCenterIndex(SLG_Utility.GetNextCenterIndex(index, posX + offsetX, posY + offsetY)) end function UISlgGvEMain:UpdateViewGrids(centerIndex) if SLG_Utility.CollectGridsByCenterIndex(centerIndex, self.horizontalMaxNum, self.verticalMaxNum, self.sourceGridContainer) then self:HandleGrids(self.sourceGridContainer) end end function UISlgGvEMain:HandleMarkGrid() local markGridIndex = CTL.SlgGvE.GetMarkGridIndex() if markGridIndex then local res, x2, y2 = self:CheckGridInScreen(markGridIndex) if res == false then UIUtils.SetActive(self.markGridTf, true) local _, info = MDL.SlgGvE.GetGridInfo(markGridIndex) local gridCfg = DataSheetManager.SlgGvEPlotData:GetDataByGveMapID(info.gveMapID) UIUtils.SetImageByAssetBundle(self.head_defenders.img_HeroHead, gridCfg.GveEnemypIcon) local tarPosX, tarPosY = self:GetMarkGridPosition(x2, y2) self.markGridTf:SetLocalPosition(tarPosX, tarPosY, 0) return end end UIUtils.SetActive(self.markGridTf, false) end function UISlgGvEMain:GetMarkGridPosition(x2, y2) local oriPosX, oriPosY = self.dragRoot:GetLocalPosition() local x1 = 0 local y1 = 0 x2 = oriPosX + x2 y2 = oriPosY + y2 if x1 == x2 then if y2 >= y1 then return x1, self.viewTopPosY - Offset_Mark else return x1, self.viewBottomPosY + Offset_Mark end end if y1 == y2 then if x2 >= x1 then return self.viewRightPosX - Offset_Mark, y1 else return self.viewLeftPosX + Offset_Mark, y1 end end --由两点求线性方程 local k = (y2 - y1) / (x2 - x1) local b = y2 - k * x2 if y2 > y1 and x2 > x1 then local y3 = k * self.viewRightPosX + b if y3 <= self.viewTopPosY then return self.viewRightPosX - Offset_Mark, y3 - Offset_Mark else return (self.viewTopPosY - b) / k - Offset_Mark, self.viewTopPosY - Offset_Mark end elseif y2 > y1 and x2 < x1 then local y3 = k * self.viewLeftPosX + b if y3 <= self.viewTopPosY then return self.viewLeftPosX + Offset_Mark, y3 - Offset_Mark else return (self.viewTopPosY - b) / k + Offset_Mark, self.viewTopPosY - Offset_Mark end elseif y2 < y1 and x2 > x1 then local y3 = k * self.viewRightPosX + b if y3 >= self.viewBottomPosY then return self.viewRightPosX - Offset_Mark, y3 + Offset_Mark else return (self.viewBottomPosY - b) / k - Offset_Mark, self.viewBottomPosY + Offset_Mark end elseif y2 < y1 and x2 < x1 then local y3 = k * self.viewLeftPosX + b if y3 >= self.viewBottomPosY then return self.viewLeftPosX + Offset_Mark, y3 + Offset_Mark else return (self.viewBottomPosY - b) / k + Offset_Mark, self.viewBottomPosY + Offset_Mark end end end --判断视野内有没有这个格子 function UISlgGvEMain:CheckGridInScreen(index) local gridUIPosX, gridUIPosY = SLG_Utility.PositionToUIPosition(SLG_Utility.IndexToPosition(index)) local result = false if self.indexLayerTypeMapping[index] then local oriPosX, oriPosY = self.dragRoot:GetLocalPosition() local x = gridUIPosX + oriPosX local y = gridUIPosY + oriPosY if (x + ITEM_WIDTH / 2) < self.viewLeftPosX then result = false elseif (x - ITEM_WIDTH / 2) > self.viewRightPosX then result = false elseif (y - ITEM_HEIGHT / 2) > self.viewTopPosY then result = false elseif (y + ITEM_HEIGHT / 2) < self.viewBottomPosY then result = false else result = true end end return result, gridUIPosX, gridUIPosY end function UISlgGvEMain:HandleGrids(gridIndexSet) --先将本次视野用不到的旧格子放回pool for gridIndex, type in pairs(self.indexLayerTypeMapping) do local layerType = type if gridIndexSet[gridIndex] == nil then --将这个格子的所有layer资源放回pool for i, v in pairs(CTL.SlgGvE.LayerType) do if bit.band(layerType, v) then self:SetGridToPool(v, gridIndex) end end end end for gridIndex, _ in pairs(gridIndexSet) do self:HandleGridLayer(gridIndex) end end function UISlgGvEMain:HandleGridLayer(gridIndex) local x, y = SLG_Utility.PositionToUIPosition(SLG_Utility.IndexToPosition(gridIndex)) self:HandleBtn(gridIndex, x, y) self:HandleAtlasIcon(gridIndex, x, y) self:HandleImageIcon(gridIndex, x, y) self:HandleFrame(gridIndex, x, y) self:HandleAttackingExp(gridIndex, x, y) self:HandleBloodTimer(gridIndex, x, y) end function UISlgGvEMain:HandleBtn(gridIndex, posX, posY) local type = CTL.SlgGvE.LayerType.Btn local result = CTL.SlgGvE.GetGridParam(gridIndex, type) if result == false then self:SetGridToPool(type, gridIndex) else local grid = self:GetGridFromView(type, gridIndex) if grid == nil then grid = self:GetGridFromPool(type, self.layer_Btn) local gridTf = grid.gameObject.transform self:SetGridToView(type, gridIndex, grid) UIUtils.SetParent(gridTf, self.btnLayerTf) UIUtils.SetLocalPosition(gridTf, posX, posY, 0) end end end function UISlgGvEMain:HandleAtlasIcon(gridIndex, posX, posY) self:HandleImage(CTL.SlgGvE.LayerType.AtlasIcon, gridIndex, posX, posY, self.layer_Atlas) end function UISlgGvEMain:HandleImageIcon(gridIndex, posX, posY) self:HandleImage(CTL.SlgGvE.LayerType.ImageIcon, gridIndex, posX, posY, self.layer_Image) end function UISlgGvEMain:HandleFrame(gridIndex, posX, posY) self:HandleImage(CTL.SlgGvE.LayerType.Frame, gridIndex, posX, posY, self.layer_Frame) end function UISlgGvEMain:HandleImage(type, gridIndex, posX, posY, parentTf) local result, param = CTL.SlgGvE.GetGridParam(gridIndex, type) if result == false then self:SetGridToPool(type, gridIndex) else local grid = self:GetGridFromView(type, gridIndex) if grid == nil then grid = self:GetGridFromPool(type, parentTf) self:SetGridToView(type, gridIndex, grid) UIUtils.SetParent(grid, parentTf) UIUtils.SetLocalPosition(grid, posX, posY, 0) end local path = self.imagePathDict[type][gridIndex] if path ~= param then UIUtils.SetImageByAssetBundle(grid, param) self.imagePathDict[type][gridIndex] = param end if type == CTL.SlgGvE.LayerType.Frame then grid.transform:SetSizeDelta(FRAME_WIDTH, FRAME_HEIGHT) else grid:SetNativeSize() end end end function UISlgGvEMain:HandleAttackingExp(gridIndex, posX, posY) self:HandleImage(CTL.SlgGvE.LayerType.AttackingExp, gridIndex, posX, posY, self.layer_AttackingExp) end function UISlgGvEMain:HandleBloodTimer(gridIndex, posX, posY) local type = CTL.SlgGvE.LayerType.BloodTimer local result, time, desc, maxHp, curHp, nameContent, scaleType = CTL.SlgGvE.GetGridParam(gridIndex, type) if result == false then self:SetGridToPool(type, gridIndex) else local grid = self:GetGridFromView(type, gridIndex) if grid == nil then grid = self:GetGridFromPool(type, self.layer_BloodTimer) local gridTf = grid.gameObject.transform self:SetGridToView(type, gridIndex, grid) UIUtils.SetParent(gridTf, self.bloodTimerTf) UIUtils.SetLocalPosition(gridTf, posX, posY, 0) end --倒计时 if time > 0 then UIUtils.SetActive(grid.img_time, true) UIUtils.SetLabelText(grid.lab_title, desc) local offset = time - UTL.Time.GetServerTimestamp() if offset > 0 then grid.lab_time:ResetAndBeginCustomTimer(false, offset, 0, "{0}:{1}:{2}", 1) end else UIUtils.SetActive(grid.img_time, false) end --血条 if maxHp > 0 then UIUtils.SetActive(grid.group_Progress, true) local rate = curHp / maxHp grid.lab_num.text = string.format("%.2f%%", (rate) * 100) grid.progress.fillAmount = rate else UIUtils.SetActive(grid.group_Progress, false) end --名字坐标 if not string.isNilOrEmpty(nameContent) then UIUtils.SetActive(grid.group_main, true) grid.lab_content.text = nameContent else UIUtils.SetActive(grid.group_main, false) end if scaleType then grid.state_progress:SetState(scaleType) end end end function UISlgGvEMain:GetGridFromView(layerType, gridIndex) if CTL.SlgGvE.CollectionLayerType[layerType] then return self.viewGridCollectionDict[layerType][gridIndex] else return self.viewGridInstanceDict[layerType][gridIndex] end end function UISlgGvEMain:SetGridToView(layerType, gridIndex, grid) if CTL.SlgGvE.CollectionLayerType[layerType] then self.viewGridCollectionDict[layerType][gridIndex] = grid else self.viewGridInstanceDict[layerType][gridIndex] = grid end --按位操作来处理枚举 local layer = self.indexLayerTypeMapping[gridIndex] if grid then if layer == nil then layer = layerType else layer = bit.bor(layer, layerType) end else layer = bit.band(layer, bit.bnot(layerType)) if layer == 0 then layer = nil end end self.indexLayerTypeMapping[gridIndex] = layer end function UISlgGvEMain:GetGridFromPool(layerType, parentTf) local grid if CTL.SlgGvE.CollectionLayerType[layerType] then grid = table.remove(self.poolGridCollectionDict[layerType]) else grid = table.remove(self.poolGridInstanceDict[layerType]) end if grid == nil then grid = self:InstantiateObject(parentTf, layerType) end return grid end function UISlgGvEMain:SetGridToPool(layerType, gridIndex) local grid = self:GetGridFromView(layerType, gridIndex) if grid then if CTL.SlgGvE.CollectionLayerType[layerType] then table.insert(self.poolGridCollectionDict[layerType], grid) UIUtils.SetParent(grid.gameObject.transform, self.gridPool) else table.insert(self.poolGridInstanceDict[layerType], grid) UIUtils.SetParent(grid, self.gridPool) end self:SetGridToView(layerType, gridIndex, nil) if CTL.SlgGvE.ImageLayerType[layerType] then self.imagePathDict[layerType][gridIndex] = nil end end end function UISlgGvEMain:InstantiateObject(parentTf, layerType) if CTL.SlgGvE.ImageLayerType[layerType] == 1 then return TK2API.InstantiateObject(self.templateImageObj, parentTf, false):GetComponent(typeof(UnityEngine.UI.Image)) elseif CTL.SlgGvE.ImageLayerType[layerType] == 2 then return TK2API.InstantiateObject(self.templateHalfImageObj, parentTf, false):GetComponent(typeof(UnityEngine.UI.Image)) elseif layerType == CTL.SlgGvE.LayerType.Btn then return self:InstantiateCollection(parentTf, self.templateButtonObj) elseif layerType == CTL.SlgGvE.LayerType.BloodTimer then return self:InstantiateCollection(parentTf, self.templateBloodTimerObj) end end function UISlgGvEMain:SetGridUI(source, parent, index) UIUtils.SetParent(source, parent) local posX, posY = SLG_Utility.PositionToUIPosition(SLG_Utility.IndexToPosition(index)) UIUtils.SetLocalPosition(source, posX, posY, 0) end function UISlgGvEMain:GetItemMiniMapPosition(index) local x, y = SLG_Utility.IndexToPosition(index) local posX, posY = SLG_Utility.PositionToUnitUIPosition(x, y) return (posX - self.miniMapMiddlePosX + DISTANCE_OFFSET) * self.scaleRate_X, (posY - self.miniMapMiddlePosY) * self.scaleRate_Y, 0 end --小地图坐标值转换为格子逻辑位置索引 function UISlgGvEMain:TransUnitUIPositionToGridIndex(posX, posY) local x, y = posX, posY x = x / self.scaleRate_X - DISTANCE_OFFSET + self.miniMapMiddlePosX y = y / self.scaleRate_Y + self.miniMapMiddlePosY return SLG_Utility.PositionToIndex(SLG_Utility.UnitUIPositionToPosition(x, y)) end function UISlgGvEMain:OnPointerDown(comp, eventData) local x, y = UIUtils.GetPositionBasedOnWidth(comp.transform, UnityEngine.Input.mousePosition, nil, nil, nil) local index = self:TransUnitUIPositionToGridIndex(x, y) self:CancelSelectGrid() UIManager.CloseView(Const_UI_Lua.UIEnum.UISlgGvESearchTips) self:OnSelectGridIndex(index) end function UISlgGvEMain:HandleEffectPos(isDragging) if isDragging then if self.isEffectMiddle then self.isEffectMiddle = false UIUtils.SetParent(self.effectTf, self.group_FirstSibling) self:StopRepeatFunc(self.QueuePlayEffect) end else if self.isEffectMiddle == false then self.isEffectMiddle = true UIUtils.SetParent(self.effectTf, self.gameObject.transform) self.effectTf:SetLocalPosition(0, 0) self:QueuePlayEffect() self:StartRepeatFunc(self.QueuePlayEffect, Const_Effect_Interval, -1) end end end function UISlgGvEMain:QueuePlayEffect() for i, v in ipairs(self.group_Effect) do v:StopUIEffect() end --随机3个特效播放 local index_1, index_2, index_3 = self:GetRandomIndex() self.group_Effect[index_3]:PlayUIEffect(Const_Effect_Paths[index_1], -1) self.group_Effect[index_2]:PlayUIEffect(Const_Effect_Paths[index_2], -1) self.group_Effect[index_1]:PlayUIEffect(Const_Effect_Paths[index_3], -1) end function UISlgGvEMain:GetRandomIndex() math.randomseed(os.time()) local index_1, index_2, index_3 = 0, 0, 0 index_1 = math.random(1, #Const_Effect_Paths) while(index_2 == 0) do local n = math.random(1, #Const_Effect_Paths) if n ~= index_1 then index_2 = n end end while(index_3 == 0) do local n = math.random(1, #Const_Effect_Paths) if n ~= index_1 and n ~= index_2 then index_3 = n end end return index_1, index_2, index_3 end function UISlgGvEMain:OnOpenGridTips(index) self:SelectGrid(index) end return UISlgGvEMain