本文整理汇总了C#中Layer.AddTiles方法的典型用法代码示例。如果您正苦于以下问题:C# Layer.AddTiles方法的具体用法?C# Layer.AddTiles怎么用?C# Layer.AddTiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer.AddTiles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadIntoLayer
public void LoadIntoLayer(Layer layer)
{
foreach (var tileEntry in Tiles)
{
var tileData = tileEntry.Key;
var tilePositions = tileEntry.Value;
Tile tile = AssemblyManager.GetTileByFullName(tileData.TypeName);
tile.Name = tileData.Name;
tile.GraphicsResourceName = tileData.GraphicsResourceName;
tile.InitialState = tileData.InitialState;
tile.Position = Vector2.Zero;
tile.InitialPosition = Vector2.Zero;
if (tile.TileShape == Physics.CollidableShape.Rectangle)
{
tile.RectSolidSides = (TileRectSolidSides)tileData.SolidSides;
}
else
{
tile.TriSolidSides = (TileTriSolidSides)tileData.SolidSides;
}
if (!(tileData.CustomData is JToken))
{
throw new InvalidCastException("LayerTileSaveData.LoadIntoLayer(Layer): The custom data for a tile was not in the correct format.");
}
tile.DeserializeCustomObjects(new JsonHelper((JToken)tileData.CustomData));
List<Tile> tilesToAdd = new List<Tile>();
foreach (Point tileNumber in tilePositions.CellNumbers)
{
float xPosition = layer.Tiles.Position.X + (tileNumber.X * layer.Tiles.CellWidth);
float yPosition = layer.Tiles.Position.Y + (tileNumber.Y * layer.Tiles.CellHeight);
Tile resultTile = tile.Clone();
resultTile.InitialPosition = resultTile.Position = new Vector2(xPosition, yPosition);
resultTile.Initialize(layer.Owner);
tilesToAdd.Add(resultTile);
}
layer.AddTiles(tilesToAdd);
}
}