-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHealthCounter.gd
212 lines (198 loc) · 8.21 KB
/
HealthCounter.gd
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
class_name HealthCounter extends Node
@export var ui_playerwin : Label3D
@export var defibCutter : DefibCutter
@export var roundManager : RoundManager
@export var symbolArray_player : Array[MeshInstance3D]
@export var symbolArray_enemy : Array[MeshInstance3D]
@export var uiparent : Node3D
@export var ui_playername : Label3D
@export var uiArray : Array[Node3D]
@export var speaker_bootup : AudioStreamPlayer3D
@export var speaker_beep : AudioStreamPlayer3D
@export var speaker_noise : AudioStreamPlayer3D
@export var camera : CameraManager
@export var animator_flickerEnemy : AnimationPlayer
@export var animator_flickerPlayer : AnimationPlayer
@export var animator_playerHands : AnimationPlayer
@export var animator_dealerHands : AnimationPlayer
@export var dialogue : Dialogue
@export var speaker_truedeath : AudioStreamPlayer2D
@export var skullSymbols : Array[VisualInstance3D]
var dialogueEntered_player = false
var dialogueEntered_dealer = false
func _ready():
ClearDisplay()
pass
var setting = true
func SetupHealth():
if (roundManager.roundArray[roundManager.currentRound].isFirstRound):
if (setting):
ui_playername.text = roundManager.playerData.playername.to_upper()
var playername_upper = roundManager.playerData.playername.to_upper()
ui_playerwin.text = tr("PLAYERWIN") % [playername_upper]
#ui_playerwin.text = roundManager.playerData.playername.to_upper() + " " + tr("PLAYERWIN")
setting = false
roundManager.health_player = roundManager.roundArray[roundManager.currentRound].startingHealth
roundManager.health_opponent = roundManager.roundArray[roundManager.currentRound].startingHealth
dialogueEntered_player = false
dialogueEntered_dealer = false
func UpdateDisplay():
for i in range(symbolArray_player.size()):
if (i <= roundManager.health_player):
symbolArray_player[i].visible = true
else: symbolArray_player[i].visible = false
for i in range(symbolArray_enemy.size()):
if (i <= roundManager.health_opponent):
symbolArray_enemy[i].visible = true
else: symbolArray_enemy[i].visible = false
FlickerLastDigit()
pass
func FlickerLastDigit():
if (roundManager.health_player == 1): animator_flickerPlayer.play("flicker digit")
else: animator_flickerPlayer.play("RESET")
if (roundManager.health_opponent == 1): animator_flickerEnemy.play("flicker digit")
else: animator_flickerEnemy.play("RESET")
var playerShotSelf = false
var trueDeathSetup = false
var checkingPlayer = false
var skipping_careful = false
func UpdateDisplayRoutine(isRaisingHealth : bool, goingToPreviousSocket : bool, showPlayerWin : bool):
var indicating = true
if (roundManager.dealerCuffed && playerShotSelf):
roundManager.waitingForHealthCheck = true
playerShotSelf = false
if (showPlayerWin):
#ERROR - FLICKER BOTH HERE
camera.BeginLerp("health counter")
await get_tree().create_timer(.8, false).timeout
UpdateDisplay()
speaker_noise.play()
return
var previousSocket = camera.activeSocket
camera.BeginLerp("health counter")
await get_tree().create_timer(.8, false).timeout
UpdateDisplay()
if (checkingPlayer && defibCutter.displayBroken_player):
indicating = false
defibCutter.BlipError("player")
if (!checkingPlayer && defibCutter.displayBroken_dealer):
indicating = false
defibCutter.BlipError("dealer")
if (indicating):
if (isRaisingHealth): speaker_beep.play()
else: speaker_noise.play()
if ((roundManager.health_opponent <= 2 or roundManager.health_player <= 2) && roundManager.playerData.currentBatchIndex == 2 && !roundManager.endless):
if (roundManager.defibCutterReady && !trueDeathSetup):
#roundManager.musicManager.EndTrack()
speaker_truedeath.play()
trueDeathSetup = true
if (roundManager.health_opponent <= 2 && !roundManager.wireIsCut_dealer):
roundManager.wireToCut = "dealer"
roundManager.requestedWireCut = true
roundManager.wireIsCut_dealer = true
roundManager.health_opponent = 1
if (roundManager.health_player <= 2 && !roundManager.wireIsCut_player):
roundManager.wireToCut = "player"
roundManager.requestedWireCut = true
roundManager.wireIsCut_player = true
roundManager.health_player = 1
#if (roundManager.shellSpawner.sequenceArray[0] == null): await get_tree().create_timer(.8, false).timeout
await get_tree().create_timer(.7, false).timeout
if (roundManager.health_player == 1 && !dialogueEntered_player && !roundManager.wireIsCut_player && !skipping_careful):
if (!roundManager.wireIsCut_player): dialogue.ShowText_ForDuration(tr("CAREFUL"), 3)
else: dialogue.ShowText_ForDuration("...", 3)
await get_tree().create_timer(3, false).timeout
dialogueEntered_player = true
if skipping_careful: skipping_careful = false
var lerpingCamera = true
if (roundManager.shellSpawner.sequenceArray.size() == 0):
#lerpingCamera = false
pass
if (lerpingCamera):
if (goingToPreviousSocket): camera.BeginLerp(previousSocket)
else: camera.BeginLerp("home")
await get_tree().create_timer(.4, false).timeout
#why can I not add functions with arguments into godot animator :sob:
var overriding_medicine_adding = false
var overriding_medicine = false
func UpdateDisplayRoutineCigarette_Enemy():
var maxHealth = roundManager.roundArray[0].startingHealth
var changingHealth = false
var prevhealth = roundManager.health_opponent
if (!roundManager.wireIsCut_dealer && !overriding_medicine): roundManager.health_opponent += 1
if (overriding_medicine && !roundManager.wireIsCut_dealer):
if(overriding_medicine_adding): roundManager.health_opponent += 2
else:
roundManager.health_opponent -= 1
if (roundManager.health_opponent > maxHealth): roundManager.health_opponent = maxHealth
var newhealth = roundManager.health_opponent
if (newhealth != prevhealth): changingHealth = true
UpdateDisplayRoutineCigarette_Main(changingHealth, true)
pass
func UpdateDisplayRoutineCigarette_Player():
var maxHealth = roundManager.roundArray[0].startingHealth
var changingHealth = false
var prevhealth = roundManager.health_player
if (!roundManager.wireIsCut_player && !overriding_medicine): roundManager.health_player += 1
if (overriding_medicine && !roundManager.wireIsCut_player):
if(overriding_medicine_adding): roundManager.health_player += 2
if (roundManager.health_player > maxHealth): roundManager.health_player = maxHealth
var newhealth = roundManager.health_player
if (newhealth != prevhealth): changingHealth = true
if (overriding_medicine && !overriding_medicine_adding): changingHealth = true
UpdateDisplayRoutineCigarette_Main(changingHealth, false)
pass
func UpdateDisplayRoutineCigarette_Main(isChanging : bool, isAddingEnemy : bool):
var prevsocket = camera.activeSocket
var playingsound = true
camera.BeginLerp("health counter")
await get_tree().create_timer(.8, false).timeout
if (isAddingEnemy && defibCutter.displayBroken_dealer):
defibCutter.BlipError("dealer")
playingsound = false
if (!isAddingEnemy && defibCutter.displayBroken_player):
defibCutter.BlipError("player")
playingsound = false
UpdateDisplay()
if (!overriding_medicine):
if (isChanging && playingsound): speaker_beep.play()
else:
if (isChanging && overriding_medicine_adding): speaker_beep.play()
else: if(isChanging && !overriding_medicine_adding): speaker_noise.play()
await get_tree().create_timer(.7, false).timeout
if (!isAddingEnemy):
camera.BeginLerp("home")
animator_playerHands.play("player revert cigarette")
else:
camera.BeginLerp("enemy")
animator_dealerHands.play("RESET")
overriding_medicine = false
func SwapSkullSymbols():
for sym in skullSymbols:
sym.set_layer_mask_value(1, true)
sym.get_parent().set_layer_mask_value(1, false)
#orig .13
var settingUpBroken = false
func Bootup():
speaker_bootup.play()
#uiparent.visible = true
ClearDisplay()
for i in range(uiArray.size()):
uiArray[i].visible = true
await get_tree().create_timer(.85, false).timeout
if (roundManager.playerData.currentBatchIndex == 2 && !settingUpBroken && !roundManager.endless):
speaker_beep.pitch_scale = .09
SwapSkullSymbols()
settingUpBroken = true
speaker_beep.play()
UpdateDisplay()
pass
func ClearDisplay():
for i in range(symbolArray_player.size()):
symbolArray_player[i].visible = false
for i in range(symbolArray_enemy.size()):
symbolArray_enemy[i].visible = false
func DisableCounter():
for i in range(uiArray.size()):
uiArray[i].visible = false
#uiparent.visible = false