示例#1
0
    [RPC] public void SetBlock(Vector3 index, int voxelType) //overloading for the network scene (as enums are not serialisable)
    {
        if ((index.x >= 0 && index.x < m_terrainArray.GetLength(0)) && (index.y >= 0 && index.y < m_terrainArray.GetLength(1)) && (index.z >= 0 && index.z < m_terrainArray.GetLength(2)))
        {
            //clear the previous mesh data
            m_voxelGenerator.ClearPreviousData();
            // Change the block to the required type
            m_terrainArray[(int)index.x, (int)index.y, (int)index.z] = (int)voxelType;
            // Create the new mesh
            DisplayTerrain();
            // Update the mesh data
            m_voxelGenerator.UpdateWorld();

            m_voxelType vType = m_voxelType.grass;
            switch (voxelType)
            {
            case 1:
                vType = m_voxelType.grass;
                break;

            case 2:
                vType = m_voxelType.dirt;
                break;

            case 3:
                vType = m_voxelType.stone;
                break;

            case 4:
                vType = m_voxelType.sand;
                break;
            }
            m_world.BlockChanged(vType);
        }
    }
示例#2
0
    public void UpdateChunk()
    {
        m_voxelGenerator = GetComponent <MeshGenerator>();
        //we now set the parent
        m_voxelGenerator.m_parent = this;

        //m_terrainArray = new int[m_chunkSize, m_chunkHeight, m_chunkSize];

        m_voxelGenerator.ClearPreviousData();

        //do terrain modifications here
        //CreatePath();

        DisplayTerrain();


        //finish up the model
        m_voxelGenerator.UpdateWorld();
    }
示例#3
0
    public void UpdateChunk()
    {
        m_voxelGenerator = GetComponent<MeshGenerator>();
        //we now set the parent
        m_voxelGenerator.m_parent = this;

        //m_terrainArray = new int[m_chunkSize, m_chunkHeight, m_chunkSize];

        m_voxelGenerator.ClearPreviousData();

        //do terrain modifications here
        //CreatePath();

        DisplayTerrain();

        //finish up the model
        m_voxelGenerator.UpdateWorld();
    }