Added a basic GameHandler
This commit is contained in:
8
3D blobici/Assets/Scripts/MainGame.meta
Normal file
8
3D blobici/Assets/Scripts/MainGame.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d14a4ecb526ba8a4bb8e6a020cab4f1f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
3D blobici/Assets/Scripts/MainGame/GameHandler.cs
Normal file
36
3D blobici/Assets/Scripts/MainGame/GameHandler.cs
Normal 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>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
2
3D blobici/Assets/Scripts/MainGame/GameHandler.cs.meta
Normal file
2
3D blobici/Assets/Scripts/MainGame/GameHandler.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5520a437c5690d24695f9830bbd741b0
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user