/// <summary> /// Responsible for assigning a current mouse behavior /// </summary> private void AttemptToSetMouseBehavior() { // Check here(?) to see if we are over a UI element, // if so -- ignore mouse clicks and such. if (EventSystem.current.IsPointerOverGameObject()) { // TODO: Do we want to ignore ALL GUI objects? Consider // things like unit health bars, resource icons, etc... // Although, if those are set to NotInteractive or Not Block // Raycasts, maybe this will return false for them anyway. return; } if (Input.GetMouseButtonUp(0)) { mouseBehavior = new UnitSelection(); } else if (selectionController.SelectedUnit != null && Input.GetMouseButtonDown(1)) { // We have a selected unit, and we've pushed down the right // mouse button, so enter unit movement mode. mouseBehavior = new UnitMovement(this.StartCoroutine); } else if (Input.GetMouseButton(0) && Vector3.Distance(Input.mousePosition, positionInfo.lastMousePosition) > cameraInfo.MouseDragThreshold) { // Left button is being held down AND the mouse moved? That's a camera drag! mouseBehavior = new CameraMovement(); positionInfo.lastMouseGroundPlanePosition = mouseBehavior.MouseToGroundPlane(Input.mousePosition); } }
public void ResetMouseBehavior() { DebugLogger.Log(LogLevel.Informational, "Resetting mouse behavior", GetType()); mouseBehavior = null; }