示例#1
0
    static Vector2[] FaceUVs(int ID, BlockData.Direction direction)
    {
        Vector2[] UVs = new Vector2[4];

        BlockData.TexturePosition tilePos;
        if (BlockLoader.GetBlock(ID).texturePosition != null && BlockLoader.GetBlock(ID).texturePosition.Length > (int)direction)
        {
            tilePos = BlockLoader.GetBlock(ID).texturePosition[(int)direction];
        }
        else
        {
            tilePos = new BlockData.TexturePosition(0, 0);
        }

        UVs[0] = new Vector2(BlockData.TILE_SIZE * tilePos.x + BlockData.TILE_SIZE,
                             BlockData.TILE_SIZE * tilePos.y);
        UVs[1] = new Vector2(BlockData.TILE_SIZE * tilePos.x + BlockData.TILE_SIZE,
                             BlockData.TILE_SIZE * tilePos.y + BlockData.TILE_SIZE);
        UVs[2] = new Vector2(BlockData.TILE_SIZE * tilePos.x,
                             BlockData.TILE_SIZE * tilePos.y + BlockData.TILE_SIZE);
        UVs[3] = new Vector2(BlockData.TILE_SIZE * tilePos.x,
                             BlockData.TILE_SIZE * tilePos.y);

        return(UVs);
    }
示例#2
0
    public static bool BreakBlock(RaycastHit hit, bool adjacent = false)
    {
        ChunkRenderer chunkRenderer = hit.collider.GetComponent <ChunkRenderer>();

        if (chunkRenderer == null)
        {
            return(false);
        }

        Vector3Int pos = GetBlockPos(hit, adjacent);

        int blockID = chunkRenderer.chunkData.GetBlock(pos.x, pos.y, pos.z);

        BlockLoader.GetBlock(blockID).Break(new Vector3(pos.x, pos.y, pos.z));
        chunkRenderer.chunkData.SetBlock(pos.x, pos.y, pos.z, 0);

        return(true);
    }