本文整理汇总了C#中TerrainTile.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# TerrainTile.Clone方法的具体用法?C# TerrainTile.Clone怎么用?C# TerrainTile.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TerrainTile
的用法示例。
在下文中一共展示了TerrainTile.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TerrainDisplay
public TerrainDisplay(TerrainTile[,] tiles)
{
mode = Mode.Erase;
this.tilesBak = (TerrainTile[,])tiles.Clone();
this.tiles = tiles;
ClientSize = new Size(800, 800);
BackColor = Color.Blue;
WindowState = FormWindowState.Maximized;
panel = new Panel()
{
Dock = DockStyle.Fill,
AutoScroll = true,
Controls =
{
(pic = new PictureBox()
{
Image = bmp = RenderColorBmp(tiles),
SizeMode = PictureBoxSizeMode.AutoSize,
})
}
};
panel.HorizontalScroll.Enabled = true;
panel.VerticalScroll.Enabled = true;
panel.HorizontalScroll.Visible = true;
panel.VerticalScroll.Visible = true;
Controls.Add(panel);
pic2 = new PictureBox()
{
Image = bmp,
Width = 250,
Height = 250,
SizeMode = PictureBoxSizeMode.Zoom
};
Controls.Add(pic2);
pic2.BringToFront();
Text = mode.ToString();
pic.MouseMove += new MouseEventHandler(pic_MouseMove);
pic.MouseDoubleClick += new MouseEventHandler(pic_MouseDoubleClick);
}
示例2: Randomize
void Randomize(TerrainTile[,] buff)
{
int w = buff.GetLength(0);
int h = buff.GetLength(1);
TerrainTile[,] tmp = (TerrainTile[,])buff.Clone();
for (int y = 10; y < h - 10; y++)
for (int x = 10; x < w - 10; x++)
{
var tile = buff[x, y];
if (tile.TileId == TileTypes.Water && tile.Elevation >= elevationThreshold[3])
tile.TileId = TileTypes.SnowRock;
else if (tile.TileId != TileTypes.Water && tile.TileId != TileTypes.Road &&
tile.TileId != TileTypes.Beach && tile.TileId != TileTypes.MovingWater &&
tile.TileId != TileTypes.DeepWater)
{
var id = tmp[x + rand.Next(-3, 4), y + rand.Next(-3, 4)].TileId;
while (id == TileTypes.Water || id == TileTypes.Road ||
id == TileTypes.Beach || id == TileTypes.MovingWater ||
id == TileTypes.DeepWater)
id = tmp[x + rand.Next(-3, 4), y + rand.Next(-3, 4)].TileId;
tile.TileId = id;
}
//if (tile.TileId == TileTypes.Beach)
// tile.Region = TileRegion.Spawn;
string biome = tile.Biome;
if (tile.TileId == TileTypes.Beach) biome = "beach";
else if (tile.TileId == TileTypes.MovingWater) biome = "coast";
var biomeObj = Decoration.GetDecor(biome, rand);
if (biomeObj != null)
{
tile.TileObj = biomeObj;
var size = Decoration.GetSize(biomeObj, rand);
if (size != null)
tile.Name = "size:" + size;
}
float elevation = 0;
int c = 0;
for (int dy = -1; dy <= 1; dy++)
for (int dx = -1; dx <= 1; dx++)
{
if (x + dx < 0 || x + dx >= w || y + dy < 0 || y + dy >= h) continue;
elevation += tmp[x + dx, y + dy].Elevation;
c++;
}
tile.Elevation = elevation / c;
buff[x, y] = tile;
}
}
示例3: Randomize
void Randomize(TerrainTile[,] buff)
{
int w = buff.GetLength(0);
int h = buff.GetLength(1);
TerrainTile[,] tmp = (TerrainTile[,])buff.Clone();
for (int y = 10; y < h - 10; y++)
for (int x = 10; x < w - 10; x++)
{
var tile = buff[x, y];
if (tile.TileId == TileTypes.Water && tile.Elevation >= elevationThreshold[3])
tile.TileId = TileTypes.SnowRock;
else if (tile.TileId != TileTypes.Water && tile.TileId != TileTypes.Road &&
tile.TileId != TileTypes.Beach && tile.TileId != TileTypes.MovingWater &&
tile.TileId != TileTypes.DeepWater)
{
var id = buff[x + rand.Next(-1, 2), y + rand.Next(-1, 2)].TileId;
while (id == TileTypes.Water || id == TileTypes.Road ||
id == TileTypes.Beach || id == TileTypes.MovingWater ||
id == TileTypes.DeepWater)
id = buff[x + rand.Next(-5, 5), y + rand.Next(-5, 5)].TileId;
tile.TileId = id;
}
//if (tile.TileId == TileTypes.Beach)
// tile.Region = TileRegion.Spawn;
string biome = tile.Biome;
if (tile.TileId == TileTypes.Beach) biome = "beach";
else if (tile.TileId == TileTypes.MovingWater) biome = "coast";
var biomeObj = Decoration.GetDecor(biome, rand);
if (biomeObj != null)
{
tile.TileObj = biomeObj;
var size = Decoration.GetSize(biomeObj, rand);
if (size != null)
tile.Name = "size:" + size;
}
buff[x, y] = tile;
}
}