public Block FindFillBlock() { //위쪽방향 우선 찾기 var nextCoords = coords; Vector2Int maxUpCoords = coords; while (true) { nextCoords = BoardUtil.GetNeighbor(nextCoords, Direction.Up); if (!BoardManager.instance.IsEnable(nextCoords)) { maxUpCoords = BoardUtil.GetNeighbor(nextCoords, Direction.Down); break; } var nextBlock = BlockManager.instance.GetBlock(nextCoords); if (nextBlock != null) { return(nextBlock); } } int centerX = Global.MAX_SIZE.x / 2; if (coords.x == centerX) { return(null); } if (coords.x < centerX) { nextCoords = maxUpCoords; for (int i = 0; i < centerX - coords.x; i++) { nextCoords = BoardUtil.GetNeighbor(nextCoords, Direction.RightUp); var nextBlock = BlockManager.instance.GetBlock(nextCoords); if (nextBlock != null) { return(nextBlock); } } return(null); } else { nextCoords = maxUpCoords; for (int i = 0; i < coords.x - centerX; i++) { nextCoords = BoardUtil.GetNeighbor(nextCoords, Direction.LeftUp); var nextBlock = BlockManager.instance.GetBlock(nextCoords); if (nextBlock != null) { return(nextBlock); } } return(null); } }
private Vector3 GetVia(Vector2Int startCoords, Vector2Int targetCoords) { var coords = startCoords; int count = Mathf.Abs(targetCoords.x - startCoords.x); Direction dir = Direction.LeftDown; if (startCoords.x < targetCoords.x) { dir = Direction.RightDown; } for (int i = 0; i < count; i++) { coords = BoardUtil.GetNeighbor(coords, dir); } return(BoardUtil.GetPosition(coords)); }
public Block GetNeighbor(Block origin, Direction dir) { return(blocks.Find(x => x.coords == BoardUtil.GetNeighbor(origin.coords, dir))); }
public Block GetNeighbor(Vector2Int coords, Direction dir) { return(blocks.Find(x => x.coords == BoardUtil.GetNeighbor(coords, dir))); }
public Board NextBoard(Board board, Direction dir) { return(boards.Find(x => x.coords == BoardUtil.GetNeighbor(board.coords, dir))); }