本文整理汇总了C#中MCForge.Level.PosToInt方法的典型用法代码示例。如果您正苦于以下问题:C# Level.PosToInt方法的具体用法?C# Level.PosToInt怎么用?C# Level.PosToInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCForge.Level
的用法示例。
在下文中一共展示了Level.PosToInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlayerBot
//.........这里部分代码省略.........
}
};
jumpTimer.Start();
currentPoint++;
if (currentPoint == Waypoints.Count) currentPoint = 0;
if (!skip) { skip = true; goto retry; }
break;
}
if (currentPoint == Waypoints.Count) currentPoint = 0;
}
if (!movement)
{
if (rot[0] < 245) rot[0] += 8;
else rot[0] = 0;
if (rot[1] > 32 && rot[1] < 64) rot[1] = 224;
else if (rot[1] > 250) rot[1] = 0;
else rot[1] += 4;
}
};
botTimer.Start();
moveTimer.Elapsed += delegate
{
moveTimer.Interval = Server.updateTimer.Interval / movementSpeed;
if (!movement) return;
int newNum;// Random rand = new Random();
if ((pos[1] - 19) % 32 != 0 && !jumping)
{
pos[1] = (ushort)((pos[1] + 19) - (pos[1] % 32));
}
x = (ushort)Math.Round((decimal)(pos[0] - 16) / (decimal)32);
y = (ushort)((pos[1] - 64) / 32);
z = (ushort)Math.Round((decimal)(pos[2] - 16) / (decimal)32);
ushort b = Block.Convert(level.GetTile(x, y, z));
ushort b1, b2, b3;//, b4;
if (Block.Walkthrough(b) && !jumping)
{
pos[1] = (ushort)(pos[1] - 32);
}
y = (ushort)((pos[1] - 64) / 32); //Block below feet
newNum = level.PosToInt((ushort)(x + Math.Sign(foundPos[0] - pos[0])), y, (ushort)(z + Math.Sign(foundPos[2] - pos[2])));
b = Block.Convert(level.GetTile(newNum));
b1 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 1, 0)));
b2 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 2, 0)));
b3 = Block.Convert(level.GetTile(level.IntOffset(newNum, 0, 3, 0)));
if (Block.Walkthrough(b2) && Block.Walkthrough(b3) && !Block.Walkthrough(b1))
{ //Get ready to go up step
pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
pos[1] += (ushort)32;
pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
}
else if (Block.Walkthrough(b1) && Block.Walkthrough(b2))
{ //Stay on current level
pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
}
else if (Block.Walkthrough(b) && Block.Walkthrough(b1))
{ //Drop a level
pos[0] += (ushort)Math.Sign(foundPos[0] - pos[0]);
pos[1] -= (ushort)32;
pos[2] += (ushort)Math.Sign(foundPos[2] - pos[2]);
}
x = (ushort)Math.Round((decimal)(pos[0] - 16) / (decimal)32);
y = (ushort)((pos[1] - 64) / 32);
z = (ushort)Math.Round((decimal)(pos[2] - 16) / (decimal)32);
b1 = Block.Convert(level.GetTile(x, (ushort)(y + 1), z));
b2 = Block.Convert(level.GetTile(x, (ushort)(y + 2), z));
b3 = Block.Convert(level.GetTile(x, y, z));
/*
if ((ushort)(foundPos[1] / 32) > y) {
if (b1 == Block.water || b1 == Block.waterstill || b1 == Block.lava || b1 == Block.lavastill) {
if (Block.Walkthrough(b2)) {
pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
}
} else if (b2 == Block.water || b2 == Block.waterstill || b2 == Block.lava || b2 == Block.lavastill) {
pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
}
} else if ((ushort)(foundPos[1] / 32) < y) {
if (b3 == Block.water || b3 == Block.waterstill || b3 == Block.lava || b3 == Block.lavastill) {
pos[1] = (ushort)(pos[1] + (Math.Sign(foundPos[1] - pos[1])));
}
}*/
};
moveTimer.Start();
}
示例2: GetTile
public byte GetTile(ushort x, ushort y, ushort z, Level l, byte[] blocks)
{
//if (PosToInt(x, y, z) >= blocks.Length) { return null; }
//Avoid internal overflow
if (x < 0) { return Block.Zero; }
if (x >= l.width) { return Block.Zero; }
if (y < 0) { return Block.Zero; }
if (y >= l.depth) { return Block.Zero; }
if (z < 0) { return Block.Zero; }
if (z >= l.height) { return Block.Zero; }
try
{
return blocks[l.PosToInt(x, y, z)];
}
catch (Exception e) { Server.ErrorLog(e); return Block.Zero; }
}