本文整理汇总了C#中Level.GetTile方法的典型用法代码示例。如果您正苦于以下问题:C# Level.GetTile方法的具体用法?C# Level.GetTile怎么用?C# Level.GetTile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.GetTile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Do
public static void Do(Level lvl, Check C, Random rand) {
int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;
int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
for (int cx = -dirX; cx != 2 * dirX; cx += dirX)
for (int cy = -dirY; cy != 2 * dirY; cy += dirY)
for (int cz = -dirZ; cz != 2 * dirZ; cz += dirZ)
{
byte tileBelow = lvl.GetTile((ushort)(x + cx),(ushort)(y + cy - 1), (ushort)(z + cz));
byte tile = lvl.GetTile((ushort)(x + cx),(ushort)(y + cy), (ushort)(z + cz));
if ((tileBelow == Block.red || tileBelow == Block.op_air) &&
(tile == Block.air || tile == Block.water)) {
lvl.AddUpdate(lvl.PosToInt((ushort)(x + cx),
(ushort)(y + cy), (ushort)(z + cz)), Block.train);
lvl.AddUpdate(C.b, Block.air);
byte newBlock = tileBelow == Block.red ? Block.obsidian : Block.glass;
lvl.AddUpdate(lvl.IntOffset(C.b, 0, -1, 0), newBlock, true,
"wait 5 revert " + tileBelow.ToString());
return;
}
}
}
示例2: Do
public static void Do(Level lvl, Check C, Random rand) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
if (lvl.GetTile(x, (ushort)(y - 1), z) != Block.lavastill)
return;
if (lvl.GetTile(x, (ushort)(y + 1), z) == Block.air) {
bool keepGoing = true;
if ((lvl.Height * 80 / 100) < y)
keepGoing = rand.Next(1, 20) > 1;
if (keepGoing) {
int bAbove = lvl.PosToInt(x, (ushort)(y + 1), z);
bool unblocked = !lvl.ListUpdate.Exists(u => u.b == bAbove);
if (unblocked) {
lvl.AddUpdate(bAbove, Block.firework, false);
lvl.AddUpdate(C.b, Block.lavastill, false, "wait 1 dissipate 100");
C.extraInfo = "wait 1 dissipate 100";
return;
}
}
}
Firework(x, y, z, 4, lvl, rand);
}
示例3: DoWaterOrLava
public unsafe static void DoWaterOrLava(Level lvl, Check C, Random rand) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
byte tileBelow = lvl.GetTile(x, (ushort)(y - 1), z);
if (tileBelow == Block.air) {
lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), lvl.blocks[C.b], false, C.extraInfo);
lvl.AddUpdate(C.b, Block.air);
C.extraInfo = "";
} else if (tileBelow == Block.waterstill || tileBelow == Block.lavastill) {
lvl.AddUpdate(C.b, Block.air);
C.extraInfo = "";
} else {
const int count = 25;
int* indices = stackalloc int[count];
for (int i = 0; i < count; ++i)
indices[i] = i;
for (int k = count - 1; k > 1; --k) {
int randIndx = rand.Next(k);
int temp = indices[k];
indices[k] = indices[randIndx]; // move random num to end of list.
indices[randIndx] = temp;
}
for (int j = 0; j < count; j++) {
int i = indices[j];
ushort posX = (ushort)(x + (i / 5) - 2);
ushort posZ = (ushort)(z + (i % 5) - 2);
if (lvl.GetTile(posX, (ushort)(y - 1), posZ) == Block.air &&
lvl.GetTile(posX, y, posZ) == Block.air)
{
if (posX < x)
posX = (ushort)(Math.Floor((double)(posX + x) / 2));
else
posX = (ushort)(Math.Ceiling((double)(posX + x) / 2));
if (posZ < z)
posZ = (ushort)(Math.Floor((double)(posZ + z) / 2));
else
posZ = (ushort)(Math.Ceiling((double)(posZ + z) / 2));
int index = lvl.PosToInt(posX, y, posZ);
if (index >= 0 && lvl.blocks[index] == Block.air &&
lvl.AddUpdate(index, lvl.blocks[C.b], false, C.extraInfo))
{
lvl.AddUpdate(C.b, Block.air);
C.extraInfo = "";
return;
}
}
}
}
}
示例4: Do
public static void Do(Level lvl, Check C, Random rand) {
int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;
int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
for (int cx = -dirX; cx != 2 * dirX; cx += dirX)
for (int cy = -dirY; cy != 2 * dirY; cy += dirY)
for (int cz = -dirZ; cz != 2 * dirZ; cz += dirZ)
{
byte rocketTail = lvl.GetTile((ushort)(x + cx), (ushort)(y + cy), (ushort)(z + cz));
if (rocketTail != Block.fire) continue;
int headIndex = lvl.PosToInt((ushort)(x - cx), (ushort)(y - cy), (ushort)(z - cz));
byte rocketHead = headIndex < 0 ? Block.Zero : lvl.blocks[headIndex];
bool unblocked = !lvl.ListUpdate.Exists(u => u.b == headIndex || u.b == C.b);
if (unblocked && (rocketHead == Block.air || rocketHead == Block.rocketstart)) {
lvl.AddUpdate(headIndex, Block.rockethead);
lvl.AddUpdate(C.b, Block.fire);
} else if (rocketHead == Block.fire) {
} else {
if (lvl.physics > 2)
lvl.MakeExplosion(x, y, z, 2);
else
lvl.AddUpdate(C.b, Block.fire);
}
}
}
示例5: DoGeyser
public static void DoGeyser(Level lvl, Check C, Random rand) {
C.time++;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
byte below = lvl.GetTile(x, (ushort)(y - 1), z);
if (below == Block.air) {
lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), Block.geyser);
} else if (below != Block.geyser) {
byte block = lvl.blocks[C.b];
lvl.PhysWater(lvl.PosToInt((ushort)(x + 1), y, z), block);
lvl.PhysWater(lvl.PosToInt((ushort)(x - 1), y, z), block);
lvl.PhysWater(lvl.PosToInt(x, y, (ushort)(z + 1)), block);
lvl.PhysWater(lvl.PosToInt(x, y, (ushort)(z - 1)), block);
}
if (lvl.physics <= 1 || C.time <= 10) return;
C.time = 0;
bool flowUp = false;
GeyserFlow(lvl, x - 1, y, z, ref flowUp);
GeyserFlow(lvl, x + 1, y, z, ref flowUp);
GeyserFlow(lvl, x, y - 1, z, ref flowUp);
GeyserFlow(lvl, x, y, z - 1, ref flowUp);
GeyserFlow(lvl, x, y, z + 1, ref flowUp);
if (flowUp)
GeyserFlow(lvl, x, y + 1, z, ref flowUp);
}
示例6: AddCactus
public static void AddCactus(Level l, ushort x, ushort y, ushort z, byte type)
{
ushort num2;
byte num = (byte)random.Next(3, 6);
for (num2 = 0; num2 <= num; num2 = (ushort)(num2 + 1))
{
l.Blockchange(x, (ushort)(y + num2), z, 0x19);
}
int num3 = 0;
int num4 = 0;
switch (random.Next(1, 3))
{
case 1:
num3 = -1;
break;
default:
num4 = -1;
break;
}
num2 = num;
while (num2 <= random.Next(num + 2, num + 5))
{
ushort x2 = (ushort)(x + num3); //width
ushort y2 = (ushort)(y + num2); //depth
ushort z2 = (ushort)(z + num4); //height
if (l.GetTile(x2, y2, z2) == 0)
{
l.Blockchange((ushort)(x + num3), (ushort)(y + num2), (ushort)(z + num4), 0x19);
}
num2 = (ushort)(num2 + 1);
}
for (num2 = num; num2 <= random.Next(num + 2, num + 5); num2 = (ushort)(num2 + 1))
{
ushort x2 = (ushort)(x - num3); //width
ushort y2 = (ushort)(y + num2); //depth
ushort z2 = (ushort)(z - num4); //height
if (l.GetTile(x2, y2, z2) == 0)
{
l.Blockchange((ushort)(x - num3), (ushort)(y + num2), (ushort)(z - num4), 0x19);
}
}
}
示例7: DoSmallTnt
public static void DoSmallTnt(Level lvl, Check C, Random rand) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
if (C.p != null && C.p.PlayingTntWars) {
int power = 2, threshold = 3;
switch (TntWarsGame.GetTntWarsGame(C.p).GameDifficulty) {
case TntWarsGame.TntWarsDifficulty.Easy:
threshold = 7;
break;
case TntWarsGame.TntWarsDifficulty.Normal:
threshold = 5;
break;
case TntWarsGame.TntWarsDifficulty.Extreme:
power = 3;
break;
}
if (C.time < threshold) {
C.time++;
lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
? Block.air : Block.lavastill);
return;
}
if (C.p.TntWarsKillStreak >= TntWarsGame.Properties.DefaultStreakTwoAmount
&& TntWarsGame.GetTntWarsGame(C.p).Streaks) {
power++;
}
lvl.MakeExplosion(x, y, z, power - 2, true, TntWarsGame.GetTntWarsGame(C.p));
List<Player> Killed = new List<Player>();
Player.players.ForEach(
delegate(Player p1)
{
if (p1.level == lvl && p1.PlayingTntWars && p1 != C.p
&& Math.Abs((int)(p1.pos[0] / 32) - x) + Math.Abs((int)(p1.pos[1] / 32) - y) + Math.Abs((int)(p1.pos[2] / 32) - z) < ((power * 3) + 1)) {
Killed.Add(p1);
}
});
TntWarsGame.GetTntWarsGame(C.p).HandleKill(C.p, Killed);
} else {
if (lvl.physics < 3) {
lvl.Blockchange(x, y, z, Block.air);
} else {
if (C.time < 5 && lvl.physics == 3) {
C.time++;
lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill
? Block.air : Block.lavastill);
return;
}
lvl.MakeExplosion(x, y, z, 0);
}
}
}
示例8: ExpandDiagonal
static void ExpandDiagonal(Level lvl, ushort x, ushort y, ushort z,
int xOffset, int yOffset, int zOffset) {
if (!Block.FireKill(lvl.GetTile((ushort)(x + xOffset),
(ushort)(y + yOffset), (ushort)(z + zOffset))))
return;
if (xOffset != 0)
lvl.AddUpdate(lvl.PosToInt((ushort)(x + xOffset), y, z), Block.fire);
if (yOffset != 0)
lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y + yOffset), z), Block.fire);
if (zOffset != 0)
lvl.AddUpdate(lvl.PosToInt(x, y, (ushort)(z + zOffset)), Block.fire);
}
示例9: ShowWarningFuse
static void ShowWarningFuse(Level lvl, ushort x, ushort y, ushort z) {
lvl.Blockchange(x, (ushort)(y + 1), z, lvl.GetTile(x, (ushort)(y + 1), z) == Block.lavastill ? Block.air : Block.lavastill);
lvl.Blockchange(x, (ushort)(y - 1), z, lvl.GetTile(x, (ushort)(y - 1), z) == Block.lavastill ? Block.air : Block.lavastill);
lvl.Blockchange((ushort)(x + 1), y, z, lvl.GetTile((ushort)(x + 1), y, z) == Block.lavastill ? Block.air : Block.lavastill);
lvl.Blockchange((ushort)(x - 1), y, z, lvl.GetTile((ushort)(x - 1), y, z) == Block.lavastill ? Block.air : Block.lavastill);
lvl.Blockchange(x, y, (ushort)(z + 1), lvl.GetTile(x, y, (ushort)(z + 1)) == Block.lavastill ? Block.air : Block.lavastill);
lvl.Blockchange(x, y, (ushort)(z - 1), lvl.GetTile(x, y, (ushort)(z - 1)) == Block.lavastill ? Block.air : Block.lavastill);
}
示例10: Do
public static void Do(Level lvl, Check C, Random rand) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
switch (rand.Next(1, 15)) {
case 1:
if (lvl.GetTile(x, (ushort)(y - 1), z) == Block.air)
lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), lvl.blocks[C.b]);
else goto case 3;
break;
case 2:
if (lvl.GetTile(x, (ushort)(y + 1), z) == Block.air)
lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y + 1), z), lvl.blocks[C.b]);
else goto case 6;
break;
case 3:
case 4:
case 5:
FlyTo(lvl, C, x - 1, y, z);
break;
case 6:
case 7:
case 8:
FlyTo(lvl, C, x + 1, y, z);
break;
case 9:
case 10:
case 11:
FlyTo(lvl, C, x, y, z - 1);
break;
default:
FlyTo(lvl, C, x, y, z + 1);
break;
}
lvl.AddUpdate(C.b, Block.air);
C.time = 255;
}
示例11: Firework
static void Firework(ushort x, ushort y, ushort z, int size, Level lvl, Random rand) {
if (lvl.physics < 1 || lvl.physics == 5) return;
int rand1 = rand.Next(Block.red, Block.white);
int rand2 = rand.Next(Block.red, Block.white);
int min = Math.Min(rand1, rand2), max = Math.Max(rand1, rand2);
// Not using override, since override = true makes it more likely that a colored block will be
// generated with no extraInfo, because it sets a Check for that position with no extraInfo.
lvl.AddUpdate(lvl.PosToInt(x, y, z), Block.air);
for (ushort yy = (ushort)(y - (size + 1)); yy <= (ushort)(y + (size + 1)); ++yy)
for (ushort zz = (ushort)(z - (size + 1)); zz <= (ushort)(z + (size + 1)); ++zz)
for (ushort xx = (ushort)(x - (size + 1)); xx <= (ushort)(x + (size + 1)); ++xx)
{
if (lvl.GetTile(xx, yy, zz) == Block.air && rand.Next(1, 40) < 2)
lvl.AddUpdate(lvl.PosToInt(xx, yy, zz), (byte)rand.Next(min, max),
false, "drop 100 dissipate 25");
}
}
示例12: MoveSnakeY
static bool MoveSnakeY(Level lvl, Check C, int index ) {
byte block = lvl.GetTile(index);
byte blockAbove = lvl.GetTile(lvl.IntOffset(index, 0, 1, 0));
byte block2Above = lvl.GetTile(lvl.IntOffset(index, 0, 2, 0));
if (block == Block.air &&
(blockAbove == Block.grass ||
blockAbove == Block.dirt && block2Above == Block.air)) {
if (lvl.AddUpdate(index, lvl.blocks[C.b])) {
lvl.AddUpdate(C.b, Block.snaketail, true, "wait 5 revert 0");
return true;
}
}
return false;
}
示例13: MoveSnake
static bool MoveSnake(Level lvl, Check C, int index) {
if (
lvl.GetTile(lvl.IntOffset(index, 0, -1, 0)) == Block.air &&
lvl.GetTile(index) == Block.air) {
index = lvl.IntOffset(index, 0, -1, 0);
} else if (
lvl.GetTile(index) == Block.air &&
lvl.GetTile(lvl.IntOffset(index, 0, 1, 0)) == Block.air) {
} else if (
lvl.GetTile(lvl.IntOffset(index, 0, 2, 0)) == Block.air &&
lvl.GetTile(lvl.IntOffset(index, 0, 1, 0)) == Block.air) {
index = lvl.IntOffset(index, 0, 1, 0);
}
if (lvl.AddUpdate(index, lvl.blocks[C.b])) {
lvl.AddUpdate(C.b, Block.snaketail, true, "wait 5 revert 0");
return true;
}
return false;
}
示例14: NukeS
public static void NukeS(Level l, ushort x, ushort y, ushort z, int size)
{
foreach (Player p in Player.players) if (p.level == l) p.SendBlockchange(x, y, z, 0);
List<string> toair = new List<string>();
int num3 = size;
for (short j = Convert.ToInt16(-num3); j <= num3; j = (short)(j + 1))
{
if ((x + j) < 0 || (x + j) > l.width) continue;
for (short k = Convert.ToInt16(-num3); k <= num3; k = (short)(k + 1))
{
if ((y + k) < 0 || (y + k) > l.depth) continue;
for (short m = Convert.ToInt16(-num3); m <= num3; m = (short)(m + 1))
{
if ((z + m) < 0 || (z + m) > l.length) continue;
short maxValue = (short)Math.Sqrt((double)(((j * j) + (k * k)) + (m * m))); //W00t FOUND THE SECRET!
if ((maxValue < (num3 + 1)) && (random.Next(maxValue) < size))
{
try
{
ushort x2 = (ushort)(x + j); //width
ushort y2 = (ushort)(y + k); //depth
ushort z2 = (ushort)(z + m); //height
if (x2 <= l.width && y2 <= l.depth && z2 <= l.length)
{
byte that = l.GetTile((ushort)(x + j), (ushort)((y + k)), (ushort)(z + m));
if (that != 7)
{
l.Blockchange((ushort)(x + j), (ushort)((y + k)), (ushort)(z + m), 0);
}
}
}
catch (Exception e)
{
Server.s.Log(e.Message);
}
}
}
}
}
}
示例15: AnyDoor
static void AnyDoor(Level lvl, Check C, ushort x, ushort y, ushort z, int timer, bool instaUpdate = false) {
if (C.time != 0) {
CheckDoorRevert(lvl, C, timer);
return;
}
PhysDoor(lvl, (ushort)(x + 1), y, z, instaUpdate);
PhysDoor(lvl, (ushort)(x - 1), y, z, instaUpdate);
PhysDoor(lvl, x, y, (ushort)(z + 1), instaUpdate);
PhysDoor(lvl, x, y, (ushort)(z - 1), instaUpdate);
PhysDoor(lvl, x, (ushort)(y - 1), z, instaUpdate);
PhysDoor(lvl, x, (ushort)(y + 1), z, instaUpdate);
if (lvl.blocks[C.b] != Block.door8_air) {
CheckDoorRevert(lvl, C, timer);
return;
}
for (int xx = -1; xx <= 1; xx++)
for (int yy = -1; yy <= 1; yy++)
for (int zz = -1; zz <= 1; zz++)
{
byte b = lvl.GetTile(lvl.IntOffset(C.b, xx, yy, zz));
if (b == Block.rocketstart) {
if (lvl.physics == 5) {
lvl.Blockchange(x, y, z, Block.air);
return;
}
int b1 = lvl.IntOffset(C.b, xx * 3, yy * 3, zz * 3);
int b2 = lvl.IntOffset(C.b, xx * 2, yy * 2, zz * 2);
bool unblocked = lvl.GetTile(b1) == Block.air && lvl.GetTile(b2) == Block.air &&
!lvl.ListUpdate.Exists(u => u.b == b1) &&
!lvl.ListUpdate.Exists(u => u.b == b2);
if (unblocked) {
lvl.AddUpdate(b1, Block.rockethead);
lvl.AddUpdate(b2, Block.fire);
}
} else if (b == Block.firework) {
if (lvl.physics == 5) {
lvl.Blockchange(x, y, z, Block.air);
return;
}
int b1 = lvl.IntOffset(C.b, xx, yy + 1, zz);
int b2 = lvl.IntOffset(C.b, xx, yy + 2, zz);
bool unblocked = lvl.GetTile(b1) == Block.air && lvl.GetTile(b2) == Block.air &&
!lvl.ListUpdate.Exists(u => u.b == b1) &&
!lvl.ListUpdate.Exists(u => u.b == b2);
if (unblocked) {
lvl.AddUpdate(b2, Block.firework);
lvl.AddUpdate(b1, Block.lavastill, false, "dissipate 100");
}
} else if (b == Block.tnt) {
if (lvl.physics == 5) {
lvl.Blockchange(x, y, z, Block.air);
return;
}
lvl.MakeExplosion((ushort)(x + xx), (ushort)(y + yy), (ushort)(z + zz), 0);
}
}
CheckDoorRevert(lvl, C, timer);
}