-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.gd
More file actions
114 lines (101 loc) · 3.64 KB
/
Copy pathGame.gd
File metadata and controls
114 lines (101 loc) · 3.64 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
extends Control
export(bool) var skip_with_s = false
onready var arrow = load('res://Assets/Cursor/arrow.png')
onready var pointing_hand = load('res://Assets/Cursor/pointing_hand.png')
onready var turn_left = load('res://Assets/Cursor/turn_left.png')
onready var turn_right = load('res://Assets/Cursor/turn_right.png')
onready var pc_arrow = load('res://Assets/Cursor/pc_arrow.png')
onready var pc_pointing_hand = load('res://Assets/Cursor/pc_pointing_hand.png')
onready var ActionRouter = get_node("/root/ActionRouter")
onready var VariableBoard = get_node("/root/VariableBoard")
var click_pressed = false
func _ready():
# Setup actions
ActionRouter.register_actions(self)
VariableBoard.register("language", "text_en")
VariableBoard.suscribe('language', $DialogueManager, 'set_language')
VariableBoard.register("random", randi())
VariableBoard.register("remember_times", 0)
VariableBoard.register("memories_replaced", 0)
VariableBoard.register("wordsearch_level", "laundry")
# Setup the mouse cursor for the game
Input.set_custom_mouse_cursor(arrow, Input.CURSOR_ARROW)
Input.set_custom_mouse_cursor(
pointing_hand,
Input.CURSOR_POINTING_HAND,
Vector2(6.0, 0.0)
)
Input.set_custom_mouse_cursor(pc_arrow, Input.CURSOR_CROSS)
Input.set_custom_mouse_cursor(
pc_pointing_hand,
Input.CURSOR_DRAG,
Vector2(7.0, 0.0)
)
Input.set_custom_mouse_cursor(turn_left, Input.CURSOR_BDIAGSIZE)
Input.set_custom_mouse_cursor(turn_right, Input.CURSOR_FDIAGSIZE)
# Setup signal listeners
$Memory/Memory1.connect("item_selected", $DialogueManager, "_on_item_selected")
$Memory/Memory2.connect("item_selected", $DialogueManager, "_on_item_selected")
# setup signal for intro
$IntroScene/Start.connect("button_down", self, "start_game")
$IntroScene/Language.connect("button_down", self, "change_language")
$ActManager.connect("finish_act", self, "hide_wordsearch")
func start_game():
$IntroScene/AnimationPlayer.play("close")
yield($IntroScene/AnimationPlayer, "animation_finished")
$IntroScene.hide()
$IntroScene/Music/MX_Menu.stop()
$ActManager.load_act()
func change_language():
var current = VariableBoard.get_value('language')
if current == 'text_en':
current = 'text_es'
$IntroScene/Language.text = '< ESPAÑOL >'
$IntroScene/Start.text = 'INICIAR'
elif current == 'text_es':
current = 'text_en'
$IntroScene/Language.text = '< ENGLISH >'
$IntroScene/Start.text = 'START'
VariableBoard.set_value('language', current)
func _process(delta):
if skip_with_s and not $IntroScene.is_visible() \
and not click_pressed and Input.is_key_pressed(KEY_S):
click_pressed = true
ActionRouter.request({
"action": "Dialogue/next"
})
yield(get_tree().create_timer(0.1), "timeout")
click_pressed = false
func handle(request):
match request.action:
"Game/ToBlack":
$Overlay.show()
$AnimationPlayer.play("FadeIn")
yield($AnimationPlayer, "animation_finished")
"Game/ToNormal":
$AnimationPlayer.play("FadeOut")
yield($AnimationPlayer, "animation_finished")
$Overlay.hide()
"Game/Inyection":
$Overlay.show()
$AnimationPlayer.play("Inyection")
yield($AnimationPlayer, "animation_finished")
$Overlay.hide()
"Game/Wait":
yield(get_tree().create_timer(request.wait), "timeout")
"Game/Random":
randomize()
var new_random = randi() % 100 + 1
print("new_random >> ", new_random)
VariableBoard.set_value("random", new_random)
"Game/Wordsearch/visible":
$SopaLetras.visible = bool(request.visible)
$SopaLetras/SFX_Sopa_OC.playsound()
"Game/Wordsearch/load":
$SopaLetras.load_level(request.level)
_:
return false
#warning-ignore:unreachable_code
return true
func hide_wordsearch():
$SopaLetras.visible = false