-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorial.gd
More file actions
190 lines (136 loc) · 4.7 KB
/
Tutorial.gd
File metadata and controls
190 lines (136 loc) · 4.7 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
extends Node
const hints = [
"充電ケーブルを抜いてください。", # 0
"使い方:デバイスを回転させる。", # 1
"使い方:画面上の任意の場所をタッチする。", # 2
"使い方:画面をタッチし、触れたままにする。", # 3
"使い方:音楽をなるまで待てる。", # 4
]
var tween
var anim_playing = false
var current_step = 1
var total_movement = 0.0
var presstime = 0
var touch_count = 0
var touching = false
var touching_time = 3.0
var wait_time = 10.0
var scene_out = false
@onready var Anim = $Anim
@onready var ipad = $TextureRect
func _ready():
SceneHelper.isTutorial = true
func _process(delta):
if current_step == 0:
if !anim_playing:
anim_playing = true
Anim.play("charging_unplug_loop")
show_hint(hints[0])
await get_tree().create_timer(8).timeout
Anim.play("charging_unplug")
await get_tree().create_timer(3).timeout
current_step = 1
anim_playing = false
show_hint(hints[1])
elif current_step == 1:
if !anim_playing:
var g = Input.get_gyroscope() * delta
ipad.rotation += g.z * 180
ipad.scale.x += snapped(g.y, 0.01) * 2
ipad.scale.y += snapped(g.x, 0.01) * 2
if ipad.scale.x > 1:
ipad.scale.x = 1
elif ipad.scale.x < -1:
ipad.scale.x = -1
if ipad.scale.y > 1:
ipad.scale.y = 1
elif ipad.scale.y < -1:
ipad.scale.y = -1
total_movement += g.length_squared()
$progress.scale.x = total_movement / .6
if total_movement >= .6:
anim_playing = true
tween = create_tween()
tween.tween_property(ipad, "scale", Vector2(1, 1), 0.8)
tween.parallel().tween_property(ipad, "rotation", 0.0, 0.8)
tween.parallel().tween_property($progress, "color:a", 0.0, 0.8)
tween.tween_property($touch/a, "modulate:a", 1.0, 0.5)
tween.parallel().tween_property($touch/b, "modulate:a", 1.0, 0.5)
tween.parallel().tween_property($touch/c, "modulate:a", 1.0, 0.5)
await get_tree().create_timer(1.0).timeout
current_step = 2
anim_playing = false
show_hint(hints[2])
elif current_step == 2:
if !anim_playing && touch_count >= 3:
anim_playing = true
tween = create_tween()
tween.tween_property($touch/a, "modulate:a", .0, 0.5).set_delay(.5)
tween.parallel().tween_property($touch/b, "modulate:a", .0, 0.5).set_delay(.65)
tween.parallel().tween_property($touch/c, "modulate:a", .0, 0.5).set_delay(.8)
tween.tween_property($progress, "color:a", 1.0, 0.8).set_delay(1.0)
await get_tree().create_timer(1.0).timeout
$progress.scale.x = 1
current_step = 3
anim_playing = false
show_hint(hints[3])
elif current_step == 3:
if !anim_playing:
touching_time += -delta if touching else delta / 2
touching_time = min(touching_time, 3.0)
$progress.scale.x = touching_time / 3.0
AuH._vol(AuH.BG, 6 - $progress.scale.x * 12)
if touching_time <= 0:
$progress.scale.x = 0
anim_playing = true
tween = create_tween()
tween.set_ease(Tween.EASE_OUT).tween_property($progress, "scale:x", 1.0, 1.0).set_delay(.5)
tween.tween_property($progress, "scale:x", .0, wait_time).set_delay(.5)
AuH.vol_tween(AuH.BG, -6.0, wait_time + 0.5)
TA.hold_end()
await get_tree().create_timer(1.0).timeout
AuH._FX(AuH.TENSEC_FX, .0, .0)
$progress.scale.x = 1
current_step = 4
show_hint(hints[4])
await get_tree().create_timer(wait_time).timeout
start_scene()
func show_hint(text):
Hint.show_hint(text, false)
pass
var touch_pos = Vector2.ZERO
func _input(event):
if event is InputEventMouseButton and event.is_pressed():
# print("Mouse Click at: ", event.position)
touch_pos = event.position
show_hint(hints[current_step])
if current_step == 2:
if Time.get_ticks_msec() - presstime > 500:
presstime = Time.get_ticks_msec()
elif current_step == 3:
touching = true
TA.hold_start(touch_pos)
if event is InputEventMouseButton and !event.is_pressed():
# print("Mouse Unclick at: ", event.position)
if current_step == 2:
if touch_count >= 3:
pass
elif Time.get_ticks_msec() - presstime < 300:
var t = $touch.get_child(touch_count)
AuH.rand_note(randf_range(-20, 0), .0, "Reverb")
TA.touch(touch_pos)
tween = create_tween().set_trans(Tween.TRANS_BACK)
tween.tween_property(t, "scale", Vector2(.05, .05), .5)
touch_count += 1
elif current_step == 3:
touching = false
TA.hold_end()
func start_scene():
SceneHelper.fade_to_black(1.0, 1.0)
await get_tree().create_timer(1.0).timeout
SceneHelper.isTutorial = false
get_tree().change_scene_to_file("res://Scenes/Room.tscn")
func _on_Button_pressed():
if !scene_out:
scene_out = true
start_scene()