本文整理汇总了C#中Block.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Block.GetLength方法的具体用法?C# Block.GetLength怎么用?C# Block.GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block.GetLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceGround
public override void ReplaceGround(BiomeData bd, Block[, ,] blocks)
{
for (int x = 0; x < blocks.GetLength(0); x++)
for (int y = 0; y < blocks.GetLength(1); y++)
if (this.SuitableSampleAverage(bd, x, y))
for (int z = 0; z < blocks.GetLength(2); z++)
if (blocks[x, y, z] == Block.GrassBlock)
blocks[x, y, z] = Block.SandGrassBlock;
base.ReplaceGround(bd, blocks);
}
示例2: ToRealChunk
public static Chunk ToRealChunk(int[,] chunkAsNumbers, int chunkOffset)
{
if (chunkLoader==null) chunkLoader=GameObject.Find("ChunkLoader").GetComponent<ChunkLoader>();
Block[,] blocks=new Block[chunkLoader.CHUNK_WIDTH, chunkLoader.MAX_SKY_HEIGHT-chunkLoader.BEDROCK_LEVEL];
for (int x=0; x<blocks.GetLength(0); x++) {
for (int y=0; y<blocks.GetLength(1); y++) {
Vector3 blockPosition=new Vector3(x+chunkLoader.CHUNK_WIDTH*chunkOffset, y+chunkLoader.BEDROCK_LEVEL, 0);
blocks[x, y]=(Block)Instantiate(chunkLoader.blockPrefabs[chunkAsNumbers[x, y]], blockPosition, Quaternion.identity);
}
}
Chunk toReturn=(Chunk)Instantiate(chunkLoader.chunkPrefab, new Vector3(0, 0, 0), Quaternion.identity);
toReturn.setBlocks(blocks, chunkOffset);
return toReturn;
}
示例3: CheckSolid
protected override bool CheckSolid(Block[,,] blocks, int x, int y, int z, Direction direction) {
if (x < 0 || x > blocks.GetLength(0) - 1) {
return true;
}
if (y < 0 || y > blocks.GetLength(1) - 1) {
return true;
}
if (z < 0 || z > blocks.GetLength(2) - 1) {
return true;
}
if (direction == Direction.Down) {
return true;
}
return !(blocks[x, y, z].GetSolidity(direction) == BlockSolidity.Block || blocks[x, y, z].GetSolidity(direction) == BlockSolidity.Floor);
}
示例4: SerializeToString
public static string SerializeToString(Block[,,] array)
{
var charArray = new char[array.GetLength(0),array.GetLength(1),array.GetLength(2)];
for(int z = 0; z < array.GetLength(2); z++)
{
for(int y = 0; y < array.GetLength(1); y++)
{
for(int x = 0; x < array.GetLength(0); x++)
{
if(array[x,y,z] != null)
{
charArray[x,y,z] = array[x,y,z].ToChar();
}
else
{
charArray[x,y,z] = '_';
}
}
}
}
return SerializeToString(charArray);
}
示例5: LoadBlocks
void LoadBlocks(Block[,] blocks, uint startX, uint startY, bool silverBot, uint startSilverBotX, uint startSilverBotY)
{
if (silverBot)
{
blocks[startSilverBotX, startSilverBotY] = (Block)0xFE;
blocks[startSilverBotX + 1, startSilverBotY] = (Block)0xFD;
blocks[startSilverBotX, startSilverBotY + 1] = (Block)0xFD;
blocks[startSilverBotX + 1, startSilverBotY + 1] = (Block)0xFE;
}
blocks[startX, startY] = (Block)0xFF;
textBox1.Text = "";
for (int y = 0; y < blocks.GetLength(1); y++)
{
for (int x = 0; x < blocks.GetLength(0); x++)
{
Block current = blocks[x, y];
char currentChar = ParseBlock(current);
textBox1.Text += currentChar;
}
if (y < blocks.GetLength(1) - 1)
textBox1.Text += "\r\n";
}
}
示例6: CheckSolid
/// <summary>
/// Checks if a blocks face is solid in a ceratian direction from a block array
/// </summary>
/// <param name="blocks">Block array to check from</param>
/// <param name="x">X position of block</param>
/// <param name="y">Y position of block</param>
/// <param name="z">Z position of block</param>
/// <param name="direction">Direction to check</param>
/// <returns>True if the block is not solid</returns>
protected virtual bool CheckSolid(Block[,,] blocks, int x, int y, int z, Direction direction) {
if (x < 0 || x > blocks.GetLength(0) - 1) {
return false;
}
if (y < 0 || y > blocks.GetLength(1) - 1) {
return false;
}
if (z < 0 || z > blocks.GetLength(2) - 1) {
return false;
}
return blocks[x, y, z].GetSolidity(direction) == BlockSolidity.Block;
}