local EventSystem = require('Event/EventSystem') local UISceneControllerPanel = UIViewClass() local freeCamPattern = "HomeMsgBg" local limitCamPattern = "HomeMsgBg" local CONST_SCALE_THRESHOLD = 2 local CAMERA_POS = {x = 761.2, y = -85.90002} function UISceneControllerPanel:OnCreated() self.CameraCtrl = CameraController.Instance self.isFocus = false end function UISceneControllerPanel:OnOpened() self:RegistTriggerEvent(self.event_SceneController, UIEventTriggerType.PointerDown) self:RegistTriggerEvent(self.event_SceneController, UIEventTriggerType.Drag) self:RegistTriggerEvent(self.event_SceneController, UIEventTriggerType.EndDrag) self:RegistSystemEvent(EventID.UI_KeyboardControl_Rotating, self.RotatingByKeyboard) self:RegistSystemEvent(EventID.UI_EnterCheatModel, self.EnterCheatModel) self:RegistSystemEvent(EventID.TimeLine_Update, self.OnTimeLine) self:RegistSystemEvent(EventID.Camera_ScalingCameraByManual, self.ScalingCameraByManual) self:RegistSystemEvent(EventID.UI_Close_DownloadEntry, self.OnDownloadEntryClose) --分包下载 if DEF.OPEN_STAGE_DOWNLOAD then if BattleDataGetter.IsTownLevel() then self.progressMat = self.img_ProgressFrame_Complete.material self:OnDownloadInit() --分包下载入口按钮 self:UpdateDownloadShow() else UIUtils.SetActive(self.event_Download, false) end else UIUtils.SetActive(self.event_Download, false) end end function UISceneControllerPanel:OnFocusChanged(value) self.isFocus=value end function UISceneControllerPanel:OnClosed() self:UnRegistDownloadEvents() end function UISceneControllerPanel:OnTimeLine(value) if value then self:EnableInput() else self:DisableInput() end end function UISceneControllerPanel:ScalingCameraByManual(isEnlarge) if self.isFocus then self.CameraCtrl:ScalingByManual(isEnlarge) end end --endregion Scene Camera function UISceneControllerPanel:OnClickScene(eventdata) local colliderSystem = ColliderSystem.GetClickColliderSystem(eventdata) if colliderSystem then EventSystem.Dispatch(EventID.OnClickSceneColliderSystem,colliderSystem) end if LevelManager.IsNoBattleLevel() and not BattleDataGetter.CheckCurLevelType(LuaConst.LevelType.DragonArteryRegistArea) then local entityList = AuxUtil.GetEventEntityIDs(eventdata) if entityList then --点击NPC local entityID = entityList[0] if entityID and entityID > 0 then local entity = BattleDataGetter.GetEntityByEntityID(entityID) --有可能点击的不是一个entity,关卡种的假人,加个判空保护 if entity then EventSystem.Dispatch(entity.Event_EntityVisited, entity) end end end --玩家交互 CTL.PlayerInteract.OnClickPlayer(entityList) end end function UISceneControllerPanel:DoDragIn(eventdata) if not self.m_Pointer_One then self.m_Pointer_One = eventdata self.position1 = {} self.delta = {} elseif not self.m_Pointer_Two and self.m_Pointer_One ~= eventdata then self.m_Pointer_Two = eventdata self.position2 = {} end --缩放 if self.m_Pointer_One and self.m_Pointer_Two then UIUtils.GetEventDataPosition(self.m_Pointer_One,self.position1) self.position1.x,self.position1.y = self.position1[1],self.position1[2] UIUtils.GetEventDataPosition(self.m_Pointer_Two,self.position2) self.position2.x,self.position2.y = self.position2[1],self.position2[2] self.oldDistance = self.oldDistance or Vector2.Distance(self.position1,self.position2) local newDistance = Vector2.Distance(self.position1,self.position2) if math.abs(newDistance-self.oldDistance) < CONST_SCALE_THRESHOLD then return end self.CameraCtrl:ScalingByManual(self.oldDistance 1024 then --大于1024K,显示M maxSizeShow = math.ceil(maxSize / 1024) sizeShowType = 1 else maxSizeShow = maxSize sizeShowType = 0 end if sizeShowType == 0 then self.lab_DownloadDebug.text = string.format("%s(%sK/%sK)", UIUtils.GetLocalizedTxt(Const_IDS.IDS_LoginDownload), curSize, maxSizeShow) else self.lab_DownloadDebug.text = string.format("%s(%.2fM/%sM)", UIUtils.GetLocalizedTxt(Const_IDS.IDS_LoginDownload), curSize / 1024, maxSizeShow) end end end function UISceneControllerPanel:OnDownloadEntryClose() self:UnRegistDownloadEvents() UIUtils.SetActive(self.event_Download, false) end function UISceneControllerPanel:OnDownloadInit() if CTL.HotFix.Get_IfAllDownload() == false then self.progressMat:SetFloat("_Percent", 0) self.maxDownloadSize = CTL.HotFix.GetStage2TotalDownloadSize() self.hasDownloadSize = CTL.HotFix.GetStage2DownloadedSize(LoginProxy.GetCurStage()) end end function UISceneControllerPanel:UpdateDownloadBtn() self.hasDownloadSize = CTL.HotFix.GetStage2DownloadedSize(LoginProxy.GetCurStage()) if LoginProxy.Get_IsDownloading() then self.state_download:SetState(0) UIUtils.SetLabelText(self.lab_Download, Const_IDS.IDS_StagePackage_Downloading) else self.state_download:SetState(1) UIUtils.SetLabelText(self.lab_Download, Const_IDS.IDS_StagePackage_TimeOut) end end function UISceneControllerPanel:UnRegistDownloadEvents() EventSystem.UnRegist(EventID.UI_Loading_UpdateDownloadProgress, self.UpdateProgress, self) EventSystem.UnRegist(EventID.Pause_Download, self.UpdateDownloadBtn, self) EventSystem.UnRegist(EventID.Resume_Download, self.UpdateDownloadBtn, self) EventSystem.UnRegist(EventID.UI_StagePackage_AllDownload, self.UpdateDownloadShow, self) EventSystem.UnRegist(EventID.UpdateDownloadState, self.UpdateDownloadBtn, self) end function UISceneControllerPanel:UpdateDownloadShow() if DEF.OPEN_STAGE_DOWNLOAD then local hasEntry = false if CTL.HotFix.Get_IfAllDownload() and MDL.HotFix.Get_HasStagePackageAward() then UIUtils.SetActive(self.event_Download, false) else UIUtils.SetActive(self.event_Download, true) if CTL.HotFix.Get_IfAllDownload() then self.progressMat:SetFloat("_Percent", 1) self.state_download:SetState(2) self.event_Download:SetRedPoint(true) UIUtils.SetLabelText(self.lab_Download, Const_IDS.IDS_StagePackage_DownloadState_Completed) else self.event_Download:SetRedPoint(false) self:UpdateDownloadBtn() hasEntry = true end end if hasEntry then EventSystem.Regist(EventID.UI_Loading_UpdateDownloadProgress, self.UpdateProgress, self) EventSystem.Regist(EventID.Pause_Download, self.UpdateDownloadBtn, self) EventSystem.Regist(EventID.Resume_Download, self.UpdateDownloadBtn, self) EventSystem.Regist(EventID.UI_StagePackage_AllDownload, self.UpdateDownloadShow, self) EventSystem.Regist(EventID.UpdateDownloadState, self.UpdateDownloadBtn, self) else self:UnRegistDownloadEvents() end else UIUtils.SetActive(self.event_Download, false) end end --endregion function UISceneControllerPanel:EnterCheatModel(isEnter) UIUtils.SetGraphicRaycasterEnable(self.gameObject.gameObject, true) end return UISceneControllerPanel