Skip to content

Commit

Permalink
feat: seedler finish
Browse files Browse the repository at this point in the history
  • Loading branch information
wlywlywlywly committed Jul 12, 2024
1 parent 72f257a commit db8eda2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
6 changes: 3 additions & 3 deletions scenes/bullets/seedler/seedler_nut.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
43 changes: 36 additions & 7 deletions scenes/weapons/seedler/seedler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,60 @@ extends Sprite2D
const TIMES = 5
@onready var path = $"../Path2D"
@onready var follow = $"../Path2D/PathFollow2D"
@export var beam: PackedScene


func move(length: float) -> void:
follow.progress = length
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:
Expand Down
6 changes: 4 additions & 2 deletions scenes/weapons/seedler/seedler.tscn
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -25,3 +26,4 @@ position = Vector2(572, 321)
scale = Vector2(2, 2)
texture = ExtResource("1_3obt5")
script = ExtResource("2_6mejc")
beam = ExtResource("3_heb0u")

0 comments on commit db8eda2

Please sign in to comment.