// Start is called before the first frame update void Start() { instance = this; cellsHolder = new Cell[numTiles, numTiles]; placeHolders = new PlaceholderIndex[numTiles, numTiles]; for (int i = 0; i < numTiles; i++) { for (int j = 0; j < numTiles; j++) { Vector3 currentPos = new Vector3(j * offset, 0, i * offset); cell = new Cell(); cell.position = currentPos; cell.myIndex = new Vector2Int(i, j); cellsHolder[i, j] = cell; PlaceholderIndex placeholder = Instantiate(tilePlaceHolder, currentPos, Quaternion.identity); placeholder.myIndex = new Vector2Int(i, j); placeHolders[i, j] = placeholder; } } foreach (Cell c in cellsHolder) { c.FindNeighbours(); } waveFunctionCollapse.InitializeWaveFunctionCollapse(); }
private OutputFromComputeCellGroups ComputeCellGroups(InputForComputingCellGroups args) { var result = new OutputFromComputeCellGroups(); result.Success = true; var cellCreator = new CellCreator(args.ContainerMapping); result.Cells = cellCreator.GenerateCells(); result.Identifiers = cellCreator.Identifiers; if (result.Cells.Count <= 0) { //When type-specific QVs are asked for but not defined in the MSL we should return without generating // Query pipeline will handle this appropriately by asking for UNION ALL view. result.Success = false; return(result); } result.ForeignKeyConstraints = ForeignConstraint.GetForeignConstraints(args.ContainerMapping.StorageEntityContainer); // Go through each table and determine their foreign key constraints var partitioner = new CellPartitioner(result.Cells, result.ForeignKeyConstraints); var cellGroups = partitioner.GroupRelatedCells(); //Clone cell groups- i.e, List<Set<Cell>> - upto cell before storing it in the cache because viewgen modified the Cell structure result.CellGroups = cellGroups.Select(setOfcells => new CellGroup(setOfcells.Select(cell => new Cell(cell)))).ToList(); return(result); }
void FindPathRecursive(Cell cell) { //인접 셀 중 지나갈 수 있는 셀을 open list에 추가 foreach (var around in cell.AroundDic) { Cell aroundCell = CellCreator.GetCell(around.Key); if (!aroundCell.IsObstacle && !closeList.Contains(aroundCell)) { if (openList.Contains(aroundCell)) { if (aroundCell.G > cell.G + cell[around.Key]) { aroundCell.Parent = cell; } } else { aroundCell.Parent = cell; openList.Add(aroundCell); //만약 목적지가 열린목록에 추가된다면, 길 찾기를 완료한것으로 판단 if (aroundCell == destinationCell) { SuccessFindPath(); return; } } } } openList.Remove(cell); closeList.Add(cell); Tuple <int, Cell> minF = new Tuple <int, Cell>(int.MaxValue, null); foreach (var checkCell in openList) { Cell parent = checkCell.Parent; //나의 G 비용은 부모의 G + 부모로부터 나한테 오는데 드는 비용 (대각선이면 14, 직각이면 10) int G = parent.G + parent[checkCell.Idx]; checkCell.G = G; //H 비용 int H = GetH(destinationCell, checkCell); int F = G + H; if (minF.Item1 > F) { minF = new Tuple <int, Cell>(F, checkCell); } } FindPathRecursive(minF.Item2); }
private OutputFromComputeCellGroups ComputeCellGroups( InputForComputingCellGroups args) { OutputFromComputeCellGroups computeCellGroups = new OutputFromComputeCellGroups(); computeCellGroups.Success = true; CellCreator cellCreator = new CellCreator(args.ContainerMapping); computeCellGroups.Cells = cellCreator.GenerateCells(); computeCellGroups.Identifiers = cellCreator.Identifiers; if (computeCellGroups.Cells.Count <= 0) { computeCellGroups.Success = false; return(computeCellGroups); } computeCellGroups.ForeignKeyConstraints = ForeignConstraint.GetForeignConstraints(args.ContainerMapping.StorageEntityContainer); List <Set <Cell> > source = new CellPartitioner((IEnumerable <Cell>)computeCellGroups.Cells, (IEnumerable <ForeignConstraint>)computeCellGroups.ForeignKeyConstraints).GroupRelatedCells(); computeCellGroups.CellGroups = source.Select <Set <Cell>, Set <Cell> >((Func <Set <Cell>, Set <Cell> >)(setOfcells => new Set <Cell>(setOfcells.Select <Cell, Cell>((Func <Cell, Cell>)(cell => new Cell(cell)))))).ToList <Set <Cell> >(); return(computeCellGroups); }