Ejemplo n.º 1
0
        public void EstablishCellNeighbours()
        {
            foreach (var pair in _occupiedCells)
            {
                ObjectPlacementPathTileConnectionGridCell tileConnectionGridCell = pair.Value;

                var potentialNeighbour = new ObjectPlacementPathTileConnectionGridCellIndices(tileConnectionGridCell.XIndex + 1, tileConnectionGridCell.ZIndex);
                if (IsCellOccupied(potentialNeighbour))
                {
                    tileConnectionGridCell.AddNeighbourIfPossible(GetCellAtIndicesIfOccupied(potentialNeighbour));
                }

                potentialNeighbour = new ObjectPlacementPathTileConnectionGridCellIndices(tileConnectionGridCell.XIndex - 1, tileConnectionGridCell.ZIndex);
                if (IsCellOccupied(potentialNeighbour))
                {
                    tileConnectionGridCell.AddNeighbourIfPossible(GetCellAtIndicesIfOccupied(potentialNeighbour));
                }

                potentialNeighbour = new ObjectPlacementPathTileConnectionGridCellIndices(tileConnectionGridCell.XIndex, tileConnectionGridCell.ZIndex + 1);
                if (IsCellOccupied(potentialNeighbour))
                {
                    tileConnectionGridCell.AddNeighbourIfPossible(GetCellAtIndicesIfOccupied(potentialNeighbour));
                }

                potentialNeighbour = new ObjectPlacementPathTileConnectionGridCellIndices(tileConnectionGridCell.XIndex, tileConnectionGridCell.ZIndex - 1);
                if (IsCellOccupied(potentialNeighbour))
                {
                    tileConnectionGridCell.AddNeighbourIfPossible(GetCellAtIndicesIfOccupied(potentialNeighbour));
                }
            }
        }
Ejemplo n.º 2
0
 public ObjectPlacementPathTileConnectionGridCell GetCellAtIndicesIfOccupied(ObjectPlacementPathTileConnectionGridCellIndices cellIndices)
 {
     if (IsCellOccupied(cellIndices))
     {
         return(_occupiedCells[cellIndices]);
     }
     else
     {
         return(null);
     }
 }
 public ObjectPlacementPathTileConnectionGridCell(ObjectPlacementPathTileConnectionGridCellIndices cellIndices, ObjectPlacementPathTileConnectionGrid parentGrid)
 {
     _cellIndices = cellIndices;
     _parentGrid  = parentGrid;
 }
Ejemplo n.º 4
0
 public Vector3 CalculateCellPosition(ObjectPlacementPathTileConnectionGridCellIndices cellIndices)
 {
     return(CalculateCellPosition(cellIndices.XIndex, cellIndices.ZIndex));
 }
Ejemplo n.º 5
0
 public bool IsCellOccupied(ObjectPlacementPathTileConnectionGridCellIndices cellIndices)
 {
     return(_occupiedCells.ContainsKey(cellIndices));
 }