From db8eda2b4bae80c7a3ed407b6bac839ed0744aee Mon Sep 17 00:00:00 2001 From: dpDeadlyPuzzles <1976985776@qq.com> Date: Fri, 12 Jul 2024 13:12:52 +0800 Subject: [PATCH] feat: seedler finish --- scenes/bullets/seedler/seedler_nut.gd | 6 ++-- scenes/weapons/seedler/seedler.gd | 43 ++++++++++++++++++++++----- scenes/weapons/seedler/seedler.tscn | 6 ++-- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/scenes/bullets/seedler/seedler_nut.gd b/scenes/bullets/seedler/seedler_nut.gd index 6b45b25..05c1a8b 100644 --- a/scenes/bullets/seedler/seedler_nut.gd +++ b/scenes/bullets/seedler/seedler_nut.gd @@ -6,7 +6,8 @@ extends Area2D # 启动投掷动作 # 大小最小, 会下落, 撞到地面炸开 # pos: 初始 -func throw(): +func throw(pos: Vector2): + position = pos area_entered.connect(throw_shot_beam) $OutScreen.screen_exited.connect(throw_shot_beam.bind(Area2D.new())) create_tween().tween_property(self, "rotation", rotation + 10.0 * TAU, 5) @@ -132,11 +133,10 @@ func super_burst_shot_beam(): func _ready(): $OutScreen.screen_exited.connect(queue_free) if get_tree().current_scene == self: - super_burst(Vector2(300, 300)) + throw(position) func _on_area_entered(area): - # thornsCreate() # 防止重复伤害 if area.name == "Player": area.get_node("..").hit(10) diff --git a/scenes/weapons/seedler/seedler.gd b/scenes/weapons/seedler/seedler.gd index a09d97e..c2f2c47 100644 --- a/scenes/weapons/seedler/seedler.gd +++ b/scenes/weapons/seedler/seedler.gd @@ -3,6 +3,7 @@ extends Sprite2D const TIMES = 5 @onready var path = $"../Path2D" @onready var follow = $"../Path2D/PathFollow2D" +@export var beam: PackedScene func move(length: float) -> void: @@ -10,24 +11,52 @@ func move(length: float) -> void: position = follow.global_position +func shot_beam(x: int, pos: Vector2): + var new_beam = beam.instantiate() + get_parent().add_child(new_beam) + match x: + 1: + new_beam.throw(pos) + 2: + new_beam.burst(pos) + 3: + new_beam.super_burst(pos) + + func start() -> void: rotation = 0 follow.loop = 1 var start_val = 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 - ) - movement.tween_method(move, start_val, mid, 1) - movement.tween_method(move, mid, end, 1) + var movement = create_tween().set_loops(TIMES) + movement.tween_method(move, start_val, mid, 1.25) + movement.tween_method(move, mid, end, 1.25) + var exit = create_tween() + exit.tween_interval(TIMES * 2.5) + exit.tween_callback(queue_free) var rotate_tween = create_tween().set_loops(TIMES) - rotate_tween.tween_property(self, "rotation", TAU * 5, 2) + rotate_tween.tween_property(self, "rotation", TAU * 5, 2.5) rotate_tween.tween_callback(func(): rotation = 0) + var shot = create_tween().set_loops() + shot.tween_callback(shot_beam.bind(1, Vector2(200, 400))) + shot.tween_callback(shot_beam.bind(1, Vector2(400, 400))) + shot.tween_callback(shot_beam.bind(1, Vector2(600, 400))) + shot.tween_callback(shot_beam.bind(1, Vector2(800, 400))) + shot.tween_callback(shot_beam.bind(1, Vector2(1000, 400))) + shot.tween_interval(2) + shot.tween_callback(shot_beam.bind(2, Vector2(300, 300))) + shot.tween_interval(1) + shot.tween_callback(shot_beam.bind(2, Vector2(700, 500))) + shot.tween_interval(2) + shot.tween_callback(shot_beam.bind(3, Vector2(500, 500))) + shot.tween_interval(2) + shot.tween_callback(shot_beam.bind(3, Vector2(800, 200))) + shot.tween_interval(2) func _ready() -> void: - if get_tree().current_scene == self: + if get_tree().current_scene == get_parent(): show() start() else: diff --git a/scenes/weapons/seedler/seedler.tscn b/scenes/weapons/seedler/seedler.tscn index 9958380..34b63a5 100644 --- a/scenes/weapons/seedler/seedler.tscn +++ b/scenes/weapons/seedler/seedler.tscn @@ -1,11 +1,12 @@ -[gd_scene load_steps=4 format=3 uid="uid://c7unyob7tl6gs"] +[gd_scene load_steps=5 format=3 uid="uid://c7unyob7tl6gs"] [ext_resource type="Texture2D" uid="uid://bqwx5dm7jefu6" path="res://scenes/weapons/seedler/seedler.png" id="1_3obt5"] [ext_resource type="Script" path="res://scenes/weapons/seedler/seedler.gd" id="2_6mejc"] +[ext_resource type="PackedScene" uid="uid://cnhbuadu80gjc" path="res://scenes/bullets/seedler/seedler_nut.tscn" id="3_heb0u"] [sub_resource type="Curve2D" id="Curve2D_elleu"] _data = { -"points": PackedVector2Array(-47.0096, -0.651695, 47.0096, 0.651695, -80.5, -136.5, -42.668, -1.96383, 42.668, 1.96383, 125.696, 126.007, 1.12246, 50.4974, -1.12246, -50.4974, 164.043, 13.6843, 37.1347, 0.841369, -37.1347, -0.841369, 128, -131, 22.7463, -1.90143, -22.7463, 1.90143, -74.6522, 124.324, -1.12246, 64.7276, 1.12246, -64.7276, -123.957, -4.40512, -41.4783, -0.841369, 41.4783, 0.841369, -80.5, -136.5) +"points": PackedVector2Array(-47.0096, -0.651695, 47.0096, 0.651695, -80.5, -136.5, -42.668, -1.96383, 42.668, 1.96383, 125.696, 126.007, 1.12246, 50.4974, -1.12246, -50.4974, 164.043, 13.6843, 37.1347, 0.841369, -37.1347, -0.841369, 128, -131, 33.3115, 0.201991, -33.3115, -0.201991, -74.6522, 124.324, -1.12246, 64.7276, 1.12246, -64.7276, -123.957, -4.40512, -41.4783, -0.841369, 41.4783, 0.841369, -80.5, -136.5) } point_count = 7 @@ -25,3 +26,4 @@ position = Vector2(572, 321) scale = Vector2(2, 2) texture = ExtResource("1_3obt5") script = ExtResource("2_6mejc") +beam = ExtResource("3_heb0u")