-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_lib.gd
More file actions
162 lines (142 loc) · 4.04 KB
/
Copy pathcode_lib.gd
File metadata and controls
162 lines (142 loc) · 4.04 KB
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
extends Node
var LMB_is_pressed: bool = false
var card_in_dropzone: bool = false
var is_card_pickup_enabled: bool = true
var card_uid_counter: int = 0
enum CardTypes {
BEGIN_BOOSTER,
HUGNER,
HYGIENE,
SPIRITUALLITY,
FUN,
SLEEP,
THIRST,
SPORT,
WEATLH,
END_BOOSTER,
BEGIN_DEMONS,
DEMON_CAT,
DEMON_SNAKE,
END_DEMONS,
BEGIN_SPECIAL,
MAIDEN,
ANGEL,
DEVIL,
END_SPECIAL,
}
enum SUMMONS {
CAT,
CAT_ANGEL,
CAT_HUMAN,
CAT_DEVIL,
DEVIL,
SNAKE,
SNAKE_ANGEL,
MEDUSA,
}
const CardTypesToSUMMONS = {
CardTypes.DEMON_CAT: SUMMONS.CAT,
CardTypes.DEMON_SNAKE: SUMMONS.SNAKE,
}
const CARD_FILES = {
CardTypes.DEMON_CAT: "res://images/cat_demon_1.png",
CardTypes.DEMON_SNAKE: "res://images/snake_demon_1.png",
CardTypes.DEVIL: "res://images/devil_1.png",
CardTypes.ANGEL: "res://images/angel_1.png",
CardTypes.MAIDEN: "res://images/maiden_1.png",
CardTypes.HUGNER: "res://images/mushroom_1.png",
CardTypes.HYGIENE: "res://images/brush_1.png",
CardTypes.SPIRITUALLITY: "res://images/book_1.png",
CardTypes.FUN: "res://images/chess_1.png",
CardTypes.SLEEP: "res://images/sleep.png",
CardTypes.THIRST: "res://images/thirst.png",
CardTypes.SPORT: "res://images/training.png",
CardTypes.WEATLH: "res://images/wealth_1.png",
}
const SUMMON_FILES = {
SUMMONS.CAT: "res://images/cat.png",
SUMMONS.CAT_ANGEL: "res://images/cat_angel.png",
SUMMONS.CAT_HUMAN: "res://images/cat_human.png",
SUMMONS.CAT_DEVIL: "res://images/cat_devil.png",
SUMMONS.DEVIL: "res://images/devil.png",
SUMMONS.SNAKE: "res://images/snake.png",
SUMMONS.SNAKE_ANGEL: "res://images/snake_angel.png",
SUMMONS.MEDUSA: "res://images/medusa.png",
}
const WOBBLE = preload ("res://AkronsusTest/Wobble.tscn")
signal LMB_DOWN(position: Vector2)
signal LMB_UP(position: Vector2)
signal UPDATE_COLLECTION(amount: int)
enum SOUNDS {
BACKGROUND_MUSIC,
DRAW_CARD_1,
DRAW_CARD_2,
SUMMON,
SUMMON_FAIL
}
const SOUND_FILES = {
SOUNDS.BACKGROUND_MUSIC: "res://sound/background_music.ogg",
SOUNDS.DRAW_CARD_1: "res://sound/draw_card_1.ogg",
SOUNDS.DRAW_CARD_2: "res://sound/draw_card_2.ogg",
SOUNDS.SUMMON: "res://sound/summon.ogg",
SOUNDS.SUMMON_FAIL: "res://sound/summon_fail.ogg"
}
var sound_player: AudioStreamPlayer = AudioStreamPlayer.new()
var collection_of_demons = []
var available_cards_to_spawn = [
CardTypes.HUGNER,
CardTypes.HYGIENE,
CardTypes.SPIRITUALLITY,
CardTypes.FUN,
CardTypes.SLEEP,
CardTypes.THIRST,
CardTypes.SPORT,
CardTypes.DEMON_SNAKE,
CardTypes.ANGEL,
CardTypes.DEVIL,
# Cards the player starts with
# CardTypes.WEATLH,
# CardTypes.DEMON_CAT,
# CardTypes.MAIDEN,
]
func add_demon_to_collection(new_demon):
debug_print("collection: %s" % [collection_of_demons])
# check if demon is already known
for known_demon in collection_of_demons:
if new_demon == known_demon:
debug_print("Demon already known")
return
# otherwise add to collection
collection_of_demons.append(new_demon)
debug_print("New demon collected, collection %s of ???" % [collection_of_demons.size()])
UPDATE_COLLECTION.emit(collection_of_demons.size())
func _input(event):
# Left mouse button
if event is InputEventMouseButton:
if event.get_button_index() == MOUSE_BUTTON_LEFT:
if event.is_pressed():
# debug_print("LMB clicked at %s" % [event.position])
LMB_is_pressed = true
LMB_DOWN.emit(event.position)
else:
# debug_print("LMB released at %s" % [event.position])
LMB_is_pressed = false
LMB_UP.emit(event.position)
func debug_print(message):
if OS.is_debug_build():
print(message)
func play_audio(sound: SOUNDS):
if sound == SOUNDS.DRAW_CARD_1 or sound == SOUNDS.DRAW_CARD_2:
var sound_options = [SOUND_FILES[SOUNDS.DRAW_CARD_1],SOUND_FILES[SOUNDS.DRAW_CARD_2]]
sound_player.stream = load(sound_options.pick_random())
sound_player.play()
else:
sound_player.stream = load(SOUND_FILES[sound])
sound_player.play()
# Called when the node enters the scene tree for the first time.
func _ready():
add_child(sound_player)
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass