/// <summary> /// Reacts to a NavigationEventInfo callback; /// It rotates the Images based on the float that comes with the callback; /// Callback is called by the camera and the float is the rotation of the camera; /// This secures that the North is always North; /// </summary> /// <param name="eventInfo">NavigationEventInfo</param> private void CompassRotation(EventInfo eventInfo) { NavigationEventInfo navInfo = (NavigationEventInfo)eventInfo; compasAngle = navInfo.navFloat; if (compasAngle >= 270 && compasAngle < 360) // 270 grader { float p = (compasAngle - 270f) / 90; LerpPictureBetween(N, 800, 0, p); LerpPictureBetween(W, 0, -800, p); CheckFill(N); CheckFill(W); } else if (compasAngle >= 180 && compasAngle < 270) // 180 grader { float p = (compasAngle - 180) / 90; LerpPictureBetween(S, 0, -800, p); LerpPictureBetween(W, 800, 0, p); CheckFill(S); CheckFill(W); } else if (compasAngle >= 90 && compasAngle < 180) // 90 grade { float p = (compasAngle - 90) / 90; LerpPictureBetween(S, 800, 0, p); LerpPictureBetween(E, 0, -800, p); CheckFill(S); CheckFill(E); } else if (compasAngle >= 0 && compasAngle < 90) // 0 grade { float p = compasAngle / 90.0f; LerpPictureBetween(N, 0, -800, p); LerpPictureBetween(E, 800, 0, p); CheckFill(N); CheckFill(E); } }
/// <summary> /// Locks and unlocks the mouse depending on <see cref="Time.timeScale"/> and controlls camera from movement input. /// </summary> void Update() { // if down rb scroll value = -1, else if if (Time.timeScale == 0) { return; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; ZoomHandler(); direction.x -= mouseSensitivity * Input.GetAxisRaw("Camera Y"); direction.y += mouseSensitivity * Input.GetAxisRaw("Camera X"); direction.x = Mathf.Clamp(direction.x, -50, 50); transform.rotation = Quaternion.Euler(direction.x, direction.y, 0f); CameraPosition(); NavigationEventInfo nei = new NavigationEventInfo { navFloat = transform.rotation.eulerAngles.y }; EventHandeler.Current.FireEvent(EventHandeler.EVENT_TYPE.Navigation, nei); } }