本文整理汇总了C#中TileSet.GetTileInfo方法的典型用法代码示例。如果您正苦于以下问题:C# TileSet.GetTileInfo方法的具体用法?C# TileSet.GetTileInfo怎么用?C# TileSet.GetTileInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileSet
的用法示例。
在下文中一共展示了TileSet.GetTileInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TerrainBitmap
public static Bitmap TerrainBitmap(TileSet tileset, Map map, bool actualSize = false)
{
var isDiamond = map.TileShape == TileShape.Diamond;
var b = map.Bounds;
// Fudge the heightmap offset by adding as much extra as we need / can.
// This tries to correct for our incorrect assumption that MPos == PPos
var heightOffset = Math.Min(map.MaximumTerrainHeight, map.MapSize.Y - b.Bottom);
var width = b.Width;
var height = b.Height + heightOffset;
var bitmapWidth = width;
if (isDiamond)
bitmapWidth = 2 * bitmapWidth - 1;
if (!actualSize)
bitmapWidth = height = Exts.NextPowerOf2(Math.Max(bitmapWidth, height));
var terrain = new Bitmap(bitmapWidth, height);
var bitmapData = terrain.LockBits(terrain.Bounds(),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
var mapTiles = map.MapTiles.Value;
unsafe
{
var colors = (int*)bitmapData.Scan0;
var stride = bitmapData.Stride / 4;
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
var uv = new MPos(x + b.Left, y + b.Top);
var type = tileset.GetTileInfo(mapTiles[uv]);
var leftColor = type != null ? type.LeftColor : Color.Black;
if (isDiamond)
{
// Odd rows are shifted right by 1px
var dx = uv.V & 1;
var rightColor = type != null ? type.RightColor : Color.Black;
if (x + dx > 0)
colors[y * stride + 2 * x + dx - 1] = leftColor.ToArgb();
if (2 * x + dx < stride)
colors[y * stride + 2 * x + dx] = rightColor.ToArgb();
}
else
colors[y * stride + x] = leftColor.ToArgb();
}
}
}
terrain.UnlockBits(bitmapData);
return terrain;
}
示例2: TerrainBitmap
public static Bitmap TerrainBitmap(TileSet tileset, Map map, bool actualSize = false)
{
var b = map.Bounds;
var width = b.Width;
var height = b.Height;
if (!actualSize)
width = height = Exts.NextPowerOf2(Math.Max(b.Width, b.Height));
var terrain = new Bitmap(width, height);
var bitmapData = terrain.LockBits(terrain.Bounds(),
ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
var mapTiles = map.MapTiles.Value;
unsafe
{
var colors = (int*)bitmapData.Scan0;
var stride = bitmapData.Stride / 4;
for (var y = 0; y < b.Height; y++)
{
for (var x = 0; x < b.Width; x++)
{
var mapX = x + b.Left;
var mapY = y + b.Top;
var type = tileset.GetTileInfo(mapTiles[new MPos(mapX, mapY)]);
var color = type != null ? type.LeftColor : Color.Black;
colors[y * stride + x] = color.ToArgb();
}
}
}
terrain.UnlockBits(bitmapData);
return terrain;
}