-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.gd
61 lines (41 loc) · 1.67 KB
/
game.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
extends Node
signal paused
signal started
signal quit
var active := false
@onready var AUDIO_BUS_MASTER = AudioServer.get_bus_index("Master")
@onready var AUDIO_BUS_MUSIC = AudioServer.get_bus_index("Music")
@onready var AUDIO_BUS_SFX = AudioServer.get_bus_index("SFX")
func _ready():
Settings.audio_setup_updated.connect(_on_audio_setup_upd)
Settings.video_setup_updated.connect(_on_video_setup_upd)
func _on_audio_setup_upd():
AudioServer.set_bus_volume_db(AUDIO_BUS_MASTER, linear_to_db(Settings.audio.master_vol))
AudioServer.set_bus_mute(AUDIO_BUS_MASTER, !Settings.audio.master_enabled)
AudioServer.set_bus_volume_db(AUDIO_BUS_SFX, linear_to_db(Settings.audio.sfx_vol))
AudioServer.set_bus_mute(AUDIO_BUS_SFX, !Settings.audio.sfx_enabled)
AudioServer.set_bus_volume_db(AUDIO_BUS_MUSIC, linear_to_db(Settings.audio.music_vol))
AudioServer.set_bus_mute(AUDIO_BUS_MUSIC, !Settings.audio.music_enabled)
func _on_video_setup_upd():
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN if Settings.video.full_screen else DisplayServer.WINDOW_MODE_MAXIMIZED)
func pause():
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
get_tree().paused = true
paused.emit()
func start():
get_tree().paused = false
started.emit()
func quitgame():
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
get_tree().paused = true
quit.emit()
func enemy_down(_type: Alien.Type, _by_player: bool):
pass # TODO: Scores
func defence_down(_type: Defence.Type, _by_player: bool):
pass # TODO: Scores
func building_down(_by_player: bool):
pass # TODO: Scores
func loose():
get_tree().create_timer(1).timeout.connect(quitgame)
func win():
get_tree().create_timer(2).timeout.connect(quitgame)