Ejemplo n.º 1
0
        public GenerationOrder(ChunksManager manager)
        {
            this._manager = manager;
            int width = (manager.Settings.GenerationDistance) * 2 + 1;

            _order = new int[width, width];

            int index = 0;

            this[0, 0] = index++;
            for (int i = 1; i <= manager.Settings.GenerationDistance; i++)
            {
                this[i, 0]  = index++;
                this[0, -i] = index++;
                this[-i, 0] = index++;
                this[0, i]  = index++;
                for (int j = 1; j < i; j++)
                {
                    this[i, j]   = index++;
                    this[i, -j]  = index++;
                    this[j, -i]  = index++;
                    this[-j, -i] = index++;
                    this[-i, -j] = index++;
                    this[-i, j]  = index++;
                    this[-j, i]  = index++;
                    this[j, i]   = index++;
                }
                this[i, i]   = index++;
                this[i, -i]  = index++;
                this[-i, -i] = index++;
                this[-i, i]  = index++;
            }
        }
Ejemplo n.º 2
0
 public ChunksDictionary(ChunksManager manager)
 {
     _columns             = new Dictionary <Vector2Int, ChunkColumn>();
     _columnsForRecycling = new Queue <ChunkColumn>();
     _worldHeight         = manager.Settings.WorldHeight;
     CreateChunksPool(manager);
 }
Ejemplo n.º 3
0
 private void CreateChunksPool(ChunksManager manager)
 {
     for (int x = -manager.Settings.GenerationDistance; x <= manager.Settings.GenerationDistance; x++)
     {
         for (int z = -manager.Settings.GenerationDistance; z <= manager.Settings.GenerationDistance; z++)
         {
             _columnsForRecycling.Enqueue(new ChunkColumn(manager));
         }
     }
 }
Ejemplo n.º 4
0
        //public void Deactivate()
        //{
        //    SetVisibility(false);
        //    isActive = false;
        //}

        private Chunk CreateChunk(ChunksManager manager)
        {
            GameObject chunk = new GameObject();

            chunk.transform.parent = manager.transform;
            chunk.tag      = "Chunk";
            chunk.isStatic = true;
            Chunk newChunk = chunk.AddComponent <Chunk>();

            newChunk.Create(manager.Settings.MeshGeneratorSettings.GenerateColliders, manager.Settings.MeshGeneratorSettings.Material);
            return(newChunk);
        }
Ejemplo n.º 5
0
        public ChunkColumn(ChunksManager manager)
        {
            _worldHeight = manager.Settings.WorldHeight;
            Chunks       = new Chunk[_worldHeight];
            Coord        = new Vector2Int();
            IsActive     = IsVisible = IsWaitingMesh = HasMesh = false;

            for (int i = 0; i < _worldHeight; i++)
            {
                Chunks[i]            = CreateChunk(manager);
                Chunks[i].Visibility = false;
            }
        }