-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLightsOut.cs
47 lines (34 loc) · 1.46 KB
/
LightsOut.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Collections;
using System.Collections.Generic;
using UHFPS.Runtime;
using UnityEngine;
public class LightsOut : MonoBehaviour
{
[Header("ASSIGNMENTS")]
[Tooltip("These are the Light GameObjects you need to be disabled")]
[SerializeField] private List<GameObject> roomLights;
[Header("THESE WILL BE PULLED AUTOMATICALLY")]
[Tooltip("You can check if the assigned objects are correctly set in the List")]
[SerializeField] private List<EmissionController> emissionControllerScripts; //Objects that emission controller script has been attached to
private void Awake()
{
// Find all EmissionController scripts in the scene and store them in the emissionControllerScripts list
emissionControllerScripts = new List<EmissionController>(FindObjectsOfType<EmissionController>());
}
private void OnTriggerEnter(Collider other)
{
//Play electricity outage sound here
//Turn the emission off in all the objects that the Emission Controller Script is attached to
foreach (var emissionController in emissionControllerScripts)
{
emissionController.TurnEmissionOff();
}
//Disable all the lights that is in the list
foreach (GameObject light in roomLights)
{
light.SetActive(false);
}
//Afterwards disable this object
this.gameObject.SetActive(false);
}
}