Implemented matching dice rooms
This commit is contained in:
parent
dbef10d80a
commit
1b55b43f34
3 changed files with 59 additions and 12 deletions
|
|
@ -4,12 +4,19 @@ using TMPro;
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
enum KeyType
|
||||
{
|
||||
Number,
|
||||
MatchinDice
|
||||
}
|
||||
|
||||
public class Room : MonoBehaviour
|
||||
{
|
||||
public int number;
|
||||
public GameObject numberTextObject;
|
||||
public List<GameObject> adjacentRooms;
|
||||
public bool isEntrance;
|
||||
[SerializeField] private GameObject numberTextObject;
|
||||
[SerializeField] private List<GameObject> adjacentRooms;
|
||||
[SerializeField] private bool isEntrance;
|
||||
[SerializeField] private KeyType keyType;
|
||||
[SerializeField] private int number;
|
||||
public event EventHandler<Room> ValidRoomClicked;
|
||||
|
||||
bool _isExplored = false;
|
||||
|
|
@ -25,7 +32,15 @@ public class Room : MonoBehaviour
|
|||
}
|
||||
|
||||
TextMeshProUGUI numberText = numberTextObject.GetComponent<TextMeshProUGUI>();
|
||||
numberText.SetText(number.ToString());
|
||||
|
||||
if (keyType == KeyType.Number)
|
||||
{
|
||||
numberText.SetText(number.ToString());
|
||||
}
|
||||
else if (keyType == KeyType.MatchinDice)
|
||||
{
|
||||
numberText.SetText("=");
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRoomExplored() {
|
||||
|
|
@ -89,4 +104,26 @@ public class Room : MonoBehaviour
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryUnlock(DicePair pair)
|
||||
{
|
||||
switch (keyType)
|
||||
{
|
||||
case KeyType.Number:
|
||||
if (number == pair.Sum())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case KeyType.MatchinDice:
|
||||
if (pair.DoResultsMatch())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue