Exemple #1
0
        /// <summary>
        /// Gizmo for debuging a cell.
        /// </summary>
        /// <param name="index">The index of the cell.</param>
        /// <param name="grid">The grid it belongs</param>
        /// <param name="color">Color of the gizmo.</param>
        /// <param name="offsetSize"> The scale amount add to the grid size cell.</param>
        public static void DebugCell(Vector3Int index, Grid3D grid, Color color, float offsetSize = 0.01f)
        {
            if (grid == null)
            {
                return;
            }
            Gizmos.color = color;
            TypeGrid3D typegrid = grid.GetTypeGrid();

            switch (typegrid)
            {
            case TypeGrid3D.Cube:
            {
                Gizmos.DrawWireCube(grid.GetPositionCell(index), Vector3.one * (grid.SizeCell + offsetSize));
            }
            break;

            case TypeGrid3D.Hexagonal:
            {
                Gizmos.DrawMesh(ProceduralMesh.GetHexagonMesh(), grid.GetPositionCell(index), Quaternion.identity, Vector3.one * (grid.SizeCell + offsetSize));
            }
            break;

            default:
                throw new ArgumentException("No type implemented " + typegrid.ToString() + " inherit Grid3D");
            }
        }
 /// <summary>
 /// Debug a plane grid for helping to visualize the cells.
 /// </summary>
 /// <param name="grid">The grid to debug.</param>
 /// <param name="color"> The color of the grid.</param>
 /// <param name="offset_grid_y"> The offset of y position. </param>
 /// <param name="size_grid">The size of the grid.</param>
 public static void DebugGrid(Grid3D grid, Color color, int offset_grid_y = 0, int size_grid = 10)
 {
     if (grid.GetTypeGrid() == TypeGrid3D.Hexagonal)
     {
         DebugHexagonGrid(grid, color, offset_grid_y, size_grid);
     }
     else
     {
         DebugSquareGrid(grid, color, offset_grid_y, size_grid);
     }
 }
Exemple #3
0
        public Grid3DDTO(Grid3D grid)
        {
            _type      = grid.GetTypeGrid();
            _name      = grid.name;
            _size_cell = grid.SizeCell;
            _gap       = grid.GapRatio;

            _map = new List <CellDTO>();
            Dictionary <Vector3Int, Cell> .Enumerator it = grid.GetEnumerator();
            while (it.MoveNext())
            {
                CellDTO dtocell = new CellDTO(it.Current.Value);
                _map.Add(dtocell);
            }
        }