Esempio n. 1
0
        public static void SaveChunks(List <GameObject> _pool, string _worldName, WorldSeed _seed)
        {
            _WSeed.amplitude = _seed.amplitude;
            _WSeed.frequency = _seed.frequency;
            _WSeed.octave    = _seed.octave;
            _WSeed.reigons   = _seed.reigons.ToArray();
            _WSeed.items     = _seed.randomLoot.ToArray();
            WorldGenSettings wgs = new WorldGenSettings(_worldName, _WSeed, Global.maxChunkSize);

            IOChunks.SaveWorldGenSettings(wgs);
            foreach (GameObject chunk in _pool)
            {
                chunk.GetComponent <MeshBuilder>().SaveChunk();
            }
        }
Esempio n. 2
0
        public void LoadWorld(string worldName)
        {
            WorldGenSettings wgs = IOChunks.LoadWorldGenSettings(worldName);

            seed.amplitude = wgs.seed.amplitude;
            seed.frequency = wgs.seed.frequency;
            seed.octave    = wgs.seed.octave;
            seed.reigons.Clear();
            for (int i = 0; i < wgs.seed.reigons.Length; i++)
            {
                seed.reigons.Add(wgs.seed.reigons[i]);
            }
            seed.randomLoot.Clear();
            for (int i = 0; i < wgs.seed.items.Length; i++)
            {
                seed.randomLoot.Add(wgs.seed.items[i]);
            }
            Global.chunks = IOChunks.LoadChunks(worldName);
        }
Esempio n. 3
0
        public static Chunk GetChunk(int posX, int posZ)
        {
            Chunk c = null;

            for (int i = 0; i < chunks.Count; i++)
            {
                if (chunks[i].x == posX && chunks[i].z == posZ)
                {
                    c = chunks[i];
                    break;
                }
            }
            c = IOChunks.LoadChunk(worldGen.worldName, "Chunk_" + posX + "," + posZ);
            if (c == null)
            {
                Debug.Log("No Chunk Found, Creating new one at:" + posX + " " + posZ);
                c = new Chunk(posX, posZ, RandomizeChunk(worldGen.seed, posX, posZ));
            }

            return(c);
        }
Esempio n. 4
0
 /// <summary>
 /// Converts chunk to binary friendly and saves to folder of string name
 /// </summary>
 /// <param name="name"></param>
 public void SaveChunk()
 {
     currentChunk.x = chunkPosX;
     currentChunk.z = chunkPosZ;
     IOChunks.SaveChunk(ConvertToSerializableChunk(currentChunk.blocks), Global.worldName, transform.name);
 }
Esempio n. 5
0
 /// <summary>
 /// Loads chunk in path string name
 /// </summary>
 /// <param name="name"></param>
 public void LoadChunk(string worldName, string name)
 {
     currentChunk = IOChunks.LoadChunk(worldName, name);
 }