void Awake() { // subscribe to events from within the TorchEvent torchEvent = GetComponent <TorchEvent>(); torchEvent.onSignalEnabledEvent += OpenDoor; torchEvent.onRequiredTorchLitEvent += OnRequiredTorchLit; torchEvent.onRequiredTorchUnlitEvent += OnRequiredTorchUnlit; }
void Awake() { // subscribe to events from within the TorchEvent torchEvent = GetComponent <TorchEvent>(); spikeTrap = GetComponent <SpikeTrap>(); torchEvent.onSignalEnabledEvent += EnableSpike; torchEvent.onSignalDisabledEvent += DisableSpike; }
//run before Start() public bool SpawnTorch(TorchEvent torchEvent) { if (torchLocation != null) { GameObject newTorch = Instantiate(torchPrefab); newTorch.transform.rotation = torchLocation.transform.rotation; newTorch.transform.position = torchLocation.transform.position; torchEvent.AddRequiredTorch(newTorch.GetComponent <Torch>()); //foreach(GameObject spike in spikeList) // spike.GetComponent<TorchEvent>().AddRequiredTorch(newTorch.GetComponent<Torch>()); return(true); } return(false); }
private void SpawnTorches(List <GameObject> roomList) { int torchCount = 0; TorchEvent te = bossRoomPrefab.transform.Find("Architecture").Find("doors").Find("Door").GetComponent <TorchEvent>(); for (int i = roomList.Count - 1; i >= 0; i--) { MiscSpawn ms; if (ms = roomList[i].GetComponent <MiscSpawn>()) { if (ms.SpawnTorch(te)) { torchCount++; } if (torchCount >= maxTorches) { break; } } } }
void DisableSpike(TorchEvent torchEvent) { spikeTrap.shouldStayRetracted = true; }
void EnableSpike(TorchEvent torchEvent) { spikeTrap.shouldStayRetracted = false; }
void OpenDoor(TorchEvent torchEvent) { // TODO play an animation here instead. transform.position = finalPosition.position; }
void OnRequiredTorchUnlit(TorchEvent torchEvent, Torch torch) { // TODO show a visual representation of how many torches are lit, and how many remain }