58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using GhostSystem;
|
|
using JetBrains.Annotations;
|
|
using Oculus.Interaction;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
// Dieses Script liest die RoomPrefs eines Raums beim Start der Szene aus, aktiviert oder deaktiviert die entsprechenden Objekte und löst das Event aus, dass die Szene vollständig
|
|
// geladen wurde.
|
|
|
|
public class RoomManager : MonoBehaviour
|
|
{
|
|
public RoomPrefs myRoom;
|
|
public string sceneId;
|
|
public List<GameObject> doors;
|
|
public List<GameObject> furnitures;
|
|
public List<GameObject> portals;
|
|
public List<GameObject> enemies;
|
|
public List<RecieveHeat> targets;
|
|
|
|
public static event Action<string, List<GameObject>, List<RecieveHeat>> OnSceneIdReady; // um das Replay erst auszulösen, wenn die SceneId da ist, die nun über die RoomPrefs festgelegt wird.
|
|
GhostRecorderBatch ghostRecorder;
|
|
|
|
public void Awake()
|
|
{
|
|
ghostRecorder = FindFirstObjectByType<GhostRecorderBatch>();
|
|
if (myRoom == null)
|
|
{
|
|
Debug.LogError("RoomPrefs is not assigned in RoomManager.");
|
|
return;
|
|
}
|
|
|
|
//if (!myRoom.doors && myRoom.furniture && !myRoom.portals && !myRoom.enemies) return;
|
|
if (myRoom.doors)
|
|
{
|
|
foreach (GameObject door in doors)
|
|
{
|
|
door.SetActive(true);
|
|
}
|
|
}
|
|
if (!myRoom.furniture)
|
|
{
|
|
foreach (GameObject f in furnitures) f.SetActive(false);
|
|
}
|
|
if (myRoom.portals)
|
|
{
|
|
foreach (GameObject portal in portals) portal.SetActive(true);
|
|
}
|
|
if (myRoom.enemies)
|
|
{
|
|
foreach (GameObject enemy in enemies) enemy.SetActive(true);
|
|
}
|
|
sceneId = myRoom.sceneId;
|
|
OnSceneIdReady?.Invoke(sceneId, doors, targets); // Mit dem Event werden auch einige Informationen wie die SceneID, die Liste der Türen und die Liste der Target-Objekte
|
|
// an Abonnenten übergeben.
|
|
}
|
|
} |