public TiledTerrain(String texturePath, Vector2 size, float frictionCoefficient, TiledType tiledType, Vector2 tileSize)
     : base(texturePath,size,frictionCoefficient)
 {
     this.tiledSize = tileSize;
     this.tiledType = tiledType;
     
 }
示例#2
0
    public void Start()
    {
        TiledFiletype type = TiledType.GetAssetType(TextAssetName);

        if (type == TiledFiletype.Map)
        {
            TiledMap map = TiledMap.ReadMap(TextAssetName);
            foreach (TiledLayer layer in map.layers)
            {
                TiledLayerTile[] tiles = layer.GetTiles();
                if (tiles != null)
                {
                    foreach (TiledLayerTile tile in tiles)
                    {
                        // Debug.LogFormat("Tile({0},{1}) = {2} H={3} V={4} D={5}", tile.X, tile.Y, tile.Gid, tile.IsFlippedHorz, tile.IsFlippedVert, tile.IsFlippedDiag);
                    }
                }
            }
        }
        else if (type == TiledFiletype.Tileset)
        {
            TiledTileset tileset = TiledTileset.ReadTileset(TextAssetName);
            tileset.PrintSummary();
        }
    }
示例#3
0
    public virtual void SetData(XmlNode node)
    {
        string[] Splitstr;
         tType = (TiledType)(int.Parse(node.ChildNodes[0].InnerText));
        mType = (MoveType)(int.Parse(node.ChildNodes[1].InnerText));
        tilt = float.Parse(node.ChildNodes[2].InnerText);

        Splitstr = node.ChildNodes[3].InnerText.Split(',');
        LeftBot = new Vector2(int.Parse(Splitstr[0]), int.Parse(Splitstr[1]));

        Splitstr = node.ChildNodes[4].InnerText.Split(',');
        RightTop = new Vector2(int.Parse(Splitstr[0]), int.Parse(Splitstr[1]));
    }
        /// <summary>
        /// 使用TiledTerrainData序列化类进行构造
        /// </summary>
        public TiledTerrain(TiledTerrainData tiledTerrainData)
        {
            // ItemBase
            texture = LoadHelper.LoadTexture2D("Terrains/"+tiledTerrainData.textureName);
            layer = tiledTerrainData.layer;

            // AnimItem

            // PhysicsItem
            SetSize(tiledTerrainData.size);
            SetOrigin(tiledTerrainData.size/2);
            body.Position = tiledTerrainData.position;
            body.Rotation = tiledTerrainData.rotation;
            body.IsStatic = true;

            // RectTerrain
            FrictionCoefficient = tiledTerrainData.frictionCoefficient;

            // TiledTerrain
            rectOrigin = Size / 2;
            tiledSize = tiledTerrainData.tiledSize;
           // origin = tiledTerrainData.tiledOrigin; -- 过期
            tiledType = tiledTerrainData.tiledType;
        }