Ejemplo n.º 1
0
        public bool CheckCellSolutionForCollision(Vector2Int cellCoordinates, OutputGrid outputGrid)
        {
            foreach (var neighbour in Create4DirectionNeighbours(cellCoordinates))
            {
                if (outputGrid.CheckIfValidPosition(neighbour.cellToPropagatePosition) == false)
                {
                    continue;;
                }
                HashSet <int> possibleIndicies = new HashSet <int>();
                foreach (var patternIndexAtNeighbour in outputGrid.GetPossibleValueForPosition(neighbour.cellToPropagatePosition))
                {
                    var possibleNeighboursForBase =
                        patternManager.GetPossibleNeighboursForPatternInDirection(patternIndexAtNeighbour,
                                                                                  neighbour.directionFromBase.GetOppositeDirectionTo());
                    possibleIndicies.UnionWith(possibleNeighboursForBase);
                }

                if (possibleIndicies.Contains(outputGrid.GetPossibleValueForPosition(cellCoordinates).First()) == false)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
 public List <VectorPair> CheckIfNeighboursAreCollapsed(VectorPair pairToCheck, OutputGrid outputGrid)
 {
     return(Create4DirectionNeighbours(pairToCheck.cellToPropagatePosition, pairToCheck.baseCellPosition).Where(
                x => outputGrid.CheckIfValidPosition(x.cellToPropagatePosition) &&
                outputGrid.CheckIfCellIsCollapsed(x.cellToPropagatePosition) == false).ToList());
 }