IEnumerator MoveToPoint() { GridTile currentTile = Grid.Tiles[_currentRow][_currentColumn]; Vector3 position = currentTile.Position; while (Vector3.Distance(transform.position, position) > .01f) { transform.position = Vector3.MoveTowards(transform.position, position, MoveSpeed * Time.deltaTime); yield return(new WaitForEndOfFrame()); } currentTile.Clean(); _swept[_currentRow, _currentColumn] = true; }
void Start() { _rows = Grid.Tiles.Length; _columns = Grid.Tiles[0].Length; _currentRow = _rows / 2; _currentColumn = _columns / 2; _swept = new bool[_rows, _columns]; GridTile firstTile = Grid.Tiles[_currentRow][_currentColumn]; transform.position = firstTile.Position; _swept[_currentRow, _currentColumn] = true; firstTile.Clean(); StartCoroutine(Sweep()); }