Implemented unselecting dice selection
This commit is contained in:
parent
1b55b43f34
commit
31917ba415
5 changed files with 78 additions and 14 deletions
|
|
@ -1381,6 +1381,10 @@ PrefabInstance:
|
|||
propertyPath: number
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2727030095425591755, guid: 92d87e25cc40b3e448e62e8ba0328315, type: 3}
|
||||
propertyPath: keyType
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2727030095425591755, guid: 92d87e25cc40b3e448e62e8ba0328315, type: 3}
|
||||
propertyPath: isEntrance
|
||||
value: 1
|
||||
|
|
@ -1913,6 +1917,10 @@ PrefabInstance:
|
|||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 1820284206}
|
||||
m_Modifications:
|
||||
- target: {fileID: -1465197196826248026, guid: 92d87e25cc40b3e448e62e8ba0328315, type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2435349004046080434, guid: 92d87e25cc40b3e448e62e8ba0328315, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Room (10)
|
||||
|
|
@ -1921,6 +1929,10 @@ PrefabInstance:
|
|||
propertyPath: number
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2727030095425591755, guid: 92d87e25cc40b3e448e62e8ba0328315, type: 3}
|
||||
propertyPath: keyType
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2727030095425591755, guid: 92d87e25cc40b3e448e62e8ba0328315, type: 3}
|
||||
propertyPath: adjacentRooms.Array.size
|
||||
value: 2
|
||||
|
|
|
|||
|
|
@ -9,17 +9,41 @@ public class DicePair
|
|||
if (_pair.Item1 == null && _pair.Item2 == null)
|
||||
{
|
||||
_pair.Item1 = die;
|
||||
die.DieBeingUsed(true, false);
|
||||
die.DieBeingUsed(false);
|
||||
}
|
||||
else if (_pair.Item2 == null)
|
||||
{
|
||||
_pair.Item2 = die;
|
||||
_pair.Item1.DieBeingUsed(true, true);
|
||||
die.DieBeingUsed(true, true);
|
||||
_pair.Item1.DieBeingUsed(true);
|
||||
die.DieBeingUsed(true);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDieInPair(Die die)
|
||||
public void UnselectDie(Die die)
|
||||
{
|
||||
if (_pair.Item1 == die)
|
||||
{
|
||||
_pair.Item1.ResetDie();
|
||||
_pair.Item1 = null;
|
||||
if (_pair.Item2 != null)
|
||||
{
|
||||
_pair.Item2.ResetDie();
|
||||
_pair.Item2.DieBeingUsed(false);
|
||||
}
|
||||
}
|
||||
else if (_pair.Item2 == die)
|
||||
{
|
||||
_pair.Item2.ResetDie();
|
||||
_pair.Item2 = null;
|
||||
if (_pair.Item1 != null)
|
||||
{
|
||||
_pair.Item1.ResetDie();
|
||||
_pair.Item1.DieBeingUsed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ContainsDie(Die die)
|
||||
{
|
||||
if (_pair.Item1 == die || _pair.Item2 == die)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,9 +37,10 @@ public class Die : MonoBehaviour
|
|||
public void ResetDie()
|
||||
{
|
||||
gameObject.GetComponent<Image>().color = originalColor;
|
||||
gameObject.GetComponent<Outline>().enabled = false;
|
||||
}
|
||||
|
||||
public void DieBeingUsed(bool isFirstPair, bool isPairComplete)
|
||||
public void DieBeingUsed(bool isPairComplete)
|
||||
{
|
||||
if (isPairComplete)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -72,16 +72,11 @@ public class GameManager : MonoBehaviour
|
|||
|
||||
void DieClicked(object sender, Die die)
|
||||
{
|
||||
if (state != GameState.PickDiceOne && state != GameState.PickDiceTwo)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case GameState.PickDiceOne:
|
||||
{
|
||||
if (!_dicePairOne.IsDieInPair(die))
|
||||
if (!_dicePairOne.ContainsDie(die))
|
||||
{
|
||||
_dicePairOne.SelectDie(die);
|
||||
|
||||
|
|
@ -91,12 +86,16 @@ public class GameManager : MonoBehaviour
|
|||
HighLightValidRoomsWithNumber(_dicePairOne);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_dicePairOne.UnselectDie(die);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GameState.PickDiceTwo:
|
||||
{
|
||||
if (!_dicePairTwo.IsDieInPair(die) && !_dicePairOne.IsDieInPair(die))
|
||||
if (!_dicePairTwo.ContainsDie(die) && !_dicePairOne.ContainsDie(die))
|
||||
{
|
||||
_dicePairTwo.SelectDie(die);
|
||||
|
||||
|
|
@ -106,9 +105,29 @@ public class GameManager : MonoBehaviour
|
|||
HighLightValidRoomsWithNumber(_dicePairTwo);
|
||||
}
|
||||
}
|
||||
else if (_dicePairTwo.ContainsDie(die))
|
||||
{
|
||||
_dicePairTwo.UnselectDie(die);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GameState.PickRoomOne:
|
||||
if (_dicePairOne.ContainsDie(die))
|
||||
{
|
||||
_dicePairOne.UnselectDie(die);
|
||||
UnhighLightRoomsAsOptions();
|
||||
state = GameState.PickDiceOne;
|
||||
}
|
||||
break;
|
||||
case GameState.PickRoomTwo:
|
||||
if (_dicePairTwo.ContainsDie(die))
|
||||
{
|
||||
_dicePairTwo.UnselectDie(die);
|
||||
UnhighLightRoomsAsOptions();
|
||||
state = GameState.PickDiceTwo;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,6 +143,14 @@ public class GameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
void UnhighLightRoomsAsOptions()
|
||||
{
|
||||
foreach (Transform roomTransform in rooms.transform)
|
||||
{
|
||||
roomTransform.gameObject.GetComponent<Room>().UnhighlightRoomAsOption();
|
||||
}
|
||||
}
|
||||
|
||||
private void DiceRolled(object sender, EventArgs e)
|
||||
{
|
||||
if (state == GameState.RollDice)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public class Room : MonoBehaviour
|
|||
}
|
||||
|
||||
TextMeshProUGUI numberText = numberTextObject.GetComponent<TextMeshProUGUI>();
|
||||
_roomNumberOriginalColor = gameObject.GetComponentInChildren<TextMeshProUGUI>().color;
|
||||
|
||||
if (keyType == KeyType.Number)
|
||||
{
|
||||
|
|
@ -52,7 +53,6 @@ public class Room : MonoBehaviour
|
|||
|
||||
public void HighlightRoomAsOption()
|
||||
{
|
||||
_roomNumberOriginalColor = gameObject.GetComponentInChildren<TextMeshProUGUI>().color;
|
||||
gameObject.GetComponentInChildren<TextMeshProUGUI>().color = Color.blue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue