Fixed bug where highlighted room would not unhighlight and refactored room highlighting to be habdled by rooms.
This commit is contained in:
parent
bcfd42147b
commit
6a309804ad
2 changed files with 38 additions and 37 deletions
|
|
@ -25,6 +25,8 @@ public class GameManager : MonoBehaviour
|
|||
private DicePair _dicePairOne = new();
|
||||
private DicePair _dicePairTwo = new();
|
||||
public static event Action<GameState> StateChanged;
|
||||
public static event Action<DicePair> DiceSelected;
|
||||
public static event Action DiceUnselected;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
|
|
@ -87,7 +89,7 @@ public class GameManager : MonoBehaviour
|
|||
if (_dicePairOne.AreBothDiceSelected())
|
||||
{
|
||||
ChangeState(GameState.PickRoomOne);
|
||||
HighLightValidRoomsWithNumber(_dicePairOne);
|
||||
DiceSelected?.Invoke(_dicePairOne);
|
||||
}
|
||||
break;
|
||||
case GameState.PickDiceTwo:
|
||||
|
|
@ -95,7 +97,7 @@ public class GameManager : MonoBehaviour
|
|||
if (_dicePairTwo.AreBothDiceSelected())
|
||||
{
|
||||
ChangeState(GameState.PickRoomTwo);
|
||||
HighLightValidRoomsWithNumber(_dicePairTwo);
|
||||
DiceSelected?.Invoke(_dicePairTwo);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
@ -113,7 +115,7 @@ public class GameManager : MonoBehaviour
|
|||
ChangeState(GameState.PickDiceOne);
|
||||
}
|
||||
_dicePairOne.UnselectDie(die);
|
||||
UnhighLightRoomsAsOptions();
|
||||
DiceUnselected?.Invoke();
|
||||
break;
|
||||
case GameState.PickDiceTwo:
|
||||
case GameState.PickRoomTwo:
|
||||
|
|
@ -122,7 +124,7 @@ public class GameManager : MonoBehaviour
|
|||
ChangeState(GameState.PickDiceTwo);
|
||||
}
|
||||
_dicePairTwo.UnselectDie(die);
|
||||
UnhighLightRoomsAsOptions();
|
||||
DiceUnselected?.Invoke();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -132,26 +134,6 @@ public class GameManager : MonoBehaviour
|
|||
StartNewTurn();
|
||||
}
|
||||
|
||||
void HighLightValidRoomsWithNumber(DicePair pair)
|
||||
{
|
||||
foreach (Transform roomTransform in rooms.transform)
|
||||
{
|
||||
Room room = roomTransform.gameObject.GetComponent<Room>();
|
||||
if (room.TryUnlock(pair) && room.IsValidRoomToExplore())
|
||||
{
|
||||
room.HighlightRoomAsOption();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnhighLightRoomsAsOptions()
|
||||
{
|
||||
foreach (Transform roomTransform in rooms.transform)
|
||||
{
|
||||
roomTransform.gameObject.GetComponent<Room>().UnhighlightRoomAsOption();
|
||||
}
|
||||
}
|
||||
|
||||
private void DiceRolled(object sender, EventArgs e)
|
||||
{
|
||||
if (state == GameState.RollDice)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue