本文整理汇总了C#中Level.IntToPos方法的典型用法代码示例。如果您正苦于以下问题:C# Level.IntToPos方法的具体用法?C# Level.IntToPos怎么用?C# Level.IntToPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.IntToPos方法的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 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);
}
}
}
示例2: DoFlood
public static void DoFlood(Level lvl, Check C, Random rand, AirFlood mode, byte block) {
if (C.time >= 1) {
lvl.AddUpdate(C.b, 0);
C.time = 255; return;
}
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
FloodAir(lvl, lvl.PosToInt((ushort)(x + 1), y, z), block);
FloodAir(lvl, lvl.PosToInt((ushort)(x - 1), y, z), block);
FloodAir(lvl, lvl.PosToInt(x, y, (ushort)(z + 1)), block);
FloodAir(lvl, lvl.PosToInt(x, y, (ushort)(z - 1)), block);
switch (mode) {
case AirFlood.Full:
FloodAir(lvl, lvl.PosToInt(x, (ushort)(y - 1), z), block);
FloodAir(lvl, lvl.PosToInt(x, (ushort)(y + 1), z), block);
break;
case AirFlood.Layer:
break;
case AirFlood.Down:
FloodAir(lvl, lvl.PosToInt(x, (ushort)(y - 1), z), block);
break;
case AirFlood.Up:
FloodAir(lvl, lvl.PosToInt(x, (ushort)(y + 1), z), block);
break;
}
C.time++;
}
示例3: 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);
}
示例4: 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);
}
示例5: 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;
}
}
}
示例6: ClosestPlayer
public static Player ClosestPlayer(Level lvl, Check C) {
if (!lvl.ai) return null;
int closestDist = 75;
Player closetPlayer = null;
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
Player.players.ForEach(
delegate(Player p)
{
if (p.level == lvl && !p.invincible) {
int curDist = Math.Abs((p.pos[0] / 32) - x) +
Math.Abs((p.pos[1] / 32) - y) +
Math.Abs((p.pos[2] / 32) - z);
if (curDist < closestDist) {
closestDist = curDist;
closetPlayer = p;
}
}
}
);
return closetPlayer;
}
示例7: 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 (C.time < 2) {
C.time++;
return;
}
if (rand.Next(1, 20) == 1 && C.time % 2 == 0) {
int max = rand.Next(1, 18);
if (max <= 3 && ExpandSimple(lvl, x - 1, y, z)) {
} else if (max <= 6 && ExpandSimple(lvl, x + 1, y, z)) {
} else if (max <= 9 && ExpandSimple(lvl, x, y - 1, z)) {
} else if (max <= 12 && ExpandSimple(lvl, x, y + 1, z)) {
} else if (max <= 15 && ExpandSimple(lvl, x, y, z - 1)) {
} else if (max <= 18 && ExpandSimple(lvl, x, y, z + 1)) {
}
}
for (int yy = -1; yy <= 1; yy++ ) {
ExpandDiagonal(lvl, x, y, z, -1, yy, -1);
ExpandDiagonal(lvl, x, y, z, +1, yy, -1);
ExpandDiagonal(lvl, x, y, z, -1, yy, +1);
ExpandDiagonal(lvl, x, y, z, +1, yy, +1);
}
if (lvl.physics >= 2) {
if (C.time < 4) {
C.time++;
return;
}
ExpandAvanced(lvl, x - 1, y, z);
ExpandAvanced(lvl, x + 1, y, z);
ExpandAvanced(lvl, x, y - 1, z);
ExpandAvanced(lvl, x, y + 1, z);
ExpandAvanced(lvl, x, y, z - 1);
ExpandAvanced(lvl, x, y, z + 1);
}
C.time++;
if (C.time > 5) {
int dropType = rand.Next(1, 10);
if (dropType <= 2) {
lvl.AddUpdate(C.b, Block.coal);
C.extraInfo = "drop 63 dissipate 10";
} else if (dropType <= 4) {
lvl.AddUpdate(C.b, Block.obsidian);
C.extraInfo = "drop 63 dissipate 10";
} else if (dropType <= 8)
lvl.AddUpdate(C.b, Block.air);
else
C.time = 3;
}
}
示例8: 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);
}
}
}
示例9: 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;
}
}
}
}
}
示例10: DoLargeTnt
public static void DoLargeTnt(Level lvl, Check C, Random rand, int power) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
if (lvl.physics < 3) {
lvl.Blockchange(x, y, z, Block.air);
} else {
if (C.time < 5 && lvl.physics == 3) {
C.time++;
ShowWarningFuse(lvl, x, y, z);
return;
}
lvl.MakeExplosion(x, y, z, power);
}
}
示例11: DoFlee
public static void DoFlee(Level lvl, Check C, Random rand, byte target) {
Player closest = AIPhysics.ClosestPlayer(lvl, C);
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
if (closest != null && rand.Next(1, 20) < 19) {
int index = 0, dirsVisited = 0;
switch (rand.Next(1, 10)) {
case 1:
case 2:
case 3:
if ((closest.pos[0] / 32) - x != 0) {
index = lvl.PosToInt((ushort)(x - Math.Sign((closest.pos[0] / 32) - x)), y, z);
if (MoveFish(lvl, C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
goto case 4;
case 4:
case 5:
case 6:
if ((closest.pos[1] / 32) - y != 0) {
index = lvl.PosToInt(x, (ushort)(y - Math.Sign((closest.pos[1] / 32) - y)), z);
if (MoveFish(lvl, C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
goto case 7;
case 7:
case 8:
case 9:
if ((closest.pos[2] / 32) - z != 0) {
index = lvl.PosToInt(x, y, (ushort)(z - Math.Sign((closest.pos[2] / 32) - z)));
if (MoveFish(lvl, C, index, target)) return;
}
dirsVisited++;
if (dirsVisited >= 3) break;
goto case 1;
}
}
RandomlyMove(lvl, C, rand, x, y, z, target);
}
示例12: DoAir
public static void DoAir(Level lvl, Check C, Random rand) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
PhysAir(lvl, lvl.PosToInt((ushort)(x + 1), y, z));
PhysAir(lvl, lvl.PosToInt((ushort)(x - 1), y, z));
PhysAir(lvl, lvl.PosToInt(x, y, (ushort)(z + 1)));
PhysAir(lvl, lvl.PosToInt(x, y, (ushort)(z - 1)));
PhysAir(lvl, lvl.PosToInt(x, (ushort)(y + 1), z));
PhysAir(lvl, lvl.PosToInt(x, (ushort)(y - 1), z));
//Edge of map water
if (lvl.edgeWater && (y < lvl.Height / 2 && y >= (lvl.Height / 2) - 2)) {
if (x == 0 || x == lvl.Width - 1 || z == 0 || z == lvl.Length - 1)
lvl.AddUpdate(C.b, Block.water);
}
if (!C.extraInfo.Contains("wait"))
C.time = 255;
}
示例13: 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;
}
示例14: DoWaterfall
public static void DoWaterfall(Level lvl, Check C, Random rand) {
ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z);
byte below = lvl.GetTile(x, (ushort)(y - 1), z);
switch (below)
{
case Block.air:
lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), Block.WaterDown);
if (C.extraInfo.IndexOf("wait") == -1)
C.time = 255;
break;
case Block.air_flood_down:
case Block.lavastill:
case Block.waterstill:
case Block.WaterDown:
break;
default:
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 (C.extraInfo.IndexOf("wait") == -1)
C.time = 255;
break;
}
}
示例15: 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);
// Make zombie fall down
if (lvl.GetTile(x, (ushort)(y - 1), z) == Block.air) {
lvl.AddUpdate(C.b, Block.zombiehead);
lvl.AddUpdate(lvl.IntOffset(C.b, 0, -1, 0), lvl.blocks[C.b]);
lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
return;
}
bool checkTime = true;
int index = 0;
Player closest = AIPhysics.ClosestPlayer(lvl, C);
if (closest != null && rand.Next(1, 20) < 18) {
if (rand.Next(1, 7) <= 3) {
index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
if (index != C.b && MoveZombie(lvl, C, index)) return;
index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
if (index != C.b && MoveZombie(lvl, C, index)) return;
} else {
index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
if (index != C.b && MoveZombie(lvl, C, index)) return;
index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
if (index != C.b && MoveZombie(lvl, C, index)) return;
}
checkTime = false;
}
if (checkTime && C.time < 3) {
C.time++;
return;
}
int dirsVisited = 0;
switch (rand.Next(1, 13))
{
case 1:
case 2:
case 3:
index = lvl.IntOffset(C.b, -1, 0, 0);
if (MoveZombie(lvl, C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
goto case 4;
case 4:
case 5:
case 6:
index = lvl.IntOffset(C.b, 1, 0, 0);
if (MoveZombie(lvl, C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
goto case 7;
case 7:
case 8:
case 9:
index = lvl.IntOffset(C.b, 0, 0, 1);
if (MoveZombie(lvl, C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
goto case 10;
case 10:
case 11:
case 12:
index = lvl.IntOffset(C.b, 0, 0, -1);
if (MoveZombie(lvl, C, index)) return;
dirsVisited++;
if (dirsVisited >= 4) return;
goto case 1;
}
lvl.AddUpdate(C.b, Block.air);
lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
}