예제 #1
0
파일: GridCell.cs 프로젝트: HiPoEGH/Nav
        // add this cell to grid and try to connect it with already existing cells
        public bool Add(Cell cell)
        {
            if (cell.AABB.Area < MIN_CELL_AREA_TO_CONSIDER)
            {
                return(false);
            }

            Vec3 border_point = default(Vec3);

            foreach (Cell our_cell in Cells)
            {
                our_cell.AddNeighbour(cell, ref border_point);
            }

            Cells.AddFirst(cell);

            return(true);
        }
예제 #2
0
        public LinkedListNode <Cell> AddCell(Direction direction)
        {
            var offset           = (int)direction * Size.Height;
            var prevCell         = direction == Direction.Left ? Cells.First : Cells.Last;
            var prevCellLocation = prevCell?.Value.Location;
            var cell             = new Cell(Size.Height, (prevCellLocation ?? 0) + offset);

            Controls.Add(cell);
            if (direction == Direction.Left)
            {
                Cells.AddFirst(cell);
                return(Cells.First);
            }
            else
            {
                Cells.AddLast(cell);
                return(Cells.Last);
            }
        }
예제 #3
0
파일: GridCell.cs 프로젝트: HiPoEGH/Nav
        internal void Deserialize(HashSet <GridCell> all_grid_cells, HashSet <Cell> all_cells, BinaryReader r)
        {
            base.Deserialize(all_grid_cells, r);

            int cells_count = r.ReadInt32();

            for (int i = 0; i < cells_count; ++i)
            {
                int cell_global_id = r.ReadInt32();
                Cells.AddFirst(all_cells.First(x => x.GlobalId == cell_global_id));
            }

            int replacement_cells_count = r.ReadInt32();

            for (int i = 0; i < replacement_cells_count; ++i)
            {
                int cell_global_id = r.ReadInt32();
                ReplacementCells.Add(all_cells.First(x => x.GlobalId == cell_global_id));
            }
        }