/// <summary> /// Move the camera's position based on input /// </summary> /// <param name="inputState"></param> public void HandleInput(CameraMovementState inputState) { Vector2 cameraMovement = Vector2.Zero; switch (inputState) { case CameraMovementState.Left: cameraMovement.X = -1; break; case CameraMovementState.Right: cameraMovement.X = 1; break; case CameraMovementState.Up: cameraMovement.Y = -1; break; case CameraMovementState.Down: cameraMovement.Y = 1; break; case CameraMovementState.ZoomIn: this.AdjustZoom(-0.25f); break; case CameraMovementState.ZoomOut: this.AdjustZoom(0.25f); break; default: throw new UnexpectedEnumMemberException(); } // When using a controller, to match the thumbstick behavior, // we need to normalize non-zero vectors in case the user // is pressing a diagonal direction. if (cameraMovement != Vector2.Zero) { cameraMovement.Normalize(); } // scale our movement to move 25 pixels per second cameraMovement *= 25f; this.MoveCamera(cameraMovement, false); }
public void InitialiseZoom(ZoomDirection t_direction, float t_zoomSpeed, float t_zoomAmount = 0.0f, float t_timeToZoom = 0.0f, CameraMovementState t_state = CameraMovementState.None) { SetZoomDirection(t_direction); SetInitialZoom(GetPosition().z); SetTrackingType(TrackingType.None); SetCameraState(CameraMovementState.None); SetTimeForZoom(t_timeToZoom); SetZoomAmount(t_zoomAmount); SetCurrentZoomSpeed(t_zoomSpeed); if (t_state != CameraMovementState.None) { InitialiseMovement(t_state); } }
public void InitialiseMovement(CameraMovementState t_state) { SetCameraState(t_state); SetTrackingType(TrackingType.None); }
public void SetCameraState(CameraMovementState t_state) { m_state = t_state; }