void CheckCell(Cell cell, Neighbours.Direction direction) { int x = cell.GetNeighbour(direction).Item1; int y = cell.GetNeighbour(direction).Item2; Color currentColor = cell.GetColor(); Boolean check = false; while (x > 0 && y > 0 && x < 9 && y < 9) { Cell nextCell = Cells[x, y]; Color nextCellColor = nextCell.GetColor(); if (nextCell.IsOccupied()) { check = (nextCellColor != currentColor && nextCellColor != Color.blue); } if (!nextCell.IsOccupied()) { if (check) { nextCell.SetKoma(Cell.KOMA.Blue); } break; } cell = nextCell; x = cell.GetNeighbour(direction).Item1; y = cell.GetNeighbour(direction).Item2; } }
void FlipCell(Cell cell, Neighbours.Direction direction) { int x = cell.GetNeighbour(direction).Item1; int y = cell.GetNeighbour(direction).Item2; Color currentColor = cell.GetColor(); Boolean check = false; List <Cell> Temp = new List <Cell>(); while (x > 0 && y > 0 && x < 9 && y < 9) { Cell nextCell = Cells[x, y]; Debug.Log($"direction : {direction} index : {cell.GetIndex()} next : ({x},{y})"); Color nextCellColor = nextCell.GetColor(); if (nextCell.IsOccupied()) { check = (nextCellColor != currentColor && nextCellColor != Color.blue); if (check) { Temp.Add(nextCell); } } if (nextCell.IsOccupied() && nextCellColor == currentColor) { foreach (var item in Temp) { if (currentColor == Color.black) { item.SetKoma(Cell.KOMA.Black); } else { item.SetKoma(Cell.KOMA.White); } } break; } cell = nextCell; x = cell.GetNeighbour(direction).Item1; y = cell.GetNeighbour(direction).Item2; } }
public (int, int) GetNeighbour(Neighbours.Direction direction) { return(_neighbours.GetNeighbour(direction)); }