Exemplo n.º 1
0
        public static HexSheet FromXml(XElement sheetElement, string name, Texture texture)
        {
            var hexSize = MathUtil.ParseSize(sheetElement.Element("HexSize").Value);
            var hexSheet = new HexSheet(texture, name, hexSize);

            foreach (var definitionElement in sheetElement.Elements("Definitions").Elements())
            {
                var hexDefinition = FromXml(definitionElement, hexSheet);
                hexSheet.AddHexDefinition(hexDefinition);
            }

            return hexSheet;
        }
Exemplo n.º 2
0
 public HexDefinition(HexSheet sheet, string name, RectangleInt rectangle)
 {
     this.Sheet = sheet;
     this.Name = name;
     this.Rectangle = rectangle;
 }
Exemplo n.º 3
0
        private static HexDefinition FromXml(XElement definitionElement, HexSheet hexSheet)
        {
            var name = definitionElement.Attribute("name").Value;
            var rectangle = MathUtil.ParseRectangle(definitionElement.Attribute("rectangle").Value);

            return new HexDefinition(hexSheet, name, rectangle);
        }
Exemplo n.º 4
0
 public static IEnumerable<object> GetXml(HexSheet hexSheet)
 {
     yield return new XElement("HexSize", hexSheet.HexSize);
     yield return new XElement("Definitions", hexSheet.Definitions.Select(d => GetHexDefinitionXml(d.Value)));
 }
 public void AddHexSheet(HexSheet sheet)
 {
     this.hexSheetDictionary.Add(sheet.Name, sheet);
 }
Exemplo n.º 6
0
        private HexLayer CreateHexLayer()
        {
            var texture = this.ResourceManager.GetTexture(@"Sandbox\HexSheet");
            var sheet = new HexSheet(texture, "Hexes", new Size(68, 60));
            var red = sheet.CreateHexDefinition("red", new Point(55, 30));
            var yellow = sheet.CreateHexDefinition("yellow", new Point(163, 330));
            var purple = sheet.CreateHexDefinition("purple", new Point(488, 330));

            //sheet.Save(@"C:\Users\Pascal\Dev\DotNet\GitHub\XNAGameEngine2D\Color HexSheet.xml");

            this.ResourceManager.AddHexSheet(sheet);

            var hexLayer = new HexLayer("Hex", new Size(4, 4), new Size(68, 60), 42);
            hexLayer[2, 0] = purple;
            hexLayer[2, 1] = purple;
            hexLayer[2, 2] = yellow;
            hexLayer[0, 1] = red;
            hexLayer[1, 1] = red;

            hexLayer.ParallaxScrollingVector = new Vector(4.0f, 0.5f);
            hexLayer.Offset = new Vector(-25, 0);

            return hexLayer;
        }