From 83d75e107f8f82bd9a3240a1218542302bd90f1f Mon Sep 17 00:00:00 2001 From: limuy Date: Mon, 8 Jul 2024 17:37:35 +0800 Subject: [PATCH] feat:develop bullets of seedler --- scenes/bullets/seedler/seedler_nut.gd | 34 ++++++++++++++++++++++++++- scenes/weapons/seedler/seedler.gd | 29 +++++++++++------------ 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/scenes/bullets/seedler/seedler_nut.gd b/scenes/bullets/seedler/seedler_nut.gd index c53d214..68fd31a 100644 --- a/scenes/bullets/seedler/seedler_nut.gd +++ b/scenes/bullets/seedler/seedler_nut.gd @@ -58,14 +58,45 @@ func burstShotBeam(): beams[i].is_fall = false beams[i].position = position var rad = TAU / times * i + (TAU / 12 if i % 2 == 0 else -TAU / 12) + beams[i].rotation = rad beams[i].velocity = Vector2(sin(rad), cos(rad)) * 800 for beam in beams: get_parent().add_child(beam) +# 启动超级爆炸 +# 最大, 原地旋转 +func superBurst(pos : Vector2): + const time = 0.8 + const wait_time = 0.65 + # TAU / s + const speed = 1.5 * TAU + position = pos + scale = Vector2(2, 2) + var tween = create_tween() + tween.tween_property(self, "rotation", rotation + speed * time, time) + tween.tween_callback(superBurstShotBeam.bind()) + tween.tween_interval(wait_time) + tween.tween_callback(queue_free) + +func superBurstShotBeam(): + const times = 12 + const num = 6 + for j in range(num): + print("aaa") + var beams: Array[Area2D] = [] + for i in range(times): + beams.push_back(thorns.instantiate()) + beams[i].is_fall = false + beams[i].position = position + var rad = TAU / times * i + (TAU / 12 if i % 2 == 0 else -TAU / 12) + beams[i].velocity = Vector2(sin(rad), cos(rad)) * 800 + for beam in beams: + get_parent().add_child(beam) + await get_tree().create_timer(0.1).timeout func _ready(): $OutScreen.screen_exited.connect(queue_free) - throw() + superBurst(Vector2(300, 300)) func _process(delta): @@ -81,3 +112,4 @@ func _on_area_entered(area): if area.name == "Player": area.get_node("..").hit(10) $CollisionShape2D.set_deferred("disabled", true) + diff --git a/scenes/weapons/seedler/seedler.gd b/scenes/weapons/seedler/seedler.gd index 92c8f4a..44e241d 100644 --- a/scenes/weapons/seedler/seedler.gd +++ b/scenes/weapons/seedler/seedler.gd @@ -1,29 +1,28 @@ extends Sprite2D -const TIMES = 5 @onready var path = $"../Path2D" @onready var follow = $"../Path2D/PathFollow2D" - -func move(length: float) -> void: +func move(length : float) -> void: follow.progress = length position = follow.global_position - - -func _ready() -> void: - if get_tree().current_scene != $"..": - hide() - return + +func start() -> void: rotation = 0 follow.loop = 1 var start = 0 var end = path.curve.get_baked_length() var mid = end / 2 - var movement = create_tween().set_loops(TIMES).set_ease(Tween.EASE_IN).set_trans( - Tween.TRANS_SINE - ) + var movement = create_tween().set_loops(times).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_SINE) movement.tween_method(move, start, mid, 1) movement.tween_method(move, mid, end, 1) - var rotate_animation = create_tween().set_loops(TIMES) - rotate_animation.tween_property(self, "rotation", TAU * 5, 2) - rotate_animation.tween_callback(func(): rotation = 0) + var rotate = create_tween().set_loops(times) + rotate.tween_property(self, "rotation", TAU * 5, 2) + rotate.tween_callback(func():rotation = 0) + +const times = 5 + +func _ready() -> void: + if get_tree().current_scene == self: + start() +