public HexDefinition CreateHexDefinition(string hexName, Point hexPosition) { var rectangle = new RectangleInt(hexPosition.X, hexPosition.Y, this.HexSize.Width, this.HexSize.Height); var hexDefinition = new HexDefinition(this, hexName, rectangle); this.Definitions.Add(hexName, hexDefinition); return hexDefinition; }
public virtual void Draw(IDrawContext drawContext, HexDefinition hexDefinition, Rectangle destination) { drawContext.DrawImage(new DrawImageParams { Texture = this.Texture, Source = hexDefinition.Rectangle, Destination = destination, }); }
public HexLayer(string name, Size mapSize, Size hexSize, int topEdgeLength, HexDefinition defaultHexDefinition = null) : base(name) { this.MapSize = mapSize; this.HexSize = hexSize; this.topEdgeLength = topEdgeLength; this.map = new HexDefinition[mapSize.Width, mapSize.Height]; if (defaultHexDefinition == null) defaultHexDefinition = NullHexDefinition.CreateInstance(); for (var i = 0; i < mapSize.Width; i++) for (var j = 0; j < mapSize.Height; j++) { this.map[i, j] = defaultHexDefinition; } }
public override void Draw(IDrawContext drawContext, HexDefinition hexDefinition, Rectangle destination) { // Do nothing NullObjectPattern }
public void AddHexDefinition(HexDefinition hexDefinition) { this.Definitions.Add(hexDefinition.Name, hexDefinition); }
private static object GetHexDefinitionXml(HexDefinition hexDefinition) { return new XElement("HexDefinition", new XAttribute("name", hexDefinition.Name), new XAttribute("rectangle", hexDefinition.Rectangle)); }