Implemented loading dungeon map json into Unity.

This commit is contained in:
Max 2025-02-11 18:19:18 +01:00
parent 0ff1e92fb9
commit ec466ee6cd
82 changed files with 252177 additions and 1068 deletions

View file

@ -4,12 +4,13 @@ using TMPro;
using UnityEngine;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine.Serialization;
public abstract class Room : MonoBehaviour
{
[SerializeField] private List<GameObject> adjacentRooms;
[SerializeField] private bool isEntrance;
[FormerlySerializedAs("adjacentRooms")] [SerializeField] public List<GameObject> AdjacentRooms;
[SerializeField] public bool IsEntrance { get; set; }
[SerializeField] protected RoomReward roomReward;
public event EventHandler<Room> RoomExploredByDice;
public static event Action<Room> RoomExploredByTorch;
@ -40,7 +41,7 @@ public abstract class Room : MonoBehaviour
InitializeRoom();
_roomNumberOriginalColor = gameObject.GetComponentInChildren<TextMeshProUGUI>().color;
}
public bool GetRoomExplored()
{
return _isExplored;
@ -49,7 +50,7 @@ public abstract class Room : MonoBehaviour
public abstract void SetRoomExplored();
protected virtual void InitializeRoom() {
if (isEntrance) {
if (IsEntrance) {
SetPropertiesOfEntrance();
}
_locks = gameObject.GetComponents<Lock>();
@ -67,7 +68,7 @@ public abstract class Room : MonoBehaviour
void SetPropertiesOfEntrance() {
gameObject.GetComponent<SpriteRenderer>().color = Color.green;
isEntrance = true;
IsEntrance = true;
}
void OnMouseDown() {
@ -113,7 +114,7 @@ public abstract class Room : MonoBehaviour
return false;
}
if (isEntrance) {
if (IsEntrance) {
// All entrance rooms are valid to be explored.
return true;
}
@ -125,7 +126,7 @@ public abstract class Room : MonoBehaviour
}
bool HasExploredAdjacentRooms() {
foreach (GameObject adjacentRoom in adjacentRooms) {
foreach (GameObject adjacentRoom in AdjacentRooms) {
if (adjacentRoom.GetComponent<Room>()._isExplored)
{
return true;