blob: 6850b35ae914d5e00760cba97c0d9faf2db40273 (
plain)
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
|
extends Node
var game_stats_config = preload("res://resources/game_stats_config.tres")
var morale_down = preload("res://assets/morale_down.wav")
signal life_changed
signal morale_changed
var _life : int
var _morale : int
var _current_wave : int
func reset():
_life = game_stats_config.starting_life
_morale = game_stats_config.starting_morale
_current_wave = 1
func get_life() -> int:
return _life
func add_life(amount: int):
_life += amount
emit_signal("life_changed")
func subtract_life(amount: int):
_life -= amount
emit_signal("life_changed")
func get_morale() -> int:
return _morale
func add_morale(amount: int):
_morale += amount
emit_signal("morale_changed")
func subtract_morale(amount: int):
_morale -= amount
emit_signal("morale_changed")
if (_morale < 1):
get_tree().change_scene_to_file("res://scenes/game_over.tscn")
else:
var ap = get_tree().current_scene.get_node("Blips")
ap.stream = morale_down
ap.play()
func get_current_wave() -> int:
return _current_wave
func increment_wave():
_current_wave += 1
|