Ejemplo n.º 1
0
 public CollisionLayer(string name, Game game, Size layer_size, int[] layer, bool breakable)
 {
     //properites coming from map class
     this.name = name;
     this.layersize = layer_size;
     this.breakable = breakable;
     this.tiles = (int[])layer.Clone();
 }
Ejemplo n.º 2
0
        public Layer(Game game, string name, Size layer_size, Size sprite_size, int[] layer, string textureName)
            : base(game)
        {
            this.game = game;
            // gets the layer details from the map and sets the varables
            this.name = name;
            this.layersize = layer_size;
            this.spritesize = sprite_size;

            this.textureName = textureName;
            this.tiles = (int[])layer.Clone();
        }
Ejemplo n.º 3
0
        public Map(string mapxml, Game game)
            : base(game)
        {
            XmlTextReader mapreader = new XmlTextReader(game.Content.RootDirectory + " \\" + mapxml);
            XmlDocument mapdocument = new XmlDocument();
            mapdocument.Load(mapreader);

            name = mapdocument.SelectSingleNode("/map").Attributes["name"].InnerText;
            mapsize = new Size(Convert.ToInt32(mapdocument.SelectSingleNode("/map/mapsize").Attributes["x"].InnerText),
                               Convert.ToInt32(mapdocument.SelectSingleNode("/map/mapsize").Attributes["y"].InnerText));

            spritesize = new Size(Convert.ToInt32(mapdocument.SelectSingleNode("/map/spritesize").Attributes["x"].InnerText),
                   Convert.ToInt32(mapdocument.SelectSingleNode("/map/spritesize").Attributes["y"].InnerText));

            XmlNodeList xmlLayers = mapdocument.SelectNodes("/map/layer");
            for (int i = 0; i < xmlLayers.Count; i++)
            {
                if (xmlLayers.Item(i).Attributes["type"].InnerText == "Texture")
                {
                    int[] layerArray = Array.ConvertAll<string, int>(xmlLayers.Item(i).SelectSingleNode("data").InnerText.Split(' '), Convert.ToInt32);
                    string layerName = xmlLayers.Item(i).Attributes["name"].InnerText;
                    this.texLayers.Add(xmlLayers.Item(i).Attributes["name"].InnerText, new Layer(game, layerName, mapsize, spritesize, layerArray, xmlLayers.Item(i).SelectSingleNode("sprite").InnerText));
                    this.Game.Components.Add(this.texLayers[layerName]);
                }
                else if (xmlLayers.Item(i).Attributes["type"].InnerText == "Collision")
                {
                    int[] layerArray = Array.ConvertAll<string, int>(xmlLayers.Item(i).SelectSingleNode("data").InnerText.Split(' '), Convert.ToInt32);
                    string layerName = xmlLayers.Item(i).Attributes["name"].InnerText;
                    this.colLayers.Add(layerName, new CollisionLayer(layerName, game, mapsize, layerArray, Convert.ToBoolean(xmlLayers.Item(i).Attributes["breakable"].InnerText)));
                }
                else
                {
                    //unknown layer
                }

            }

            // Console.Write("");
        }
Ejemplo n.º 4
0
 public SpriteSheet(Texture2D texture, Size spriteSize)
 {
     this.texture = texture;
     this.sprite = spriteSize;
 }