public void Draw(IPlotOperation plotOperation) { var area = viewport.RenderedArea; var insets = viewport.RenderInsets; var renderType = viewport.RenderType; var screenOrigin = new MapCoordinate(0, 0); screenNavigator.NavigateTo(GridDirection.North, screenOrigin, out MapCoordinate northWest, insets.Top); screenNavigator.NavigateTo(GridDirection.West, northWest, out northWest, insets.Left); screenNavigator.NavigateTo(GridDirection.South, screenOrigin, out MapCoordinate southWest, insets.Bottom); screenNavigator.NavigateTo(GridDirection.West, southWest, out southWest, insets.Left); var valid = true; var mapOrigin = viewport.CenterPointInMapCoordinates; valid &= mapAccessNavigator.NavigateTo(GridDirection.North, mapOrigin, out MapCoordinate mapRowStart, insets.Top); valid &= mapAccessNavigator.NavigateTo(GridDirection.West, mapRowStart, out mapRowStart, insets.Left); var rowStart = northWest; if (logger.IsTraceEnabled) { logger.Trace( "Rendering frame lines from {0} -> {1} in area {2} (Insets: {3}, ScreenOrigin: {4}, MapOrigin: {5})", northWest, southWest, area, insets, screenOrigin, mapOrigin); } plotOperation.StartDrawing(); for (var y = 0; y < area.Height; y += 1) { if (renderType == RenderType.Grid) { RenderLine(plotOperation, mapRowStart, rowStart, area.Width, valid, y); screenNavigator.NavigateTo(GridDirection.South, rowStart, out rowStart); valid = mapAccessNavigator.NavigateTo(GridDirection.South, mapRowStart, out mapRowStart); } else { // In any of the two isometric modes the renderer cannot just move straight downwards. // Rows are offset against each other, so the renderer has to alternate between the // south-east and south-west direction. // // On the first line, the start and end position are outwards from the screen so // the line is actually two elements longer. RenderLine(plotOperation, mapRowStart, rowStart, area.Width, valid, y); // was area.Width screenNavigator.NavigateTo(GridDirection.SouthEast, rowStart, out rowStart); valid = mapAccessNavigator.NavigateTo(GridDirection.SouthEast, mapRowStart, out mapRowStart); RenderLine(plotOperation, mapRowStart, rowStart, area.Width, valid, y); // was area.Width screenNavigator.NavigateTo(GridDirection.SouthWest, rowStart, out rowStart); valid = mapAccessNavigator.NavigateTo(GridDirection.SouthWest, mapRowStart, out mapRowStart); } } plotOperation.FinishedDrawing(); }
public FogState this[int x, int y] { get { navigator.NavigateTo(GridDirection.None, new MapCoordinate(x, y), out MapCoordinate c); return(parent[c.X, c.Y]); } }
public static MapCoordinate[] NavigateCardinalNeighbours(this IMapNavigator <GridDirection> nav, MapCoordinate coord, MapCoordinate[] retval = null) { if (retval == null || retval.Length < 4) { retval = new MapCoordinate[4]; } nav.NavigateTo(GridDirection.North, coord, out retval[0]); nav.NavigateTo(GridDirection.East, coord, out retval[1]); nav.NavigateTo(GridDirection.South, coord, out retval[2]); nav.NavigateTo(GridDirection.West, coord, out retval[3]); return(retval); }
public void Validate(IMapNavigator <GridDirection> navigator) { var br = navigator.NavigateTo(Direction, Origin, out var result, Steps); br.Should().Be(Result); result.Should().Be(ExpectedPosition, "we navigated from origin {0} in direction {1}", Origin, Direction, ExpectedPosition); }
public static MapCoordinate NavigateUnconditionally(this IMapNavigator <GridDirection> nav, GridDirection d, MapCoordinate coord, int steps = 1) { nav.NavigateTo(d, coord, out MapCoordinate results, steps); return(results); }
void NavigateForUpwardRenderDirection(int x, int y, out MapCoordinate coordA, out MapCoordinate coordB, out MapCoordinate coordC, out MapCoordinate coordD) { // // /\ // /A \ // /\ 2/\ // / D\/ B \ // \1 /\ 3 / // \/ C\/ // \ / // \/ // // tile_cell_A_B_C_D // self is at C coordC = new MapCoordinate(x, y); gridNavigator.NavigateTo(GridDirection.North, coordC, out coordB); gridNavigator.NavigateTo(GridDirection.NorthWest, coordC, out coordA); gridNavigator.NavigateTo(GridDirection.West, coordC, out coordD); }