UNFINISHED Implemented procedural dice generation. Way too hard

This commit is contained in:
Max 2025-02-17 16:51:45 +01:00
parent ea1ca7a0cd
commit 03f0f7859e
43 changed files with 13909 additions and 57 deletions

View file

@ -28,12 +28,14 @@ namespace DungeonGenerator
GameObject bossRoomGO = PrefabUtility.InstantiatePrefab(bossRoomPrefab, gameObject.transform) as GameObject;
bossRoomGO.transform.position = ConvertToUnityPosition(map.GetBossRoom().GetCenterOfRoom(), map.Width, map.Height);
AddLockToRoomObject(bossRoomGO, map.GetBossRoom().Lock.GetLock());
_roomIdToGameObject[map.GetBossRoom().Id] = bossRoomGO;
foreach (var monsterRoom in map.GetMonsterRooms())
{
GameObject monsterRoomGO = PrefabUtility.InstantiatePrefab(monsterRoomPrefab, gameObject.transform) as GameObject;
monsterRoomGO.transform.position = ConvertToUnityPosition(monsterRoom.GetCenterOfRoom(), map.Width, map.Height);
AddLockToRoomObject(monsterRoomGO, monsterRoom.Lock.GetLock());
_roomIdToGameObject[monsterRoom.Id] = monsterRoomGO;
}
@ -41,6 +43,7 @@ namespace DungeonGenerator
{
GameObject normalRoomGO = PrefabUtility.InstantiatePrefab(normalRoomPrefab, gameObject.transform) as GameObject;
normalRoomGO.transform.position = ConvertToUnityPosition(normalRoom.GetCenterOfRoom(), map.Width, map.Height);
AddLockToRoomObject(normalRoomGO, normalRoom.Lock.GetLock());
_roomIdToGameObject[normalRoom.Id] = normalRoomGO;
}
@ -49,6 +52,7 @@ namespace DungeonGenerator
GameObject entranceRoomGO = PrefabUtility.InstantiatePrefab(normalRoomPrefab, gameObject.transform) as GameObject;
entranceRoomGO.transform.position = ConvertToUnityPosition(entranceRoom.GetCenterOfRoom(), map.Width, map.Height);
entranceRoomGO.GetComponent<Room>().IsEntrance = true;
AddLockToRoomObject(entranceRoomGO, entranceRoom.Lock.GetLock());
_roomIdToGameObject[entranceRoom.Id] = entranceRoomGO;
}
@ -70,5 +74,35 @@ namespace DungeonGenerator
return new Vector3(newX, newY, 0f);
}
private void AddLockToRoomObject(GameObject room, string lockString)
{
NumberLock _lock;
switch (lockString)
{
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "10":
case "11":
case "12":
_lock = room.AddComponent<NumberLock>();
_lock.SetNumber(Int32.Parse(lockString));
break;
case "=":
room.AddComponent<MatchingDiceLock>();
break;
case null:
Debug.Log("Lock for room was null when imported. Using 1 as lock");
_lock = room.AddComponent<NumberLock>();
_lock.SetNumber(1);
break;
}
}
}
}