本文整理汇总了C#中IMap.AddTile方法的典型用法代码示例。如果您正苦于以下问题:C# IMap.AddTile方法的具体用法?C# IMap.AddTile怎么用?C# IMap.AddTile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMap
的用法示例。
在下文中一共展示了IMap.AddTile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateMap
private static IMap GenerateMap()
{
rock = Content.Load<Texture2D>("rock_single");
tile_green = Content.Load<Texture2D>("tile_green");
tile_brown = Content.Load<Texture2D>("tile_brown");
map = new Map(new Point(100, 100));
int width = 100;
int length = 100;
int threadCount = 2; // Environment.ProcessorCount
int stepWidth = width / threadCount;
int stepLength = length / threadCount;
List<Thread> threads = new List<Thread>();
for (int i = 0; i < threadCount; i++)
{
threads.Add(new Thread(new ParameterizedThreadStart(GenerateMapSlice)));
}
List<SliceData> sliceDataList = new List<SliceData>();
for (int i = 0; i < threadCount; i++)
{
SliceData data = new SliceData(new List<Tile>(), new Rectangle(0, stepLength * i, width, stepLength));
threads[i].Start(data);
sliceDataList.Add(data);
}
for (int i = 0; i < threadCount; i++)
{
threads[i].Join();
}
foreach(SliceData data in sliceDataList)
{
foreach(Tile tile in data.TileList)
{
tile.MapIndex = map.AddTile(tile);
}
}
// Clear thread list
threads.Clear();
// Build adjacent tile arrays
for (int i = 0; i < threadCount; i++)
{
threads.Add(new Thread(new ParameterizedThreadStart(PopulateAdjacentTiles)));
}
int range = map.TileCount / threadCount;
for (int i = 0; i < threadCount; i++)
{
PopulateAdjacentTilesData Data = new PopulateAdjacentTilesData(map, i * range, range);
threads[i].Start(Data);
}
for (int i = 0; i < threadCount; i++)
{
threads[i].Join();
}
return map;
}