diff --git a/3D blobici/Assets/Scripts/MainGame.meta b/3D blobici/Assets/Scripts/MainGame.meta new file mode 100644 index 0000000..f75da05 --- /dev/null +++ b/3D blobici/Assets/Scripts/MainGame.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d14a4ecb526ba8a4bb8e6a020cab4f1f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/3D blobici/Assets/Scripts/MainGame/GameHandler.cs b/3D blobici/Assets/Scripts/MainGame/GameHandler.cs new file mode 100644 index 0000000..161c261 --- /dev/null +++ b/3D blobici/Assets/Scripts/MainGame/GameHandler.cs @@ -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(); + + 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(); + + } + } +} diff --git a/3D blobici/Assets/Scripts/MainGame/GameHandler.cs.meta b/3D blobici/Assets/Scripts/MainGame/GameHandler.cs.meta new file mode 100644 index 0000000..7645d1d --- /dev/null +++ b/3D blobici/Assets/Scripts/MainGame/GameHandler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5520a437c5690d24695f9830bbd741b0 \ No newline at end of file diff --git a/3D blobici/Assets/Scripts/MapGen/MapGenManager.cs b/3D blobici/Assets/Scripts/MapGen/MapGenManager.cs index 37bf3d3..b90b2e3 100644 --- a/3D blobici/Assets/Scripts/MapGen/MapGenManager.cs +++ b/3D blobici/Assets/Scripts/MapGen/MapGenManager.cs @@ -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 gridToRoom = new(); + public event Action OnGenerationComplete; + public IReadOnlyDictionary GridToRoom => gridToRoom; void Start() => GenerateFromLayout(); @@ -85,6 +88,8 @@ public class MapGenManager : MonoBehaviour RoomHandler rh = keyValuePair.Value.GetComponent(); rh.ToggleAllDoors(); } + + OnGenerationComplete?.Invoke(this); } ///