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:
|
||||
game_difficulty = "easy"
|
||||
game_version = version
|
||||
print("minigame: " + mode + " " + next_lose + " " + next_win)
|
||||
print("setup minigame: " + mode + " " + next_lose + " " + next_win)
|
||||
set_mode(mode)
|
||||
scoreUI.init(mode, game_goal)
|
||||
next_timeline_lose = next_lose
|
||||
|
@ -76,12 +76,14 @@ func stop():
|
|||
foreground.stop()
|
||||
player.stop()
|
||||
spawner.stop()
|
||||
|
||||
scoreUI.stop()
|
||||
|
||||
|
||||
func on_win():
|
||||
stop()
|
||||
emit_signal("game_over", next_timeline_win)
|
||||
|
||||
|
||||
func on_game_over():
|
||||
stop()
|
||||
emit_signal("game_over", next_timeline_lose)
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
extends Control
|
||||
|
||||
onready var label : Label = $MarginContainer/Label
|
||||
onready var timer = $Timer
|
||||
|
||||
var game_mode
|
||||
var max_time = 30
|
||||
var current_time = 0
|
||||
|
||||
func _ready():
|
||||
Signals.connect("update_score",self,"update_score")
|
||||
|
||||
|
||||
|
||||
|
||||
func update_score(score: int):
|
||||
label.text = String(score)
|
||||
|
||||
|
||||
func start(mode: String):
|
||||
|
||||
match mode:
|
||||
"score":
|
||||
update_score(0)
|
||||
|
@ -22,15 +23,8 @@ func start(mode: String):
|
|||
"time":
|
||||
update_score(max_time)
|
||||
show()
|
||||
var t = Timer.new()
|
||||
t.set_wait_time(1)
|
||||
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")
|
||||
current_time = 0
|
||||
timer.start()
|
||||
_:
|
||||
print("game_mode not recognized by scoreUI")
|
||||
|
||||
|
@ -44,3 +38,18 @@ func init(mode, goal: int):
|
|||
max_time = goal
|
||||
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__ = {
|
||||
"_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]
|
||||
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 ) ],
|
||||
"loop": true,
|
||||
"name": "jump",
|
||||
"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 ) ],
|
||||
"loop": true,
|
||||
"name": "man_run",
|
||||
|
@ -73,5 +73,6 @@ shape = SubResource( 2 )
|
|||
position = Vector2( -0.0400658, 9.23466 )
|
||||
scale = Vector2( 0.609429, 0.281311 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
||||
[connection signal="body_exited" from="Area2D" to="." method="_on_Area2D_body_exited"]
|
||||
|
|
|
@ -4,15 +4,14 @@ extends "scroll_movement.gd"
|
|||
onready var notifier = $notifier
|
||||
|
||||
func _ready():
|
||||
get_node("notifier").connect("screen_exited", self, "_on_screen_exited")
|
||||
notifier.connect("screen_exited", self, "_on_screen_exited")
|
||||
|
||||
func _on_screen_exited():
|
||||
print("Bonus exited the screen")
|
||||
queue_free()
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
move()
|
||||
|
||||
|
||||
|
||||
func _on_pick_bonus_body_entered(body):
|
||||
|
|
|
@ -74,20 +74,19 @@ func increase_score(scoretoadd):
|
|||
match game_mode:
|
||||
"score":
|
||||
score+=scoretoadd
|
||||
Signals.emit_signal("update_score",score)
|
||||
Signals.emit_signal("update_score", score)
|
||||
if score >= score_goal:
|
||||
Signals.emit_signal("win")
|
||||
"time":
|
||||
pass
|
||||
_:
|
||||
print("game_mode not recognized by player2 start func")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func player_win():
|
||||
stop()
|
||||
|
||||
|
||||
func player_die():
|
||||
stop()
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ var timer_speed = 0.99
|
|||
var random_threshold = 50
|
||||
var scenes_offset = 0
|
||||
|
||||
onready var timer := $Timer
|
||||
onready var items := $items
|
||||
|
||||
func _ready():
|
||||
Signals.connect("die",self,"game_over")
|
||||
Signals.connect("win",self,"game_over")
|
||||
|
@ -25,17 +28,17 @@ func _on_Timer_timeout():
|
|||
else:
|
||||
scene_index = 0
|
||||
var tmp = scenes[scene_index+scenes_offset*2].instance()
|
||||
$items.add_child(tmp)
|
||||
items.add_child(tmp)
|
||||
last_object = tmp
|
||||
if(self.get_node("Timer").wait_time <= 1):
|
||||
self.get_node("Timer").wait_time = 1
|
||||
if(timer.wait_time <= 1):
|
||||
timer.wait_time = 1
|
||||
else:
|
||||
self.get_node("Timer").wait_time *= timer_speed
|
||||
self.get_node("Timer").start()
|
||||
timer.wait_time *= timer_speed
|
||||
timer.start()
|
||||
|
||||
|
||||
func game_over():
|
||||
self.get_node("Timer").set_paused(true)
|
||||
timer.set_paused(true)
|
||||
#last_object.queue_free()
|
||||
|
||||
|
||||
|
@ -51,7 +54,7 @@ func start(difficulty, version):
|
|||
pass
|
||||
scenes_offset = version
|
||||
spawner_enabled = true
|
||||
self.get_node("Timer").set_paused(false)
|
||||
timer.set_paused(false)
|
||||
|
||||
|
||||
func stop():
|
||||
|
|
|
@ -10,8 +10,8 @@ var USER_MUSIC = "res://music/utilisateur.ogg"
|
|||
|
||||
func _ready():
|
||||
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")
|
||||
add_child_below_node(mini_game, dialogic_node)
|
||||
play_music()
|
||||
|
||||
|
||||
|
@ -57,6 +57,7 @@ func start_minigame():
|
|||
|
||||
|
||||
func _on_MiniGame_game_over(next_timeline: String):
|
||||
print("game over received: " + next_timeline)
|
||||
dialogic_node = Dialogic.start(next_timeline, false)
|
||||
dialogic_node.connect('dialogic_signal', self, "_on_Dialogic_signal_received")
|
||||
add_child_below_node(mini_game, dialogic_node)
|
||||
|
|
Loading…
Reference in a new issue