Added a basic GameHandler

This commit is contained in:
2025-06-30 18:31:40 +02:00
parent bcce66a3f5
commit 668354d601
4 changed files with 52 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d14a4ecb526ba8a4bb8e6a020cab4f1f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,36 @@
using UnityEngine;
public class GameHandler : MonoBehaviour
{
private MapGenManager mapGen;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Awake()
{
mapGen = GetComponent<MapGenManager>();
mapGen.OnGenerationComplete += HandleStart;
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void HandleStart(MapGenManager map)
{
var Rooms = map.GridToRoom;
/*----- For now only open the doors -----*/
foreach (var room in mapGen.GridToRoom)
{
var rh = room.Value.GetComponent<RoomHandler>();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5520a437c5690d24695f9830bbd741b0

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -23,6 +24,8 @@ public class MapGenManager : MonoBehaviour
[SerializeField] private int RoomDistance = 3;
private readonly Dictionary<Vector2Int, GameObject> gridToRoom = new();
public event Action<MapGenManager> OnGenerationComplete;
public IReadOnlyDictionary<Vector2Int, GameObject> GridToRoom => gridToRoom;
void Start() => GenerateFromLayout();
@@ -85,6 +88,8 @@ public class MapGenManager : MonoBehaviour
RoomHandler rh = keyValuePair.Value.GetComponent<RoomHandler>();
rh.ToggleAllDoors();
}
OnGenerationComplete?.Invoke(this);
}
/// <summary>