本文整理汇总了C#中Level.SetBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Level.SetBlock方法的具体用法?C# Level.SetBlock怎么用?C# Level.SetBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level.SetBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
public Level Load(string levelName, string path)
{
Level finalLevel = new Level(new Vector3S(32, 32, 32));
finalLevel.Name = levelName;
using (FileStream fs = File.OpenRead(path)) {
using (GZipStream gs = new GZipStream(fs, CompressionMode.Decompress)) {
byte[] ver = new byte[2];
gs.Read(ver, 0, ver.Length);
ushort version = BitConverter.ToUInt16(ver, 0);
//if (version != 1874) //Is a old MCForge level!
// throw new Exception(path + " is not a valid MCForge Level");
// Older levels WILL STILL WORK WITH THIS so you don't need this check. .dat files won't load though.
ushort[] vars = new ushort[6];
byte[] rot = new byte[2];
byte[] header = new byte[16];
gs.Read(header, 0, header.Length);
vars[0] = BitConverter.ToUInt16(header, 0); //X
vars[1] = BitConverter.ToUInt16(header, 2); //Z
vars[2] = BitConverter.ToUInt16(header, 4); //Y
vars[3] = BitConverter.ToUInt16(header, 6); //SpawnX
vars[4] = BitConverter.ToUInt16(header, 8); //SpawnZ
vars[5] = BitConverter.ToUInt16(header, 10); //SpawnY
rot[0] = header[12]; //SpawnHeading
rot[1] = header[13]; //SpawnYaw
finalLevel.CWMap.Size = new Vector3S((short)vars[0], (short)vars[1], (short)vars[2]);
finalLevel.CWMap.SpawnPos = new Vector3S((short)vars[3], (short)vars[4], (short)vars[5]);
finalLevel.CWMap.SpawnRotation = new Vector2S(rot[0], rot[1]);
finalLevel.TotalBlocks = finalLevel.CWMap.Size.x * finalLevel.CWMap.Size.z * finalLevel.CWMap.Size.y;
byte[] blocks = new byte[finalLevel.CWMap.Size.x * finalLevel.CWMap.Size.z * finalLevel.CWMap.Size.y];
gs.Read(blocks, 0, blocks.Length);
finalLevel.CWMap.BlockData = new byte[finalLevel.TotalBlocks];
for (int x = 0; x < finalLevel.CWMap.Size.x; x++)
for (int y = 0; y < finalLevel.CWMap.Size.y; y++)
for (int z = 0; z < finalLevel.CWMap.Size.z; z++)
finalLevel.SetBlock(x, z, y, (byte)OldMCForgeToNewMCForge.Convert(blocks[finalLevel.PosToInt((ushort)x, (ushort)z, (ushort)y)])); //Converts all custom blocks to normal blocks.
}
}
finalLevel.HandleMetaData();
Logger.Log("[Level] " + levelName + " was loaded");
return finalLevel;
}
示例2: Tick
public override void Tick(Level l)
{
if (level == null) level = l;
state = true;
l.SetBlock(l.PosToInt(X, Z, Y), open);
time += 16;
if (time >= 16)
{
l.SetBlock(l.PosToInt(X, Z, Y), closed);
state = false;
time = 0;
}
}