public void CreateResources(ICanvasResourceCreator resourceCreator) { DestroyResources(); // define path var pb = new CanvasPathBuilder(resourceCreator); var radiusH = HexUtils.GetRadiusHeight(Radius); pb.BeginFigure(-1 * Radius * HexUtils.COS60, radiusH); pb.AddLine(Radius * HexUtils.COS60, radiusH); pb.AddLine(Radius, 0); pb.AddLine(Radius * HexUtils.COS60, -1 * radiusH); pb.AddLine(-1 * Radius * HexUtils.COS60, -1 * radiusH); pb.AddLine(-1 * Radius, 0); pb.EndFigure(CanvasFigureLoop.Closed); // create and cache _strokeStyle = new CanvasStrokeStyle(); var geo = CanvasGeometry.CreatePath(pb); if (Filled) { _geo = CanvasCachedGeometry.CreateFill(geo); } else { _geo = CanvasCachedGeometry.CreateStroke(geo, Style.StrokeWidth, _strokeStyle); } }
public PrerenderProvider(IConfig config, IIndicatorRegistry indicatorRegistry) { _indicatorRegistry = indicatorRegistry ?? throw new ArgumentNullException(nameof(indicatorRegistry)); _tileRadius = config.GetFloat(CoreConfig.TileRadius); _tileRadiusH = HexUtils.GetRadiusHeight(_tileRadius); _prerenders = new Dictionary <DrawLayer, PrerenderedLayer>(); foreach (var dl in DrawLayers) { _prerenders.Add(dl, new PrerenderedLayer(DrawLevelOfDetail.Low, dl)); } }
public FieldController(IConfig config, UiStateModel uiState, MapModel map, IIndicatorRegistry indicatorRegistry, PrerenderProvider prerenderProvider) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _uiState = uiState ?? throw new ArgumentNullException(nameof(uiState)); _map = map ?? throw new ArgumentNullException(nameof(map)); _prerenderProvider = prerenderProvider ?? throw new ArgumentNullException(nameof(config)); _indicatorRegistry = indicatorRegistry ?? throw new ArgumentNullException(nameof(indicatorRegistry)); _tileRadius = config.GetFloat(CoreConfig.TileRadius); _tileRadiusH = HexUtils.GetRadiusHeight(_tileRadius); _pan = Vector2.Zero; _zoom = 1.0f; }
public MapTileModel(HexCoords coords, IConfig config, IIndicatorProvider indicatorProvider) { Coords = coords; _agents = new VersionedCollection <IExtendedAgent>(new HashSet <IExtendedAgent>()); // copy down config var radius = config.GetFloat(CoreConfig.TileRadius); // calculate position var radiusH = HexUtils.GetRadiusHeight(radius); var x = Coords.Column * (radius + radius * HexUtils.COS60); var y = ((Coords.Column & 1) * radiusH) + ((Coords.Row - (Coords.Column & 1)) * 2 * radiusH); Position = new Vector2(x, y); Indicators = indicatorProvider.CreateIndicatorCollection(); }
public void Initialize(int rows, int columns) { Rows = rows; Columns = columns; Size = new Vector2((float)(Columns * _tileRadius * 1.5 + _tileRadius / 2), Rows * 2 * HexUtils.GetRadiusHeight(_tileRadius)); _tiles = new HexGridCollection <MapTileModel>(Rows, Columns); _paths = new Dictionary <string, MapPathModel>(); }