-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnvironmentManager.gd
39 lines (32 loc) · 1.06 KB
/
EnvironmentManager.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
extends Node2D
export var raining = true
func _ready():
Game.connect("setTimeOfDay", self, "switchLight")
Game.connect("goInside",self,"processGoInside")
Game.connect("goOutside",self,"processGoOutside")
switchLight(Game.timeOfDay)
func switchLight(timeOfDay):
for child in get_children():
if child is Light2D:
child.enabled = false
get_child(timeOfDay).enabled = true
func processGoOutside():
$Rain/RainSpecks.visible = true if raining else false
call_deferred("toggleRainAudio", raining)
func processGoInside():
$Rain/RainSpecks.visible = false
call_deferred("toggleRainAudio", raining)
func toggleRainAudio(enable):
var audioNode = $Rain/RainInsideAudio if Game.player.body.parent.bodyHouse != "" else $Rain/RainOutsideAudio
var otherAudioNode = $Rain/RainInsideAudio if Game.player.body.parent.bodyHouse == "" else $Rain/RainOutsideAudio
print(Game.player.body.parent.bodyHouse)
otherAudioNode.stop()
if enable: audioNode.play(5)
else: audioNode.stop()
#WEATHER
# snow
# rain
# storm / lightning
# wind
# birds and crickets
# mosquitos and bugs