Repository navigation
Expand file tree
/
Copy pathLevelExit.cs
More file actions
56 lines (45 loc) · 1.76 KB
/
Copy pathLevelExit.cs
File metadata and controls
56 lines (45 loc) · 1.76 KB
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
48
49
50
51
52
53
54
55
using UnityEngine;
using TMPro;
public class LevelExit : MonoBehaviour
{
//Este script gestiona la interacción con el diálogo de salida del nivel.
//El cuál debe comprobar si el jugador ha rescatado a todos los héroes.
//No he reciclado el script de DialogHandler para esto, ya que la manera en la que se
// activa/desactiva el mensaje al pulsar la tecla de interacción es diferente.
[SerializeField] private SpriteRenderer keypressWhite;
[SerializeField] private GameObject visibleDialog;
[SerializeField] private GameObject lockedDialog;
[SerializeField] private PlayerStats playerStats;
private bool dialogActivated;
void Awake() {
visibleDialog.SetActive(false);
lockedDialog.SetActive(false);
}
private void OnTriggerEnter(Collider other) {
if (other.CompareTag("Visor")) {
lockedDialog.SetActive(true);
InvokeRepeating("KeyPressBlinkingAnimation",0f, 0.5f);
}
other.GetComponentInParent<InputHandler>()?.SetLevelExit(this);
}
private void OnTriggerExit(Collider other) {
if (other.CompareTag("Visor")) {
CancelInvoke("KeyPressBlinkingAnimation");
lockedDialog.SetActive(false);
visibleDialog.SetActive(false);
}
other.GetComponentInParent<InputHandler>()?.ClearLevelExit();
}
public void ActivateDialog() {
CancelInvoke("KeyPressBlinkingAnimation");
lockedDialog.SetActive(false);
if (playerStats.AreAllPeopleRescued()) {
playerStats.WinGame();
} else {
visibleDialog.SetActive(true);
}
}
private void KeyPressBlinkingAnimation() {
keypressWhite.enabled = !keypressWhite.enabled;
}
}