Skip to content

Commit 65d0c9c

Browse files
committed
Refactoring.
1 parent 6422ca4 commit 65d0c9c

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

Assets/Scripts/Common/UnityGameBoardRenderer.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,7 @@ public void CreateGridTiles()
5858
_gridSlotTiles = new IGridTile[_rowCount, _columnCount];
5959
_originPosition = GetOriginPosition(_rowCount, _columnCount);
6060

61-
for (var rowIndex = 0; rowIndex < _rowCount; rowIndex++)
62-
{
63-
for (var columnIndex = 0; columnIndex < _columnCount; columnIndex++)
64-
{
65-
SetTile(rowIndex, columnIndex, TileGroup.Available);
66-
}
67-
}
61+
SetTilesGroup(TileGroup.Available);
6862
}
6963

7064
public bool IsTileActive(GridPosition gridPosition)
@@ -122,14 +116,7 @@ public TileGroup GetTileGroup(GridPosition gridPosition)
122116

123117
public void ResetState()
124118
{
125-
for (var rowIndex = 0; rowIndex < _rowCount; rowIndex++)
126-
{
127-
for (var columnIndex = 0; columnIndex < _columnCount; columnIndex++)
128-
{
129-
SetTile(rowIndex, columnIndex, TileGroup.Available);
130-
}
131-
}
132-
119+
SetTilesGroup(TileGroup.Available);
133120
ResetGameBoardData();
134121
}
135122

@@ -173,6 +160,17 @@ private IGridTile GetTile(int rowIndex, int columnIndex, TileGroup group)
173160
return tile;
174161
}
175162

163+
private void SetTilesGroup(TileGroup group)
164+
{
165+
for (var rowIndex = 0; rowIndex < _rowCount; rowIndex++)
166+
{
167+
for (var columnIndex = 0; columnIndex < _columnCount; columnIndex++)
168+
{
169+
SetTile(rowIndex, columnIndex, group);
170+
}
171+
}
172+
}
173+
176174
private void SetTile(int rowIndex, int columnIndex, TileGroup group)
177175
{
178176
var currentTile = _gridSlotTiles[rowIndex, columnIndex];

0 commit comments

Comments
 (0)