Beispiel #1
0
 private static Vector3 CreatePosition(CellMatrix cellMatrix, Cell cell)
 {
     return(new Vector3(
                cellMatrix.BottomLeft.x + cell.Coord.X,
                0,
                cellMatrix.BottomLeft.y + cell.Coord.Y
                ));
 }
Beispiel #2
0
 public static IEnumerable <Cell> RadialForEach(
     this CellMatrix cellMatrix,
     Cell center,
     int radio
     )
 {
     return(RadialForEach(cellMatrix, center.Coord, radio));
 }
Beispiel #3
0
        public static void DrawCell(CellMatrix cellMatrix, Cell cell)
        {
            var position = new Vector3(
                cellMatrix.BottomLeft.x + cell.Coord.X,
                0,
                cellMatrix.BottomLeft.y + cell.Coord.Y
                );

            Gizmos.color = cell.Value == 1 ? Color.black : Color.white;
            Gizmos.DrawCube(position, Vector3.one);
        }
Beispiel #4
0
 public static IEnumerable <Cell> RadialForEach(
     this CellMatrix cellMatrix,
     Coord center,
     int radio)
 {
     for (var x = center.X - radio; x <= center.X + radio; x++)
     {
         for (var y = center.Y - radio; y <= center.Y + radio; y++)
         {
             yield return(cellMatrix[x, y]);
         }
     }
 }
Beispiel #5
0
 public SquareEdgeNodeMatrix(CellMatrix cellMatrix, float squareSideSize)
 {
     nodes = new SquareEdgeNode[cellMatrix.Width, cellMatrix.Height];
     cellMatrix.ForEach(cell => AddNode(squareSideSize, cell, CreatePosition(cellMatrix, cell)));
 }
Beispiel #6
0
 public CellMatrixRegionResolver(CellMatrix cellMatrix)
 {
     this.cellMatrix = cellMatrix;
     InitializeVisited(cellMatrix);
 }
Beispiel #7
0
 private void InitializeVisited(CellMatrix cellMatrix)
 {
     visitedCells = new bool[cellMatrix.Width, cellMatrix.Height];
 }