-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBrokenSatelliteManager.cs
More file actions
121 lines (106 loc) · 4.16 KB
/
Copy pathBrokenSatelliteManager.cs
File metadata and controls
121 lines (106 loc) · 4.16 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Axiom
{
public class BrokenSatelliteManager : MonoBehaviour
{
[SerializeField]
private GameObject _triggerObject;
private OWTriggerVolume _trigger;
[SerializeField]
private AudioSource _audioSource;
private OWAudioSource _owAudioSource;
[SerializeField]
private BrokenSatelliteNode[] _satelliteNodes;
[SerializeField]
private Light[] _antennaLights;
private NoiseImageEffect _cameraNoiseEffect;
private NotificationData _helmetProgressNotification;
private int _repairCount;
private void Awake()
{
_cameraNoiseEffect = GetComponentInChildren<NoiseImageEffect>(true);
_cameraNoiseEffect.enabled = true;
foreach (var node in _satelliteNodes) node.OnRepaired += OnRepairNode;
foreach (var light in _antennaLights) light.enabled = false;
if (_audioSource != null) _owAudioSource = _audioSource.GetComponent<OWAudioSource>();
if (_triggerObject != null)
{
_trigger = _triggerObject.GetComponent<OWTriggerVolume>();
if (_trigger != null)
{
_trigger.OnEntry += OnEntry;
_trigger.OnExit += OnExit;
}
}
}
private void OnDestroy()
{
foreach (var node in _satelliteNodes) node.OnRepaired -= OnRepairNode;
if (_trigger != null)
{
_trigger.OnEntry -= OnEntry;
_trigger.OnExit -= OnExit;
}
}
private void OnRepairNode(BrokenSatelliteNode node)
{
_repairCount++;
UpdateNotification();
if (_repairCount >= _satelliteNodes.Length)
{
DialogueConditionManager.SharedInstance.SetConditionState("PostAxiomBrokenSatellite", conditionState: true);
Locator.GetShipLogManager().RevealFact("AXIOM_BROKEN_SATELLITE_X2");
foreach (var light in _antennaLights) light.enabled = true;
_cameraNoiseEffect.enabled = false;
_owAudioSource.PlayOneShot(AudioType.TH_ZeroGTrainingAllRepaired, 2);
}
}
private void UpdateNotification()
{
if (_helmetProgressNotification != null)
{
NotificationManager.SharedInstance.UnpinNotification(_helmetProgressNotification);
}
if (_repairCount < _satelliteNodes.Length)
{
_helmetProgressNotification = new NotificationData(NotificationTarget.Player, _repairCount + UITextLibrary.GetString(UITextType.Notification0gTraining));
NotificationManager.SharedInstance.PostNotification(_helmetProgressNotification, pin: true);
}
else
{
_helmetProgressNotification = new NotificationData(NotificationTarget.Player, _repairCount + UITextLibrary.GetString(UITextType.Notification0gTraining), 10f);
NotificationManager.SharedInstance.PostNotification(_helmetProgressNotification, pin: true);
}
}
private void RemoveNotification()
{
if (_helmetProgressNotification != null)
{
NotificationManager.SharedInstance.UnpinNotification(_helmetProgressNotification);
}
_helmetProgressNotification = null;
}
private void OnEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
UpdateNotification();
GlobalMessenger.FireEvent("EnterAxiomBrokenSatellite");
Locator.GetShipLogManager().RevealFact("AXIOM_BROKEN_SATELLITE");
}
}
private void OnExit(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector"))
{
RemoveNotification();
GlobalMessenger.FireEvent("ExitAxiomBrokenSatellite");
}
}
}
}