本文整理汇总了C#中TileMap.GetTileData方法的典型用法代码示例。如果您正苦于以下问题:C# TileMap.GetTileData方法的具体用法?C# TileMap.GetTileData怎么用?C# TileMap.GetTileData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileMap
的用法示例。
在下文中一共展示了TileMap.GetTileData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: findAvailableTile
public static TileStruct findAvailableTile(TileMap map, int Xoffset, int Yoffset)
{
TileStruct tile = new TileStruct(0,0,TileType.None);
while (tile.Type != TileType.Dirt)
{
tile = map.GetTileData(rand.Next(0, map.map[0].Length - 1) + Xoffset, rand.Next(0, map.map.Length - 1) + Yoffset);
}
return tile;
}
示例2: GetTexture
public static Sprite GetTexture(TileStruct tile, TileMap map)
{
var left = map.GetTileData(tile.X - 1, tile.Y);
var right = map.GetTileData(tile.X + 1, tile.Y);
var north = map.GetTileData(tile.X, tile.Y + 1);
var south = map.GetTileData(tile.X, tile.Y - 1);
var upLeft = map.GetTileData(tile.X - 1, tile.Y + 1);
var upRight = map.GetTileData(tile.X + 1, tile.Y + 1);
var downLeft = map.GetTileData(tile.X - 1, tile.Y - 1);
var downRight = map.GetTileData(tile.X + 1, tile.Y - 1);
if (left.Type == TileType.Rock || right.Type == TileType.Rock || north.Type == TileType.Rock || south.Type == TileType.Rock || upLeft.Type == TileType.Rock || upRight.Type == TileType.Rock || downLeft.Type == TileType.Rock || downRight.Type == TileType.Rock)
{
tile.DecorType = DecorType.None;
}
if (tile.Type == TileType.Rock)
{
return getSpriteWithName(tile.WallTerrainType + getNumber(
tile.WallTerrainType,
left.GetTerrainType(),
right.GetTerrainType(),
north.GetTerrainType(),
south.GetTerrainType(),
upLeft.GetTerrainType(),
upRight.GetTerrainType(),
downLeft.GetTerrainType(),
downRight.GetTerrainType()
),
tile.Type);
}
string decor = Enum.GetName(typeof(DecorType), tile.DecorType);
if (tile.Type == TileType.Dirt)
{
if (tile.DecorType == DecorType.None)
{
return getSpriteWithName(tile.GetTerrainType() + getNumberFloors(
tile.GetTerrainType(),
left.GetTerrainType(),
right.GetTerrainType(),
north.GetTerrainType(),
south.GetTerrainType(),
upLeft.GetTerrainType(),
upRight.GetTerrainType(),
downLeft.GetTerrainType(),
downRight.GetTerrainType()),
tile.Type);
}
else
{
return getSpriteWithName(tile.GetTerrainType() + decor + getNumberFloors(
tile.GetTerrainType() + tile.GetDecorType(),
left.GetTerrainType() + left.GetDecorType(),
right.GetTerrainType() + right.GetDecorType(),
north.GetTerrainType() + north.GetDecorType(),
south.GetTerrainType() + south.GetDecorType(),
upLeft.GetTerrainType() + upLeft.GetDecorType(),
upRight.GetTerrainType() + upRight.GetDecorType(),
downLeft.GetTerrainType() + downLeft.GetDecorType(),
downRight.GetTerrainType() + downRight.GetDecorType()
),
tile.Type);
}
}
return null;
}