示例#1
0
        public void SaveData()
        {
            Chunk  chunk          = GetComponent <Chunk>();
            string compressedData = ChunkDataFiles.CompressData(chunk);

            WriteChunkData(chunk.ChunkIndex, compressedData);
        }
示例#2
0
        public void SendVoxelData(NetworkPlayer player, int chunkx, int chunky, int chunkz)
        {
            // >> You can check whether the request for voxel data is valid here <<
            // if (true) {
            Chunk chunk = ChunkManager.SpawnChunkFromServer(chunkx, chunky, chunkz).GetComponent <Chunk>();  // get the chunk (spawn it if it's not spawned already)

            chunk.lifetime = 0f;                                                                             // refresh the chunk's lifetime
            string data = ChunkDataFiles.CompressData(chunk);                                                // get data from the chunk and compress it

            byte[] dataBytes = GetBytes(data);                                                               // convert to byte array (sending strings over RPC doesn't work too well)
            GetComponent <NetworkView>().RPC("ReceiveVoxelData", player, chunkx, chunky, chunkz, dataBytes); // send compressed data to the player who requested it
                                                                                                             // }
        }