void OnMouseDragged(object sender, MouseEventArgs e) { var delta = e.Position - dragStartPosition; var deltaInView = ContinuousViewportCoordinates.FromPixels(GameRendering.TileSize, delta.X, delta.Y); GameRendering.CenterPoint = viewportPosition - deltaInView; }
void OnMouseDragFinished(object sender, MouseEventArgs e) { var delta = e.Position - dragStartPosition; var deltaInView = ContinuousViewportCoordinates.FromPixels(GameRendering.TileSize, delta.X, delta.Y); Debug.WriteLine("Finished move: " + delta + " - " + (GameRendering.CenterPoint - deltaInView)); }
void OnMouseMoved(object sender, MouseEventArgs e) { var pointedPosition = MouseRelativeToCenter(e.Position); var mouseInScreenScale = ContinuousViewportCoordinates.FromPixels(GameRendering.TileSize, pointedPosition.X, pointedPosition.Y); var posInScreenOrigin = GameRendering.CenterPoint + mouseInScreenScale; var mc = GameRendering.ScreenPositionToMapCoordinate(posInScreenOrigin.ToViewCoordinate()); GameRendering.MapNavigator.NavigateTo(GridDirection.None, mc, out mc); TileUnderMouseCursor = mc; }