void Update() { if (Input.GetKeyDown(KeyCode.Space)) { if (PUIManager.IsCurrentUI <PMapUI>()) { PUIManager.GetUI <PMapUI>().Space(); } } if (Input.GetMouseButtonDown(1)) { MouseRightButtonDown = true; if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>())) { PUIManager.AddNewUIAction("启动右键拖拽", () => { PUIManager.GetUI <PMapUI>().CameraController.StopTracking(); LastMousePosition = Input.mousePosition; }); } } if (Input.GetMouseButtonUp(1)) { MouseRightButtonDown = false; } if (MouseRightButtonDown) { if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>())) { PUIManager.AddNewUIAction(string.Empty, () => { Vector3 MouseDirection = Input.mousePosition - LastMousePosition; LastMousePosition = Input.mousePosition; Vector3 MoveDirection = new Vector3(MouseDirection.y, 0, -MouseDirection.x) * Config.MouseSensitivity; PUIManager.GetUI <PMapUI>().CameraController.ChangePerspective(PUIManager.GetUI <PMapUI>().CameraController.Camera.position + MoveDirection); }); } } #region 标滚动 if (Input.GetAxis("Mouse ScrollWheel") < 0) { if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>()) && PUIManager.GetUI <PMapUI>().CameraController != null) { if (PMath.InRect(Input.mousePosition, PUIManager.GetUI <PMapUI>().InformationText.rectTransform)) { PUIManager.AddNewUIAction("查看下一条信息", () => { PUIManager.GetUI <PMapUI>().NextInformation(); }); } else { PUIManager.AddNewUIAction("缩放[zoom+]", () => { if (PCameraController.Config.CameraLockedDistance.magnitude < 80.0f) { PCameraController.Config.CameraLockedDistance += PCameraController.Config.CameraZoomDistance; PUIManager.GetUI <PMapUI>().CameraController.ChangePerspective(PUIManager.GetUI <PMapUI>().CameraController.Camera.position + PCameraController.Config.CameraZoomDistance); } }); } } } else if (Input.GetAxis("Mouse ScrollWheel") > 0) { if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>()) && PUIManager.GetUI <PMapUI>().CameraController != null) { if (PMath.InRect(Input.mousePosition, PUIManager.GetUI <PMapUI>().InformationText.rectTransform)) { PUIManager.AddNewUIAction("查看上一条信息", () => { PUIManager.GetUI <PMapUI>().LastInformation(); }); } else { PUIManager.AddNewUIAction("缩放[zoom-]", () => { if (PCameraController.Config.CameraLockedDistance.magnitude > 20.0f) { PCameraController.Config.CameraLockedDistance -= PCameraController.Config.CameraZoomDistance; PUIManager.GetUI <PMapUI>().CameraController.ChangePerspective(PUIManager.GetUI <PMapUI>().CameraController.Camera.position - PCameraController.Config.CameraZoomDistance); } }); } } } #endregion #region 择格子 if (Input.GetMouseButtonUp(0)) { if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>()) && !PUIManager.GetUI <PMapUI>().MessageBox.IsActive) { Vector3 WorldPosition1 = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 20.0f)); Vector3 WorldPosition2 = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 30.0f)); Vector3 WorldPosition = new Vector3((WorldPosition1.x - WorldPosition2.x) / (WorldPosition1.y - WorldPosition2.y) * (-WorldPosition1.y) + WorldPosition1.x, 0, (WorldPosition1.z - WorldPosition2.z) / (WorldPosition1.y - WorldPosition2.y) * (-WorldPosition1.y) + WorldPosition1.z); PBlock FindBlockResult = PNetworkManager.NetworkClient.GameStatus.Map.FindBlock(PUIManager.GetUI <PMapUI>().Scene.BlockGroup.FindBlockSceneIndex(WorldPosition)); if (FindBlockResult != null) { PNetworkManager.NetworkClient.Send(new PClickOnBlockOrder(FindBlockResult.Index.ToString())); } } } #endregion }