-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShellSpawner.gd
170 lines (142 loc) · 5.54 KB
/
ShellSpawner.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
class_name ShellSpawner extends Node
@export var dialogue : Dialogue
@export var anim_compartment : AnimationPlayer
@export var roundManager : RoundManager
@export var camera : CameraManager
@export var shellInstance : PackedScene
@export var shellLocationArray : Array[Vector3]
@export var spawnParent : Node3D
@export var healthCounter : HealthCounter
@export var soundArray_latchOpen : Array[AudioStream]
@export var speaker_latchOpen : AudioStreamPlayer2D
@export var speaker_audioIndicator : AudioStreamPlayer2D
@export var soundArray_indicators : Array[AudioStream]
@export var ai : DealerIntelligence
var spawnedShell
var locationIndex
var tempSequence : Array[String]
var sequenceArray : Array[String]
var shellBranch : ShellClass
var spawnedShellObjectArray = []
func _ready():
pass
func _process(delta):
pass
var skipDialoguePresented = false
func MainShellRoutine():
if (roundManager.playerData.currentBatchIndex != 0):
roundManager.shellLoadingSpedUp = true
#CLEAR PREVIOUS SHELL SEQUENCE ARRAY
sequenceArray = []
#CHECK IF CONSOLE TEXT EXISTS. SHOW CONSOLE TEXT
#INITIAL CAMERA SOCKET. HEALTH COUNTER FUNCTIONALITY
if (roundManager.roundArray[roundManager.currentRound].bootingUpCounter):
camera.BeginLerp("health counter")
await get_tree().create_timer(.5, false).timeout
healthCounter.Bootup()
await get_tree().create_timer(1.4, false).timeout
#await get_tree().create_timer(2, false).timeout #NEW
camera.BeginLerp("shell compartment")
await get_tree().create_timer(.5, false).timeout
#SHELL SPAWNING
var temp_nr = roundManager.roundArray[roundManager.currentRound].amountBlank + roundManager.roundArray[roundManager.currentRound].amountLive
var temp_live = roundManager.roundArray[roundManager.currentRound].amountLive
var temp_blank = roundManager.roundArray[roundManager.currentRound].amountBlank
var temp_shuf = roundManager.roundArray[roundManager.currentRound].shufflingArray
SpawnShells(temp_nr, temp_live, temp_blank, temp_shuf)
seq = sequenceArray
anim_compartment.play("show shells")
PlayLatchSound()
PlayAudioIndicators()
await get_tree().create_timer(1, false).timeout
roundManager.ignoring = false
#DIALOGUE
var text_lives
var text_blanks
if (temp_live == 1): text_lives = tr("LIVEROUND") % str(temp_live)
else: text_lives = tr("LIVEROUNDS") % str(temp_live)
if (temp_blank == 1): text_blanks = tr("BLANKROUND") % str(temp_blank)
else: text_blanks = tr("BLANKROUNDS") % str(temp_blank)
var finalstring : String
#finalstring = str(temp_live) + " " + text_lives + " " + str(temp_blank) + " " + text_blanks
finalstring = text_lives + " " + text_blanks
var maindur = 1.3
if (roundManager.playerData.currentBatchIndex == 2):
roundManager.playerData.skippingShellDescription = true
if (!roundManager.playerData.skippingShellDescription):
if (CheckBackdropScaling()): dialogue.scaling = true
dialogue.ShowText_Forever(finalstring)
if (roundManager.playerData.skippingShellDescription && !skipDialoguePresented):
dialogue.ShowText_Forever(tr("DRILL"))
maindur = 2.5
skipDialoguePresented = true
if(!roundManager.playerData.skippingShellDescription): await get_tree().create_timer(2.5, false).timeout
else: await get_tree().create_timer(maindur, false).timeout
dialogue.HideText()
#HIDE SHELLS
anim_compartment.play("hide shells")
PlayLatchSound()
if(roundManager.shellLoadingSpedUp): await get_tree().create_timer(.2, false).timeout
else: await get_tree().create_timer(.5, false).timeout
#CHECK IF INSERTING INTO CHAMBER IN RANDOM ORDER.
if (roundManager.roundArray[roundManager.currentRound].insertingInRandomOrder):
sequenceArray.shuffle()
sequenceArray.shuffle()
roundManager.LoadShells()
return
pass
func CheckBackdropScaling():
var curloc = TranslationServer.get_locale()
var localesToScale = ["FR", "IT", "DE", "ES", "ES LATAM", "BR", "PT"]
for l in localesToScale:
if (curloc == l):
return true
return false
func SpawnShells(numberOfShells : int, numberOfLives : int, numberOfBlanks : int, shufflingArray : bool):
#DELETE PREVIOUS SHELLS
for i in range(spawnedShellObjectArray.size()):
spawnedShellObjectArray[i].queue_free()
spawnedShellObjectArray = []
#SETUP SHELL ARRAY
sequenceArray = []
tempSequence = []
ai.sequenceArray_knownShell = []
for i in range(numberOfLives):
tempSequence.append("live")
for i in range(numberOfBlanks):
tempSequence.append("blank")
if (shufflingArray):
tempSequence.shuffle()
for i in range(tempSequence.size()):
sequenceArray.append(tempSequence[i])
ai.sequenceArray_knownShell.append(false)
pass
locationIndex = 0
#SPAWN SHELLS
for i in range(numberOfShells):
spawnedShell = shellInstance.instantiate()
shellBranch = spawnedShell.get_child(0)
if (sequenceArray[i] == "live"): shellBranch.isLive = true
else: shellBranch.isLive = false
shellBranch.ApplyStatus()
spawnParent.add_child(spawnedShell)
spawnedShell.transform.origin = shellLocationArray[locationIndex]
spawnedShell.rotation_degrees = Vector3(-90, -90, 180)
spawnedShellObjectArray.append(spawnedShell)
locationIndex += 1
pass
pass
var tog = false
func PlayLatchSound():
tog = !tog
if (tog): speaker_latchOpen.stream = soundArray_latchOpen[0]
else: speaker_latchOpen.stream = soundArray_latchOpen[1]
speaker_latchOpen.play()
var seq = []
func PlayAudioIndicators():
await get_tree().create_timer(.37, false).timeout
for i in range(seq.size()):
if (seq[i] == "blank"): speaker_audioIndicator.stream = soundArray_indicators[0]
else: speaker_audioIndicator.stream = soundArray_indicators[1]
speaker_audioIndicator.play()
await get_tree().create_timer(.07, false).timeout