Fixed bug where highlighted room would not unhighlight and refactored room highlighting to be habdled by rooms.

This commit is contained in:
Maxwell Dodd 2025-01-27 14:41:40 +01:00
parent bcfd42147b
commit 84fda847a8
2 changed files with 31 additions and 30 deletions

View file

@ -3,6 +3,7 @@ using System.Collections;
using TMPro;
using UnityEngine;
using System.Collections.Generic;
using Unity.VisualScripting;
enum KeyType
{
@ -23,10 +24,20 @@ public class Room : MonoBehaviour
private bool _isClickable = true;
private Color _roomNumberOriginalColor;
private void OnEnable() {
GameManager.StateChanged += HandleStateChange;
GameManager.DiceSelected += HandleDiceSelected;
GameManager.DiceUnselected += HandDiceUnselected;
}
private void OnDisable() {
GameManager.StateChanged -= HandleStateChange;
GameManager.DiceSelected -= HandleDiceSelected;
GameManager.DiceUnselected -= HandDiceUnselected;
}
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start() {
GameManager.StateChanged += HandleStateChange;
if (isEntrance) {
SetPropertiesOfEntrance();
}
@ -44,10 +55,6 @@ public class Room : MonoBehaviour
}
}
private void OnEnable() {
}
public void SetRoomExplored() {
_isExplored = true;
UnhighlightRoomAsOption();
@ -131,6 +138,7 @@ public class Room : MonoBehaviour
}
private void HandleStateChange(GameState state) {
UnhighlightRoomAsOption();
switch (state)
{
case GameState.PickDiceOne:
@ -144,4 +152,15 @@ public class Room : MonoBehaviour
break;
}
}
private void HandleDiceSelected(DicePair pair) {
if (TryUnlock(pair) && IsValidRoomToExplore())
{
HighlightRoomAsOption();
}
}
private void HandDiceUnselected() {
UnhighlightRoomAsOption();
}
}