本文整理汇总了C#中Level.GetBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Level.GetBlock方法的具体用法?C# Level.GetBlock怎么用?C# Level.GetBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.GetBlock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tick
public override void Tick(Level l)
{
if (l.GetBlock(X, Z, Y - 1) == Block.BlockList.AIR) {
Add(l, new Active_Water(X, Z, Y - 1));
Remove(l);
//l.BlockChange((ushort)X, (ushort)Z, (ushort)(Y - 1), this);
}
else {
if (l.GetBlock(X + 1, Z, Y) == Block.BlockList.AIR) {
Add(l, new Active_Water(X + 1, Z, Y));
//l.BlockChange((ushort)(X + 1), (ushort)Z, (ushort)Y, this);
}
if (l.GetBlock(X - 1, Z, Y) == Block.BlockList.AIR) {
Add(l, new Active_Water(X - 1, Z, Y));
//l.BlockChange((ushort)(X - 1), (ushort)Z, (ushort)Y, this);
}
if (l.GetBlock(X, Z + 1, Y) == Block.BlockList.AIR) {
Add(l, new Active_Water(X, Z + 1, Y));
//l.BlockChange((ushort)X, (ushort)(Z + 1), (ushort)Y, this);
}
if (l.GetBlock(X, Z - 1, Y) == Block.BlockList.AIR) {
Add(l, new Active_Water(X, Z - 1, Y));
// l.BlockChange((ushort)X, (ushort)(Z - 1), (ushort)Y, this);
}
}
}
示例2: Tick
public override void Tick(Level l)
{
if (Block.CanPassLight(l.GetBlock(X, Z, Y + 1)))
{
l.BlockChange((ushort)X, (ushort)Z, (ushort)Y, Block.BlockList.GRASS);
Remove(l);
}
}
示例3: Tick
public override void Tick(Level l)
{
if (l.GetBlock(X, Z, Y - 1) == Block.BlockList.AIR)
{
Remove(l);
Add(l, new Gravel(X, Z, Y - 1));
l.BlockChange((ushort)X, (ushort)Z, (ushort)Y, Block.BlockList.AIR);
}
}
示例4: Tick
public override void Tick(Level l)
{
if (l.GetBlock(X, Z, Y - 1) == Block.BlockList.AIR)
{
Remove(l);
Add(l, new Sand(X, Z, Y - 1));
l.BlockChange((ushort)X, (ushort)Z, (ushort)Y, Block.BlockList.AIR);
return;
}
bool north = l.GetBlock(X + 1, Z, Y) == Block.BlockList.AIR;
bool south = l.GetBlock(X - 1, Z, Y) == Block.BlockList.AIR;
bool east = l.GetBlock(X, Z + 1, Y) == Block.BlockList.AIR;
bool west = l.GetBlock(X, Z - 1, Y) == Block.BlockList.AIR;
if (!north && !south && !east && !west)
return;
List<Vector2D> card = new List<Vector2D>();
if (north)
card.Add(new Vector2D(1, 0));
if (south)
card.Add(new Vector2D(-1, 0));
if (east)
card.Add(new Vector2D(0, 1));
if (west)
card.Add(new Vector2D(0, -1));
List<Vector2D> diag = new List<Vector2D>();
if (north && east)
diag.Add(new Vector2D(1, 1));
if (south && east)
diag.Add(new Vector2D(-1, 1));
if (north && west)
diag.Add(new Vector2D(1, -1));
if (south && west)
diag.Add(new Vector2D(-1, -1));
List<Vector2D> check = new List<Vector2D>();
while (card.Count > 0)
{
int i = new Random().Next(0, card.Count);
check.Add(card[i]);
card.RemoveAt(i);
}
while (diag.Count > 0)
{
int i = new Random().Next(0, diag.Count);
check.Add(diag[i]);
diag.RemoveAt(i);
}
for (int i = 0; i < check.Count; ++i)
{
int x = (int)check[i].x;
int z = (int)check[i].z;
int y = x * z == 0 ? 1 : 2;
if (l.GetBlock(X + x, Z + z, Y - y) == Block.BlockList.AIR && l.GetBlock(X + x, Z + z, Y - y + 1) == Block.BlockList.AIR)
{
Remove(l);
Add(l, new Sand(X + x, Z + z, Y - y));
l.BlockChange((ushort)X, (ushort)Z, (ushort)Y, Block.BlockList.AIR);
return;
}
}
}