Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -49,8 +49,10 @@ func _activate(_world, activator, position):
|
|||||||
else:
|
else:
|
||||||
assert(false, "who are you, activator?")
|
assert(false, "who are you, activator?")
|
||||||
|
|
||||||
func discard(world, activator, do_ability):
|
func discard(_world, activator, do_ability):
|
||||||
ammo = max_ammo
|
ammo = max_ammo
|
||||||
|
if do_ability:
|
||||||
|
activator.dash(_activate);
|
||||||
|
|
||||||
func get_ammo():
|
func get_ammo():
|
||||||
return ammo
|
return ammo
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ var charge_level = 0;
|
|||||||
var charge_rate = 1;
|
var charge_rate = 1;
|
||||||
var charged = false;
|
var charged = false;
|
||||||
|
|
||||||
var dash_cooldown_timer = 0;
|
var dash_cooldown_timer: Timer = Timer.new()
|
||||||
var dash_on_cooldown = false;
|
|
||||||
|
|
||||||
var knockback_timer: Timer = Timer.new()
|
var knockback_timer: Timer = Timer.new()
|
||||||
|
|
||||||
func get_target_pos():
|
func get_target_pos():
|
||||||
@@ -70,36 +68,30 @@ func charge():
|
|||||||
# Gradual charge dropoff
|
# Gradual charge dropoff
|
||||||
charge_level = max(charge_level - charge_rate * 2, 0);
|
charge_level = max(charge_level - charge_rate * 2, 0);
|
||||||
|
|
||||||
func dash():
|
func dash(on_end: Callable):
|
||||||
if dash_on_cooldown:
|
dash_cooldown_timer.start(dash_cooldown);
|
||||||
return;
|
var target_dir = position.direction_to(target)
|
||||||
|
dash_cooldown_timer.timeout.connect(func(): on_end.call(null, self, target_dir), CONNECT_ONE_SHOT);
|
||||||
hand.discard(); # Must set move_state at start and end of dash
|
velocity = move_direction * speed * 5;
|
||||||
dash_on_cooldown = true;
|
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
screen_size = get_viewport_rect().size
|
screen_size = get_viewport_rect().size
|
||||||
knockback_timer.one_shot = true
|
knockback_timer.one_shot = true
|
||||||
|
dash_cooldown_timer.one_shot = true
|
||||||
add_child(knockback_timer);
|
add_child(knockback_timer);
|
||||||
|
add_child(dash_cooldown_timer);
|
||||||
|
|
||||||
func _process(delta):
|
func _process(_delta):
|
||||||
update_target_coords();
|
update_target_coords();
|
||||||
update_camera_position();
|
update_camera_position();
|
||||||
if (move_state != MoveState.Dashing):
|
if (move_state != MoveState.Dashing):
|
||||||
update_move_direction();
|
update_move_direction();
|
||||||
|
|
||||||
if (dash_on_cooldown):
|
|
||||||
dash_cooldown_timer += delta;
|
|
||||||
if (dash_cooldown_timer >= dash_cooldown):
|
|
||||||
dash_on_cooldown = false;
|
|
||||||
dash_cooldown_timer = 0;
|
|
||||||
|
|
||||||
# handle move_state
|
# handle move_state
|
||||||
if knockback_timer.time_left > 0:
|
if knockback_timer.time_left > 0 or dash_cooldown_timer.time_left > 0:
|
||||||
pass
|
pass
|
||||||
elif Input.is_action_just_pressed("dash"):
|
elif Input.is_action_just_pressed("dash"):
|
||||||
dash();
|
hand.discard(); # Must set move_state at start and end of dash
|
||||||
elif (move_state != MoveState.Dashing):
|
elif (move_state != MoveState.Dashing):
|
||||||
velocity = move_direction * speed;
|
velocity = move_direction * speed;
|
||||||
if velocity.x || velocity.y:
|
if velocity.x || velocity.y:
|
||||||
|
|||||||
Reference in New Issue
Block a user