add particules when winning

This commit is contained in:
Fabien Freling 2020-01-12 18:51:07 +01:00
parent efb9a4e9d9
commit d2c1aa044f
5 changed files with 51 additions and 7 deletions

View file

@ -1,6 +1,6 @@
tool
extends Control
class_name Taquin
tool
var Piece = preload("res://src/Piece.tscn")
@ -39,6 +39,7 @@ func compute_padding(piece_size: int) -> Vector2:
func _ready() -> void:
$AnimationPlayer/MockPiece.visible = false
$Particles2D.emitting = false
$Background.rect_size.x = width
$Background.rect_size.y = height
@ -148,8 +149,8 @@ func move_piece(direction) -> bool:
update()
if check_solved():
var game_state = get_node("/root/Main/GameState") as GameState
game_state.transition_to(GameState.State.WINNING)
emit_signal("solved")
if game_state != null:
game_state.transition_to(GameState.State.WINNING)
return true
@ -171,4 +172,9 @@ func check_solved() -> bool:
for r in range(rows):
if pieces[c][r].number != 1 + c + r * columns:
return false
return true
return true
func _on_GameState_state_changed(previous, current):
match current:
GameState.State.WINNING:
$Particles2D.emitting = true