|
@@ -6,6 +6,7 @@ signal get_firing
|
|
|
signal is_full
|
|
|
signal gain_new_bullet
|
|
|
signal interrupt_wave
|
|
|
+signal move_visor
|
|
|
|
|
|
enum State {
|
|
|
READY,
|
|
@@ -22,7 +23,8 @@ var _ballScene = preload("res://scenes/Ball.tscn")
|
|
|
var nbAmmo = 0
|
|
|
var nbStorage = 1
|
|
|
|
|
|
-onready var target = $Target
|
|
|
+onready var target = $TargetLine
|
|
|
+onready var visor = $TargetLine/TargetVisor
|
|
|
onready var source = $Source
|
|
|
onready var shootDelay = $ShootDelay
|
|
|
onready var grid = $Grid
|
|
@@ -42,14 +44,13 @@ func _input(event):
|
|
|
|
|
|
|
|
|
func aim_at(cursor:Vector2):
|
|
|
- target.position = source.position
|
|
|
- target.position += (cursor - source.position) * visor_ratio
|
|
|
+ visor.position = (cursor - source.position) * visor_ratio
|
|
|
+ emit_signal("move_visor")
|
|
|
|
|
|
|
|
|
func trigger(aim:Vector2):
|
|
|
if (current_state == State.READY):
|
|
|
current_state = State.FIRING
|
|
|
- target.position = aim
|
|
|
emit_signal("get_firing")
|
|
|
elif (current_state == State.WAITING):
|
|
|
current_state = State.INTERRUPTING
|
|
@@ -59,7 +60,7 @@ func trigger(aim:Vector2):
|
|
|
func shoot():
|
|
|
var bullet = _ballScene.instance()
|
|
|
bullet.position = source.position
|
|
|
- bullet.linear_velocity = (target.position - source.position).normalized()
|
|
|
+ bullet.linear_velocity = (target.get_visor_pos() - source.position).normalized()
|
|
|
bullet.linear_velocity *= BULLET_SPEED
|
|
|
add_child(bullet)
|
|
|
bullet.connect("tree_exited", self, "_on_Ball_tree_exited")
|
|
@@ -83,7 +84,7 @@ func end_of_round():
|
|
|
|
|
|
func get_ready():
|
|
|
current_state = State.READY
|
|
|
- target.position = source.position
|
|
|
+ visor.position = source.position
|
|
|
nbAmmo = nbStorage
|
|
|
nbStorage = 0
|
|
|
|