コード例 #1
0
        public TiledTileLayer(XmlElement xLayer) : base(xLayer)
        {
            Width = xLayer.AttributeInt("width");
            Height = xLayer.AttributeInt("height");
            Encoding = xLayer["data"].Attributes["encoding"].Value;

            if(xLayer.Attributes["opacity"] != null)
            {
                Opacity = xLayer.AttributeFloat("opacity");
            }
            
            DecodeTiles(xLayer);
        }
コード例 #2
0
ファイル: Tilemap.cs プロジェクト: KrissLaCross/BreakOut
 /// <summary>
 /// Load tile data from an XmlElement.
 /// </summary>
 /// <param name="e">An XmlElement containing attributes x, y, tx, and ty.</param>
 /// <returns>The TileInfo for the loaded tile.</returns>
 public TileInfo SetTile(XmlElement e) {
     int x, y, tx, ty;
     if (UsePositions) {
         x = e.AttributeInt("x") * TileWidth;
         y = e.AttributeInt("y") * TileHeight;
     }
     else {
         x = e.AttributeInt("x");
         y = e.AttributeInt("y");
     }
     tx = e.AttributeInt("tx") * TileWidth;
     ty = e.AttributeInt("ty") * TileHeight;
     return SetTile(x, y, tx, ty);
 }
コード例 #3
0
        void CreateEntity(XmlElement e, Scene scene) {
            Type entityType = Util.GetTypeFromAllAssemblies(e.Name);

            object[] arguments = new object[2];
            arguments[0] = scene;
            arguments[1] = e.Attributes;

            if (entityType != null) {
                MethodInfo method = entityType.GetMethod(CreationMethodName, BindingFlags.Static | BindingFlags.Public);
                if (method != null) {
                    method.Invoke(null, arguments);
                }
                else {
                    // Attempt to create with just constructor
                    var x = e.AttributeInt("x");
                    var y = e.AttributeInt("y");
                    var entity = (Entity)Activator.CreateInstance(entityType, x, y);
                    scene.Add(entity);
                }
            }
        }
コード例 #4
0
 public TiledTileset(XmlElement xTileset)
 {
     Name = xTileset.Attributes["name"].Value;
     FirstGid = xTileset.AttributeInt("firstgid");
     ImageSource = xTileset["image"].Attributes["source"].Value;
 }