Skip to content

Commit 2d9ae66

Browse files
committed
Added NotAvailable property to grid slot.
1 parent 63ee5d6 commit 2d9ae66

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

Assets/Plugins/Match3/Core/Models/GridSlot.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class GridSlot<TItem> where TItem : IItem
99
public bool HasItem => Item != null;
1010
public bool IsMovable => State.IsLocked == false && HasItem;
1111
public bool CanSetItem => State.CanContainItem && HasItem == false;
12+
public bool NotAvailable => State.CanContainItem == false || State.IsLocked;
1213

1314
public TItem Item { get; private set; }
1415
public IGridSlotState State { get; }
@@ -27,11 +28,6 @@ public void SetItem(TItem item)
2728
Item = item;
2829
}
2930

30-
public IGridSlotState GetState()
31-
{
32-
return State;
33-
}
34-
3531
public void Clear()
3632
{
3733
if (State.CanContainItem == false)

Assets/Scripts/Common/GridSlotStates.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.

Assets/Scripts/Common/LevelGoals/CollectRowMaxItems.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private int GetMaxRowLength(IGameBoard<IUnityItem> gameBoard)
4444

4545
for (var columnIndex = 0; columnIndex < gameBoard.ColumnCount; columnIndex++)
4646
{
47-
if (gameBoard[rowIndex, columnIndex].CanSetItem)
47+
if (gameBoard[rowIndex, columnIndex].State.CanContainItem)
4848
{
4949
availableSlots++;
5050
continue;

Assets/Scripts/FillStrategies/FallDownFillStrategy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private List<ItemMoveData> GetItemsMoveData(IGameBoard<IUnityItem> gameBoard, in
6969
for (var rowIndex = gameBoard.RowCount - 1; rowIndex >= 0; rowIndex--)
7070
{
7171
var gridSlot = gameBoard[rowIndex, columnIndex];
72-
if (gridSlot.HasItem == false || gridSlot.IsMovable == false)
72+
if (gridSlot.IsMovable == false)
7373
{
7474
continue;
7575
}
@@ -131,7 +131,7 @@ private GridPosition GetItemGeneratorPosition(IGameBoard<IUnityItem> gameBoard,
131131
while (rowIndex >= 0)
132132
{
133133
var gridSlot = gameBoard[rowIndex, columnIndex];
134-
if (gridSlot.State.IsLocked || gridSlot.State.CanContainItem == false)
134+
if (gridSlot.NotAvailable)
135135
{
136136
return new GridPosition(rowIndex, columnIndex);
137137
}

Assets/Scripts/FillStrategies/SlideDownFillStrategy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private List<ItemMoveData> GetColumnItemsMoveData(IGameBoard<IUnityItem> gameBoa
170170
private ItemMoveData GetItemMoveData(IGameBoard<IUnityItem> gameBoard, int rowIndex, int columnIndex)
171171
{
172172
var gridSlot = gameBoard[rowIndex, columnIndex];
173-
if (gridSlot.HasItem == false || gridSlot.IsMovable == false)
173+
if (gridSlot.IsMovable == false)
174174
{
175175
return null;
176176
}
@@ -198,7 +198,7 @@ private bool CanDropFromTop(IGameBoard<IUnityItem> gameBoard, int rowIndex, int
198198
while (rowIndex >= 0)
199199
{
200200
var gridSlot = gameBoard[rowIndex, columnIndex];
201-
if (gridSlot.State.IsLocked || gridSlot.State.CanContainItem == false)
201+
if (gridSlot.NotAvailable)
202202
{
203203
return false;
204204
}
@@ -241,7 +241,7 @@ private bool CanDropDiagonally(IGameBoard<IUnityItem> gameBoard, GridSlot<IUnity
241241
GridPosition direction, out GridPosition gridPosition)
242242
{
243243
var sideGridSlot = gameBoard.GetSideGridSlot(gridSlot, direction);
244-
if (sideGridSlot != null && (sideGridSlot.State.IsLocked || sideGridSlot.State.CanContainItem == false))
244+
if (sideGridSlot is { NotAvailable: true })
245245
{
246246
return gameBoard.CanMoveDown(sideGridSlot, out gridPosition);
247247
}

0 commit comments

Comments
 (0)