2021-09-08 08:27:14 +00:00
|
|
|
extends KinematicBody2D
|
|
|
|
|
2021-10-01 14:23:48 +00:00
|
|
|
signal level_just_won
|
2021-09-08 08:27:14 +00:00
|
|
|
enum {IDLE, MOVEUP, MOVEDOWN}
|
|
|
|
var state = IDLE
|
|
|
|
|
|
|
|
func _on_Killzone_body_entered(body):
|
|
|
|
if body.has_method("reset_ball"):
|
|
|
|
body.reset_ball()
|
|
|
|
state = MOVEUP
|
|
|
|
GameStats.add_balls(-1)
|
2021-10-01 14:23:48 +00:00
|
|
|
|
2021-09-08 08:27:14 +00:00
|
|
|
if body.has_method("explode"):
|
|
|
|
if (body.has_method("set_particle_direction")):
|
|
|
|
body.set_particle_direction(Vector2(0, -10))
|
|
|
|
body.explode()
|
|
|
|
|
|
|
|
func _physics_process(_delta):
|
|
|
|
match state:
|
|
|
|
IDLE: pass
|
|
|
|
MOVEUP: moveup()
|
|
|
|
MOVEDOWN: movedown()
|
|
|
|
|
|
|
|
func moveup():
|
|
|
|
var _collide = move_and_collide(Vector2(0, -5))
|
|
|
|
|
|
|
|
func movedown():
|
|
|
|
var _collide = move_and_collide(Vector2(0, 5))
|
2021-10-09 17:24:55 +00:00
|
|
|
GameStats.set_multiplier(1)
|
2021-09-08 08:27:14 +00:00
|
|
|
|
|
|
|
func _on_ZoneDetection_area_entered(_area):
|
|
|
|
if (state == MOVEUP):
|
|
|
|
state = MOVEDOWN
|
2021-10-01 14:23:48 +00:00
|
|
|
if GameStats.level_won:
|
|
|
|
emit_signal("level_just_won")
|
2021-09-08 08:27:14 +00:00
|
|
|
else: state = IDLE
|