fix minigame reset
This commit is contained in:
parent
fbf5a2ceee
commit
9059eddb1e
8 changed files with 52 additions and 34 deletions
|
@ -32,7 +32,7 @@ func setup(mode: String, goal: int, difficulty: String, next_lose: String, next_
|
||||||
else:
|
else:
|
||||||
game_difficulty = "easy"
|
game_difficulty = "easy"
|
||||||
game_version = version
|
game_version = version
|
||||||
print("minigame: " + mode + " " + next_lose + " " + next_win)
|
print("setup minigame: " + mode + " " + next_lose + " " + next_win)
|
||||||
set_mode(mode)
|
set_mode(mode)
|
||||||
scoreUI.init(mode, game_goal)
|
scoreUI.init(mode, game_goal)
|
||||||
next_timeline_lose = next_lose
|
next_timeline_lose = next_lose
|
||||||
|
@ -76,12 +76,14 @@ func stop():
|
||||||
foreground.stop()
|
foreground.stop()
|
||||||
player.stop()
|
player.stop()
|
||||||
spawner.stop()
|
spawner.stop()
|
||||||
|
scoreUI.stop()
|
||||||
|
|
||||||
|
|
||||||
func on_win():
|
func on_win():
|
||||||
stop()
|
stop()
|
||||||
emit_signal("game_over", next_timeline_win)
|
emit_signal("game_over", next_timeline_win)
|
||||||
|
|
||||||
|
|
||||||
func on_game_over():
|
func on_game_over():
|
||||||
stop()
|
stop()
|
||||||
emit_signal("game_over", next_timeline_lose)
|
emit_signal("game_over", next_timeline_lose)
|
||||||
|
|
|
@ -1,20 +1,21 @@
|
||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
onready var label : Label = $MarginContainer/Label
|
onready var label : Label = $MarginContainer/Label
|
||||||
|
onready var timer = $Timer
|
||||||
|
|
||||||
var game_mode
|
var game_mode
|
||||||
var max_time = 30
|
var max_time = 30
|
||||||
|
var current_time = 0
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
Signals.connect("update_score",self,"update_score")
|
Signals.connect("update_score",self,"update_score")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func update_score(score: int):
|
func update_score(score: int):
|
||||||
label.text = String(score)
|
label.text = String(score)
|
||||||
|
|
||||||
|
|
||||||
func start(mode: String):
|
func start(mode: String):
|
||||||
|
|
||||||
match mode:
|
match mode:
|
||||||
"score":
|
"score":
|
||||||
update_score(0)
|
update_score(0)
|
||||||
|
@ -22,15 +23,8 @@ func start(mode: String):
|
||||||
"time":
|
"time":
|
||||||
update_score(max_time)
|
update_score(max_time)
|
||||||
show()
|
show()
|
||||||
var t = Timer.new()
|
current_time = 0
|
||||||
t.set_wait_time(1)
|
timer.start()
|
||||||
add_child(t)
|
|
||||||
t.start()
|
|
||||||
for n in range(max_time,0,-1):
|
|
||||||
update_score(n)
|
|
||||||
yield(t,"timeout")
|
|
||||||
update_score(0)
|
|
||||||
Signals.emit_signal("win")
|
|
||||||
_:
|
_:
|
||||||
print("game_mode not recognized by scoreUI")
|
print("game_mode not recognized by scoreUI")
|
||||||
|
|
||||||
|
@ -44,3 +38,18 @@ func init(mode, goal: int):
|
||||||
max_time = goal
|
max_time = goal
|
||||||
hide()
|
hide()
|
||||||
|
|
||||||
|
|
||||||
|
func stop():
|
||||||
|
timer.stop()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Timer_timeout() -> void:
|
||||||
|
current_time += 1
|
||||||
|
var n = max_time - current_time
|
||||||
|
if n < 0:
|
||||||
|
n = 0
|
||||||
|
update_score(n)
|
||||||
|
if n == 0:
|
||||||
|
Signals.emit_signal("win")
|
||||||
|
timer.stop()
|
||||||
|
|
||||||
|
|
|
@ -39,3 +39,7 @@ align = 1
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="."]
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||||
|
|
|
@ -24,16 +24,16 @@
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id=1]
|
[sub_resource type="SpriteFrames" id=1]
|
||||||
animations = [ {
|
animations = [ {
|
||||||
"frames": [ ExtResource( 7 ), ExtResource( 10 ), ExtResource( 9 ), ExtResource( 4 ), ExtResource( 8 ), ExtResource( 2 ), ExtResource( 3 ), ExtResource( 1 ) ],
|
|
||||||
"loop": true,
|
|
||||||
"name": "run",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [ ExtResource( 12 ), ExtResource( 11 ), ExtResource( 5 ) ],
|
"frames": [ ExtResource( 12 ), ExtResource( 11 ), ExtResource( 5 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "jump",
|
"name": "jump",
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
}, {
|
}, {
|
||||||
|
"frames": [ ExtResource( 7 ), ExtResource( 10 ), ExtResource( 9 ), ExtResource( 4 ), ExtResource( 8 ), ExtResource( 2 ), ExtResource( 3 ), ExtResource( 1 ) ],
|
||||||
|
"loop": true,
|
||||||
|
"name": "run",
|
||||||
|
"speed": 5.0
|
||||||
|
}, {
|
||||||
"frames": [ ExtResource( 18 ), ExtResource( 15 ), ExtResource( 14 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 21 ), ExtResource( 13 ), ExtResource( 17 ) ],
|
"frames": [ ExtResource( 18 ), ExtResource( 15 ), ExtResource( 14 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 21 ), ExtResource( 13 ), ExtResource( 17 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
"name": "man_run",
|
"name": "man_run",
|
||||||
|
@ -73,5 +73,6 @@ shape = SubResource( 2 )
|
||||||
position = Vector2( -0.0400658, 9.23466 )
|
position = Vector2( -0.0400658, 9.23466 )
|
||||||
scale = Vector2( 0.609429, 0.281311 )
|
scale = Vector2( 0.609429, 0.281311 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
||||||
[connection signal="body_exited" from="Area2D" to="." method="_on_Area2D_body_exited"]
|
[connection signal="body_exited" from="Area2D" to="." method="_on_Area2D_body_exited"]
|
||||||
|
|
|
@ -4,15 +4,14 @@ extends "scroll_movement.gd"
|
||||||
onready var notifier = $notifier
|
onready var notifier = $notifier
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
get_node("notifier").connect("screen_exited", self, "_on_screen_exited")
|
notifier.connect("screen_exited", self, "_on_screen_exited")
|
||||||
|
|
||||||
func _on_screen_exited():
|
func _on_screen_exited():
|
||||||
print("Bonus exited the screen")
|
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
move()
|
move()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_pick_bonus_body_entered(body):
|
func _on_pick_bonus_body_entered(body):
|
||||||
|
|
|
@ -74,20 +74,19 @@ func increase_score(scoretoadd):
|
||||||
match game_mode:
|
match game_mode:
|
||||||
"score":
|
"score":
|
||||||
score+=scoretoadd
|
score+=scoretoadd
|
||||||
Signals.emit_signal("update_score",score)
|
Signals.emit_signal("update_score", score)
|
||||||
if score >= score_goal:
|
if score >= score_goal:
|
||||||
Signals.emit_signal("win")
|
Signals.emit_signal("win")
|
||||||
"time":
|
"time":
|
||||||
pass
|
pass
|
||||||
_:
|
_:
|
||||||
print("game_mode not recognized by player2 start func")
|
print("game_mode not recognized by player2 start func")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func player_win():
|
func player_win():
|
||||||
stop()
|
stop()
|
||||||
|
|
||||||
|
|
||||||
func player_die():
|
func player_die():
|
||||||
stop()
|
stop()
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ var timer_speed = 0.99
|
||||||
var random_threshold = 50
|
var random_threshold = 50
|
||||||
var scenes_offset = 0
|
var scenes_offset = 0
|
||||||
|
|
||||||
|
onready var timer := $Timer
|
||||||
|
onready var items := $items
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
Signals.connect("die",self,"game_over")
|
Signals.connect("die",self,"game_over")
|
||||||
Signals.connect("win",self,"game_over")
|
Signals.connect("win",self,"game_over")
|
||||||
|
@ -25,17 +28,17 @@ func _on_Timer_timeout():
|
||||||
else:
|
else:
|
||||||
scene_index = 0
|
scene_index = 0
|
||||||
var tmp = scenes[scene_index+scenes_offset*2].instance()
|
var tmp = scenes[scene_index+scenes_offset*2].instance()
|
||||||
$items.add_child(tmp)
|
items.add_child(tmp)
|
||||||
last_object = tmp
|
last_object = tmp
|
||||||
if(self.get_node("Timer").wait_time <= 1):
|
if(timer.wait_time <= 1):
|
||||||
self.get_node("Timer").wait_time = 1
|
timer.wait_time = 1
|
||||||
else:
|
else:
|
||||||
self.get_node("Timer").wait_time *= timer_speed
|
timer.wait_time *= timer_speed
|
||||||
self.get_node("Timer").start()
|
timer.start()
|
||||||
|
|
||||||
|
|
||||||
func game_over():
|
func game_over():
|
||||||
self.get_node("Timer").set_paused(true)
|
timer.set_paused(true)
|
||||||
#last_object.queue_free()
|
#last_object.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +54,7 @@ func start(difficulty, version):
|
||||||
pass
|
pass
|
||||||
scenes_offset = version
|
scenes_offset = version
|
||||||
spawner_enabled = true
|
spawner_enabled = true
|
||||||
self.get_node("Timer").set_paused(false)
|
timer.set_paused(false)
|
||||||
|
|
||||||
|
|
||||||
func stop():
|
func stop():
|
||||||
|
|
|
@ -10,8 +10,8 @@ var USER_MUSIC = "res://music/utilisateur.ogg"
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
dialogic_node = Dialogic.start_from_save('00_start')
|
dialogic_node = Dialogic.start_from_save('00_start')
|
||||||
add_child_below_node(mini_game, dialogic_node)
|
|
||||||
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
|
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
|
||||||
|
add_child_below_node(mini_game, dialogic_node)
|
||||||
play_music()
|
play_music()
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ func start_minigame():
|
||||||
|
|
||||||
|
|
||||||
func _on_MiniGame_game_over(next_timeline: String):
|
func _on_MiniGame_game_over(next_timeline: String):
|
||||||
|
print("game over received: " + next_timeline)
|
||||||
dialogic_node = Dialogic.start(next_timeline, false)
|
dialogic_node = Dialogic.start(next_timeline, false)
|
||||||
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
|
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
|
||||||
add_child_below_node(mini_game, dialogic_node)
|
add_child_below_node(mini_game, dialogic_node)
|
||||||
|
|
Loading…
Reference in a new issue