当前位置: 首页>>代码示例>>C#>>正文


C# Chunk.GetBlock方法代码示例

本文整理汇总了C#中Chunk.GetBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Chunk.GetBlock方法的具体用法?C# Chunk.GetBlock怎么用?C# Chunk.GetBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chunk的用法示例。


在下文中一共展示了Chunk.GetBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LightChunk

    /// <summary>
    /// Identifies all sunlit blocks, then lights all surrounding blocks
    /// </summary>
    /// <param name="chunk"></param>
    public void LightChunk(Chunk chunk)
    {
        if (chunk.IsOnTheBorder)
        {
            return;
        }

        LightSunlitBlocksInChunk(chunk);

        byte sunlight = Sunlight();
        int chunkWorldX = chunk.ArrayX * m_WorldData.ChunkBlockWidth;
        int chunkWorldY = chunk.ArrayY * m_WorldData.ChunkBlockHeight;

        for (int x = 0; x < m_WorldData.ChunkBlockWidth; x++)
        {
            int blockX = chunkWorldX + x;
            for (int y = 0; y < m_WorldData.ChunkBlockHeight; y++)
            {
                int blockY = chunkWorldY + y;

                for (int z = m_WorldData.ChunkBlockDepth - 1; z >= 0; z--)
                {
                    Block block = chunk.GetBlock(x, y, z);
                    // Only light blocks that surround a sunlit block (for now)
                    if (block.Type == BlockType.Air && block.LightAmount == sunlight)
                    {
                        SetLightingAroundBlock(blockX, blockY, z, 1);
                    }
                }
            }
        }
    }
开发者ID:scorpion44,项目名称:BlockPackage,代码行数:36,代码来源:LightProcessor.cs

示例2: Save

    public Save(Chunk chunk)
    {

        try
        {
            //Because existing saved blocks aren't marked as modified we have to add the
            //blocks already in the save fie if there is one. Then add 
            Dictionary<BlockPos, Block> blocksDictionary = AddSavedBlocks(chunk);

            for (int x = 0; x < Config.Env.ChunkSize; x++)
            {
                for (int y = 0; y < Config.Env.ChunkSize; y++)
                {
                    for (int z = 0; z < Config.Env.ChunkSize; z++)
                    {
                        BlockPos pos = new BlockPos(x, y, z);
                        if (chunk.GetBlock(pos).modified)
                        {
                            //remove any existing blocks in the dictionary as they're
                            //from the existing save and are overwritten
                            blocksDictionary.Remove(pos);
                            blocksDictionary.Add(pos, chunk.GetBlock(pos));
                            changed = true;
                        }
                    }
                }
            }

            blocks = new Block[blocksDictionary.Keys.Count];
            positions = new BlockPos[blocksDictionary.Keys.Count];

            int index = 0;

            foreach (var pair in blocksDictionary)
            {
                blocks[index] = pair.Value;
                positions[index] = pair.Key;
                index++;
            }

        }
        catch (Exception ex)
        {
            Debug.LogError(ex);
        }

    }
开发者ID:li5414,项目名称:Voxelmetric,代码行数:47,代码来源:Save.cs

示例3: RandomUpdate

 //On random update spread grass to any nearby dirt blocks on the surface
 public override void RandomUpdate(Chunk chunk, BlockPos pos, Block block)
 {
     for (int x = -1; x <= 1; x++)
     {
         for (int y = -1; y <= 1; y++)
         {
             for (int z = -1; z <= 1; z++)
             {
                 if (chunk.GetBlock(pos.Add(x, y, z) - chunk.pos) == dirt
                     && chunk.GetBlock(pos.Add(x, y + 1, z) - chunk.pos) == air)
                 {
                     chunk.SetBlock(pos.Add(x, y, z) - chunk.pos, "grass", false);
                     chunk.SetFlag(Chunk.Flag.updateSoon, true);
                 }
             }
         }
     }
 }
开发者ID:li5414,项目名称:Voxelmetric,代码行数:19,代码来源:grassOverride.cs

示例4: SetBlock

 public static void SetBlock(Chunk chunk, Block block, BlockPos pos, bool replaceBlocks = false)
 {
     if (Chunk.InRange(pos))
     {
         if (replaceBlocks || chunk.GetBlock(pos).type == Block.Air.type)
         {
             block.modified = false;
             chunk.SetBlock(pos, block, false);
         }
     }
 }
开发者ID:renokun,项目名称:Voxelmetric,代码行数:11,代码来源:TerrainGen.cs

示例5: Resolve

 public override void Resolve(Chunk chunk, int x, int y, int z)
 {
     chunk.GetBlock (x - 1, y, z).setoffset (new Vector3 (0.5f, 0.5f, 0.5f));
     chunk.GetBlock (x, y, z - 1).setoffset (new Vector3 (0.5f, 0.5f, 0.5f));
     chunk.GetBlock (x - 1, y, z - 1).setoffset (new Vector3 (0.5f, 0.5f, 0.5f));
     chunk.GetBlock (x - 1, y - 1, z).setoffset (new Vector3 (0.5f, 0.5f, 0.5f));
     chunk.GetBlock (x, y - 1, z - 1).setoffset (new Vector3 (0.5f, 0.5f, 0.5f));
     chunk.GetBlock (x - 1, y - 1, z - 1).setoffset (new Vector3 (0.5f, 0.5f, 0.5f));
     chunk.GetBlock (x, y - 1, z).setoffset (new Vector3 (0.5f, 0.5f, 0.5f));
 }
开发者ID:TwoClunkers,项目名称:Clunk-Genesis,代码行数:10,代码来源:BlockAnchor.cs

示例6: Blockdata

    public virtual MeshData Blockdata(Chunk chunk, int x, int y, int z, MeshData meshData)
    {
        if (!chunk.GetBlock(x, y + 1, z).IsSolid(Direction.down))
        {
            meshData = FaceDataUp(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x, y - 1, z).IsSolid(Direction.up))
        {
            meshData = FaceDataDown(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x, y, z + 1).IsSolid(Direction.south))
        {
            meshData = FaceDataNorth(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x, y, z - 1).IsSolid(Direction.north))
        {
            meshData = FaceDataSouth(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x + 1, y, z).IsSolid(Direction.west))
        {
            meshData = FaceDataEast(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x - 1, y, z).IsSolid(Direction.east))
        {
            meshData = FaceDataWest(chunk, x, y, z, meshData);
        }

        return meshData;
    }
开发者ID:billy1234,项目名称:TerrainGenMaster,代码行数:34,代码来源:Block.cs

示例7: Blockdata

    public virtual MeshData Blockdata(Chunk chunk, int x, int y, int z, MeshData meshData)
    {
        // Check if block on top has a solid down face
        if (!chunk.GetBlock(x, y + 1, z).IsSolid(Direction.down)) {
            meshData = FaceDataUp(chunk, x, y, z, meshData);
        }

        // Check if the block below has a solid up face
        if (!chunk.GetBlock(x, y - 1, z).IsSolid(Direction.up)) {
            meshData = FaceDataDown(chunk, x, y, z, meshData);
        }

        // Check if the block north has a solid south face
        if (!chunk.GetBlock(x, y, z + 1).IsSolid(Direction.south)) {
            meshData = FaceDataNorth(chunk, x, y, z, meshData);
        }

        // Check if the block south has a solid north face
        if (!chunk.GetBlock(x, y, z - 1).IsSolid(Direction.north)) {
            meshData = FaceDataSouth(chunk, x, y, z, meshData);
        }

        // Check if the block east has a solid west face
        if (!chunk.GetBlock(x + 1, y, z).IsSolid(Direction.west)) {
            meshData = FaceDataEast(chunk, x, y, z, meshData);
        }

        // Check if the block west has a solid east face
        if (!chunk.GetBlock(x - 1, y, z).IsSolid(Direction.east)) {
            meshData = FaceDataWest(chunk, x, y, z, meshData);
        }

        return meshData;
    }
开发者ID:strauzen,项目名称:Voxels,代码行数:34,代码来源:Block.cs

示例8: Render

	public void Render (World world, Chunk chunk)
	{
		this.world = world;
		this.chunk = chunk;

		vertices.Clear ();
		uvs.Clear ();
		for (int i = 0; i < subMeshCount; i++) {
			triangles [i].Clear ();
		}

		Block block;
		Vector3 start;

		for (int x = 0; x < world.ChunkX; x++) {
			for (int y = 1; y < world.LevelY; y++) {
				for (int z = 0; z < world.ChunkZ; z++) {
					start = new Vector3 (x, y, z);
					block = chunk.GetBlock (x, y, z);
					if (block == null)
						continue;
					if (MustFaceBeVisible (x - 1, y, z, block)) {
						DrawFace (start + Vector3.back, start, start + Vector3.back + Vector3.up, start + Vector3.up, block);
					} 
					if (MustFaceBeVisible (x + 1, y, z, block)) {
						DrawFace (start + Vector3.right, start + Vector3.right + Vector3.back, start + Vector3.right + Vector3.up, start + Vector3.right + Vector3.back + Vector3.up, block);
					}
					if (MustFaceBeVisible (x, y - 1, z, block)) {
						DrawFace (start, start + Vector3.back, start + Vector3.right, start + Vector3.back + Vector3.right, block);
					}
					if (MustFaceBeVisible (x, y + 1, z, block)) {
						DrawFace (start + Vector3.up + Vector3.back, start + Vector3.up, start + Vector3.up + Vector3.back + Vector3.right, start + Vector3.up + Vector3.right, block);
					}
					if (MustFaceBeVisible (x, y, z - 1, block)) {
						DrawFace (start + Vector3.back + Vector3.right, start + Vector3.back, start + Vector3.back + Vector3.right + Vector3.up, start + Vector3.back + Vector3.up, block);		
					} 
					if (MustFaceBeVisible (x, y, z + 1, block)) {
						DrawFace (start, start + Vector3.right, start + Vector3.up, start + Vector3.right + Vector3.up, block);
					}
				}
			}
		}
	}
开发者ID:indigo,项目名称:indigo,代码行数:43,代码来源:TerrainRenderer.cs

示例9: GetTexture

    public Rect GetTexture(Chunk chunk, BlockPos pos, Direction direction)
    {
        if (usesConnectedTextures)
        {
            string blockName = chunk.GetBlock(pos).controller.Name();

            bool wn = ConnectedTextures.IsSame(chunk, pos, -1, 1, direction, blockName);
            bool n = ConnectedTextures.IsSame(chunk, pos, 0, 1, direction, blockName);
            bool ne = ConnectedTextures.IsSame(chunk, pos, 1, 1, direction, blockName);
            bool w = ConnectedTextures.IsSame(chunk, pos, -1, 0, direction, blockName);
            bool e = ConnectedTextures.IsSame(chunk, pos, 1, 0, direction, blockName);
            bool es = ConnectedTextures.IsSame(chunk, pos, 1, -1, direction, blockName);
            bool s = ConnectedTextures.IsSame(chunk, pos, 0, -1, direction, blockName);
            bool sw = ConnectedTextures.IsSame(chunk, pos, -1, -1, direction, blockName);

            return connectedTextures[ConnectedTextures.GetTexture(n, e, s, w, wn, ne, es, sw)];

        }

        if (textures.Count == 1)
        {
            return textures[0];
        }

        if (textures.Count > 1)
        {
            float randomNumber = noiseGen.Generate(pos.x, pos.y, pos.z);
            randomNumber += 1;
            randomNumber /= 2;
            randomNumber *= textures.Count;

            return textures[(int)randomNumber];
        }


        Debug.LogError("There were no textures for " + textureName);
        return new Rect();
    }
开发者ID:li5414,项目名称:Voxelmetric,代码行数:38,代码来源:TextureCollection.cs

示例10: BuildFace

    public override void BuildFace(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, Block block)
    {
        List<Direction> dir = new List<Direction>();

        //East
        if (Block.Air != chunk.GetBlock(new BlockPos(pos.x + 1, pos.y, pos.z)) && dirE.east != false)
        {
            dir.Add(Direction.east);
        }
        //West
        if (Block.Air != chunk.GetBlock(new BlockPos(pos.x - 1, pos.y, pos.z)) && dirE.west != false)
        {
            dir.Add(Direction.west);
        }
        //North
        if (Block.Air != chunk.GetBlock(new BlockPos(pos.x, pos.y, pos.z + 1)) && dirE.north != false)
        {
            dir.Add(Direction.north);
        }
        //South
        if (Block.Air != chunk.GetBlock(new BlockPos(pos.x, pos.y, pos.z - 1)) && dirE.south != false)
        {
            dir.Add(Direction.south);
        }
        //Up
        if (Block.Air != chunk.GetBlock(new BlockPos(pos.x, pos.y + 1, pos.z)) && dirE.up != false)
        {
            dir.Add(Direction.up);
        }
        //Down
        if (Block.Air != chunk.GetBlock(new BlockPos(pos.x, pos.y - 1, pos.z)) && dirE.down != false)
        {
            dir.Add(Direction.down);
        }

        ConnectedBuilder.BuildRenderer(chunk, pos, meshData, direction, MeshSize, ConnMeshSizeX, ConnMeshSizeY, ConnMeshSizeZ, dir.ToArray());
        ConnectedBuilder.BuildTextures(chunk, pos, meshData, direction, textures, MeshSize, dir.ToArray());
        ConnectedBuilder.BuildColors(chunk, pos, meshData, direction, MeshSize, dir.ToArray());

        if (Config.Toggle.UseCollisionMesh)
        {
            BlockBuilder.BuildCollider(chunk, pos, meshData, direction);
        }
    }
开发者ID:FaizanDurrani,项目名称:Voxelmetric-ConnectedMeshes,代码行数:44,代码来源:BlockConnected.cs

示例11: AddBlockData

    public override void AddBlockData(Chunk chunk, BlockPos pos, MeshData meshData, Block block)
    {
        if (!chunk.GetBlock(pos.Add(0, 1, 0)).controller.IsSolid(BlockDirection.down))
            BuildFace(chunk, pos, meshData, BlockDirection.up, block);

        if (!chunk.GetBlock(pos.Add(0, -1, 0)).controller.IsSolid(BlockDirection.up))
            BuildFace(chunk, pos, meshData, BlockDirection.down, block);

        if (!chunk.GetBlock(pos.Add(0, 0, 1)).controller.IsSolid(BlockDirection.south))
            BuildFace(chunk, pos, meshData, BlockDirection.north, block);

        if (!chunk.GetBlock(pos.Add(0, 0, -1)).controller.IsSolid(BlockDirection.north))
            BuildFace(chunk, pos, meshData, BlockDirection.south, block);

        if (!chunk.GetBlock(pos.Add(1, 0, 0)).controller.IsSolid(BlockDirection.west))
            BuildFace(chunk, pos, meshData, BlockDirection.east, block);

        if (!chunk.GetBlock(pos.Add(-1, 0, 0)).controller.IsSolid(BlockDirection.east))
            BuildFace(chunk, pos, meshData, BlockDirection.west, block);
    }
开发者ID:losetear,项目名称:Voxelmetric,代码行数:20,代码来源:BlockSolid.cs

示例12: AddBlockData

    public override void AddBlockData(Chunk chunk, BlockPos pos, MeshData meshData, Block block)
    {
        if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(0, 1, 0)) != block))
            BuildFace(chunk, pos, meshData, Direction.up, block);

        if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(0, -1, 0)) != block))
            BuildFace(chunk, pos, meshData, Direction.down, block);

        if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(0, 0, 1)) != block))
            BuildFace(chunk, pos, meshData, Direction.north, block);

        if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(0, 0, -1)) != block))
            BuildFace(chunk, pos, meshData, Direction.south, block);

        if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(1, 0, 0)) != block))
            BuildFace(chunk, pos, meshData, Direction.east, block);

        if ((isSolid || !solidTowardsSameType || chunk.GetBlock(pos.Add(-1, 0, 0)) != block))
            BuildFace(chunk, pos, meshData, Direction.west, block);
    }
开发者ID:FaizanDurrani,项目名称:Voxelmetric-ConnectedMeshes,代码行数:20,代码来源:ProcMesh.cs

示例13: if

    public virtual MeshData Blockdata
     (Chunk chunk, int x, int y, int z, MeshData meshData, int CycleNumber)
    {
		if (CycleNumber == 0)
			meshData.useRenderDataForCol = true;
		else if (CycleNumber == 1)
			meshData.useRenderDataForCol = false;

		if (!chunk.GetBlock(x, y + 1, z).IsSolid(chunk, Direction.down, CycleNumber))
        {
			meshData = FaceDataUp(chunk, x, y, z, meshData, CycleNumber);
        }

		if (!chunk.GetBlock(x, y - 1, z).IsSolid(chunk, Direction.up, CycleNumber))
        {
			meshData = FaceDataDown(chunk, x, y, z, meshData, CycleNumber);
        }

		if (!chunk.GetBlock(x, y, z + 1).IsSolid(chunk, Direction.south, CycleNumber))
        {
			meshData = FaceDataNorth(chunk, x, y, z, meshData, CycleNumber);
        }

		if (!chunk.GetBlock(x, y, z - 1).IsSolid(chunk, Direction.north, CycleNumber))
        {
			meshData = FaceDataSouth(chunk, x, y, z, meshData, CycleNumber);
        }

		if (!chunk.GetBlock(x + 1, y, z).IsSolid(chunk, Direction.west, CycleNumber))
        {
			meshData = FaceDataEast(chunk, x, y, z, meshData, CycleNumber);
        }

		if (!chunk.GetBlock(x - 1, y, z).IsSolid(chunk, Direction.east, CycleNumber))
        {
			meshData = FaceDataWest(chunk, x, y, z, meshData, CycleNumber);
        }

        return meshData;

	}
开发者ID:Deus0,项目名称:Zeltex,代码行数:41,代码来源:BlockBase.cs

示例14: Blockdata

    public virtual MeshData Blockdata(Chunk chunk, int x, int y, int z, MeshData meshData)
    {
        meshData.useRenderDataForCol = true;

        if (!chunk.GetBlock (x, y + 1, z).IsSolid (Direction.down))
        {
            meshData = FaceData (chunk, new Vector3 (x, y + 1, z), Vector3.forward, Vector3.right, Direction.up, meshData);
        }

        if (!chunk.GetBlock (x, y - 1, z).IsSolid (Direction.up))
        {
            meshData = FaceData (chunk, new Vector3 (x, y, z), Vector3.right, Vector3.forward, Direction.down, meshData);
        }

        if (!chunk.GetBlock (x, y, z + 1).IsSolid (Direction.south))
        {
            meshData = FaceData (chunk, new Vector3 (x, y, z + 1), Vector3.right, Vector3.up, Direction.north, meshData);
        }

        if (!chunk.GetBlock (x, y, z - 1).IsSolid (Direction.north))
        {
            meshData = FaceData (chunk, new Vector3 (x + 1, y, z), Vector3.left, Vector3.up, Direction.south, meshData);
        }

        if (!chunk.GetBlock (x + 1, y, z).IsSolid (Direction.west))
        {
            meshData = FaceData (chunk, new Vector3 (x + 1, y, z + 1), Vector3.back, Vector3.up, Direction.east, meshData);
        }

        if (!chunk.GetBlock (x - 1, y, z).IsSolid (Direction.east))
        {
            meshData = FaceData (chunk, new Vector3 (x, y, z), Vector3.forward, Vector3.up, Direction.west, meshData);
        }

        return meshData;
    }
开发者ID:neilsustc,项目名称:myMinecraft-unity3d,代码行数:36,代码来源:Block.cs

示例15: Blockdata

    //takes directional check, and calls rendering functions
    public virtual MeshData Blockdata(Chunk chunk, int x, int y, int z, MeshData meshData)
    {
        meshData.useRenderDataForCol = true;//bool that sets collision to tris

        if (!chunk.GetBlock(x, y + 1, z).IsSolid(Direction.down))
        {
            meshData = FaceDataUp(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x, y - 1, z).IsSolid(Direction.up))
        {
            meshData = FaceDataDown(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x, y, z + 1).IsSolid(Direction.south))
        {
            meshData = FaceDataNorth(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x, y, z - 1).IsSolid(Direction.north))
        {
            meshData = FaceDataSouth(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x + 1, y, z).IsSolid(Direction.west))
        {
            meshData = FaceDataEast(chunk, x, y, z, meshData);
        }

        if (!chunk.GetBlock(x - 1, y, z).IsSolid(Direction.east))
        {
            meshData = FaceDataWest(chunk, x, y, z, meshData);
        }

        return meshData;
    }
开发者ID:Hopesresolve,项目名称:MineCraftProject,代码行数:37,代码来源:BlockScript.cs


注:本文中的Chunk.GetBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。