Exemple #1
0
        //protected Greed childrenGreed;


        //public Cell(Pos pos, SortedList<ushort, Cell> neighbors, object owner)
        //        public Cell(Pos pos, SortedList<ushort, Cell> neighbors, Cell parent, object owner)
        public Cell(CellPos pos, Cell parent, object owner)
        {
            this.pos = pos;
            this.parent = parent;

            /*
            if (parent == null)
            {
                neighbors = new SortedList<ushort, Cell>();
                neighborsBinaryGrid = new BinaryGrid((byte)Pos.WIDTH, (byte)Pos.HEIGHT);
            } else
            {
                neighbors = parent.children;
                neighborsBinaryGrid = parent.neighborsBinaryGrid;
            }
            */

            childrenBinaryGrid = new BinaryGrid((byte)Pos.WIDTH, (byte)Pos.HEIGHT);


            this.neighbors = parent == null ? new SortedList<ushort, Cell>() : parent.children;

            this.owner = owner == null ? this : owner;
            children = new SortedList<ushort, Cell>();

            neighbors [pos.index] = this;
//            neighborsBinaryGrid.Set(pos.x, pos.y, pos.z);
            if (parent != null)
                parent.childrenBinaryGrid.Set(pos.x, pos.y, pos.z);

            AddNeighbors();
            AddToNeighbors();
        }
Exemple #2
0
        public ChunkCell(CellPos pos, Cell parent, object owner) : base(pos, parent, owner)
        {
            childrenOpacityBinaryGreed = new BinaryGrid((byte)Pos.WIDTH, (byte)Pos.HEIGHT);
            childrenLightsTypes = new Dictionary<byte, LightType>();

            if (neighborsArray == null)
                neighborsArray = new ChunkCell[27];
        }
Exemple #3
0
        public BChunk AddChunk(CellPos pos)
        {
            var v = new Vector3(pos.x * CellPos.WIDTH, pos.y * CellPos.HEIGHT, pos.z * CellPos.WIDTH);

            var chunk = Instantiate(this.chunk, v + transform.position, Quaternion.identity) as Transform;

            chunk.parent = transform;

            var bChunk = chunk.GetComponent<BChunk>();

            bChunk.cell = new ChunkCell(pos, cell, bChunk);

            return bChunk;
        }
Exemple #4
0
        BChunk AddChunk(BChunks bChunks, CellPos pos)
        {
            var bChunk = bChunks.AddChunk(pos);


            //bChunk.cell.AddToNeighbors();

            return bChunk;
            /*
            bChunk.AddBlock(new Pos(0, 0, 0), 0, false);
            bChunk.AddBlock(new Pos(1, 0, 0), 0, false);
            bChunk.AddBlock(new Pos(1, 0, 1), 0, false);
            bChunk.AddBlock(new Pos(2, 0, 0), 0, false);

            bChunk.AddBlock(new Pos(Pos.WIDTH - 1, 0, 0), 0, false);

            var bChunk1 = bChunks.AddChunk(new Pos(1, 0, 0));
            bChunk1.AddBlock(new Pos(0, 0, 0), 0, false);

            var bChunk2 = bChunks.AddChunk(new Pos(Pos.WIDTH - 1, 0, 0));
            bChunk2.AddBlock(new Pos(Pos.WIDTH - 1, 0, 0), 0, false);

            bChunk.cell.AddToNeighbors();
            bChunk1.cell.AddToNeighbors();
            bChunk2.cell.AddToNeighbors();

            bChunk.UpdateBlocks();
            bChunk1.UpdateBlocks();
            bChunk2.UpdateBlocks();

            bChunk.UpdateMesh(false);
            bChunk1.UpdateMesh(false);
            bChunk2.UpdateMesh(false);

            bChunks.Save();
*/
        }
Exemple #5
0
        void AddTestChunk(CellPos posChunk)
        {
            var bChunk = AddChunk(posChunk);

            FillBlocks(bChunk, 1, 1, 1);

            //AddRandomBlocks(bChunk);


        }