feat: 1. 添加武器位置,1-6
2. 添加武器容器 3. 添加敌人的Hurtbox
This commit is contained in:
@@ -31,7 +31,7 @@ func get_move_direction() -> Vector2:
|
|||||||
if not is_instance_valid(Global.player):
|
if not is_instance_valid(Global.player):
|
||||||
return Vector2.ZERO
|
return Vector2.ZERO
|
||||||
|
|
||||||
var direction := global_position.direction_to(Global.player.position)
|
var direction := global_position.direction_to(Global.player.global_position)
|
||||||
|
|
||||||
for area: Node2D in vision_area.get_overlapping_areas():
|
for area: Node2D in vision_area.get_overlapping_areas():
|
||||||
if area != self and area.is_inside_tree():
|
if area != self and area.is_inside_tree():
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ radius = 4.0
|
|||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_lmqbh"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_lmqbh"]
|
||||||
radius = 150.0
|
radius = 150.0
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_03rrj"]
|
||||||
|
radius = 38.0
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_421q1"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_421q1"]
|
||||||
radius = 40.0
|
radius = 40.0
|
||||||
|
|
||||||
@@ -37,6 +40,15 @@ collision_mask = 2
|
|||||||
position = Vector2(0, -25)
|
position = Vector2(0, -25)
|
||||||
shape = SubResource("CircleShape2D_lmqbh")
|
shape = SubResource("CircleShape2D_lmqbh")
|
||||||
|
|
||||||
|
[node name="HurtboxComponent" parent="." index="4" unique_id=1155790880]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 16
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="HurtboxComponent" index="0" unique_id=880029571]
|
||||||
|
position = Vector2(0, -30)
|
||||||
|
shape = SubResource("CircleShape2D_03rrj")
|
||||||
|
debug_color = Color(0.59981126, 0.5382401, 0.22537157, 0.41960785)
|
||||||
|
|
||||||
[node name="HitboxComponent" parent="." index="5" unique_id=151235566 instance=ExtResource("5_e15k4")]
|
[node name="HitboxComponent" parent="." index="5" unique_id=151235566 instance=ExtResource("5_e15k4")]
|
||||||
collision_layer = 4
|
collision_layer = 4
|
||||||
collision_mask = 32
|
collision_mask = 32
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class_name Player
|
|||||||
@onready var dash_cooldown_timer: Timer = $DashCooldownTimer
|
@onready var dash_cooldown_timer: Timer = $DashCooldownTimer
|
||||||
@onready var collision: CollisionShape2D = $CollisionShape2D
|
@onready var collision: CollisionShape2D = $CollisionShape2D
|
||||||
@onready var trail: Trail = %Trail
|
@onready var trail: Trail = %Trail
|
||||||
|
@onready var weapon_container: WeaponContainer = $WeaponContainer
|
||||||
|
|
||||||
|
var current_weapons: Array[Weapon] = []
|
||||||
|
|
||||||
var move_dir: Vector2
|
var move_dir: Vector2
|
||||||
var is_dashing := false
|
var is_dashing := false
|
||||||
@@ -20,6 +23,13 @@ func _ready() -> void:
|
|||||||
dash_timer.wait_time = dash_duration
|
dash_timer.wait_time = dash_duration
|
||||||
dash_cooldown_timer.wait_time = dash_cooldown
|
dash_cooldown_timer.wait_time = dash_cooldown
|
||||||
|
|
||||||
|
add_weapon(preload("uid://murcuuks1j8l"))
|
||||||
|
add_weapon(preload("uid://murcuuks1j8l"))
|
||||||
|
add_weapon(preload("uid://murcuuks1j8l"))
|
||||||
|
add_weapon(preload("uid://murcuuks1j8l"))
|
||||||
|
add_weapon(preload("uid://murcuuks1j8l"))
|
||||||
|
add_weapon(preload("uid://murcuuks1j8l"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
@@ -41,6 +51,15 @@ func _process(delta: float) -> void:
|
|||||||
update_animations()
|
update_animations()
|
||||||
update_rotation()
|
update_rotation()
|
||||||
|
|
||||||
|
func add_weapon(data: ItemWeapon) -> void:
|
||||||
|
var weapon := data.scene.instantiate() as Weapon
|
||||||
|
add_child(weapon)
|
||||||
|
|
||||||
|
weapon.setup_weapon(data)
|
||||||
|
current_weapons.append(weapon)
|
||||||
|
weapon_container.update_weapons_positions(current_weapons)
|
||||||
|
|
||||||
|
|
||||||
func update_animations() -> void:
|
func update_animations() -> void:
|
||||||
if move_dir.length() > 0:
|
if move_dir.length() > 0:
|
||||||
anim_player.play("move")
|
anim_player.play("move")
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://b5makasbbi1ov" path="res://scenes/unit/players/player.gd" id="2_xa7el"]
|
[ext_resource type="Script" uid="uid://b5makasbbi1ov" path="res://scenes/unit/players/player.gd" id="2_xa7el"]
|
||||||
[ext_resource type="Resource" uid="uid://btnfef0ui2ju8" path="res://resources/units/players/stats_player_well_rounded.tres" id="3_xa7el"]
|
[ext_resource type="Resource" uid="uid://btnfef0ui2ju8" path="res://resources/units/players/stats_player_well_rounded.tres" id="3_xa7el"]
|
||||||
[ext_resource type="Script" uid="uid://bkfe6nn8yxhbq" path="res://scenes/unit/players/trail.gd" id="4_0kki1"]
|
[ext_resource type="Script" uid="uid://bkfe6nn8yxhbq" path="res://scenes/unit/players/trail.gd" id="4_0kki1"]
|
||||||
|
[ext_resource type="Script" uid="uid://cxkyieqijftcu" path="res://scenes/unit/players/weapon_container.gd" id="6_viu20"]
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_ht2l1"]
|
[sub_resource type="Curve" id="Curve_ht2l1"]
|
||||||
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||||
@@ -45,16 +46,100 @@ z_index = 1
|
|||||||
position = Vector2(0, -31)
|
position = Vector2(0, -31)
|
||||||
shape = SubResource("CircleShape2D_etcc1")
|
shape = SubResource("CircleShape2D_etcc1")
|
||||||
|
|
||||||
[node name="DashTimer" type="Timer" parent="." index="3" unique_id=968231365]
|
[node name="WeaponContainer" type="Node2D" parent="." index="3" unique_id=1247020101]
|
||||||
|
script = ExtResource("6_viu20")
|
||||||
|
|
||||||
|
[node name="One" type="Node2D" parent="WeaponContainer" index="0" unique_id=539007369]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="WeaponContainer/One" index="0" unique_id=831356380]
|
||||||
|
position = Vector2(0, -15)
|
||||||
|
|
||||||
|
[node name="Two" type="Node2D" parent="WeaponContainer" index="1" unique_id=289812867]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="WeaponContainer/Two" index="0" unique_id=128089457]
|
||||||
|
position = Vector2(40, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D2" type="Marker2D" parent="WeaponContainer/Two" index="1" unique_id=617036328]
|
||||||
|
position = Vector2(-40, 20)
|
||||||
|
|
||||||
|
[node name="Three" type="Node2D" parent="WeaponContainer" index="2" unique_id=629421449]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="WeaponContainer/Three" index="0" unique_id=739257802]
|
||||||
|
position = Vector2(40, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D2" type="Marker2D" parent="WeaponContainer/Three" index="1" unique_id=855050328]
|
||||||
|
position = Vector2(-40, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D3" type="Marker2D" parent="WeaponContainer/Three" index="2" unique_id=472814416]
|
||||||
|
position = Vector2(0, -115)
|
||||||
|
|
||||||
|
[node name="Four" type="Node2D" parent="WeaponContainer" index="3" unique_id=506537805]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="WeaponContainer/Four" index="0" unique_id=1255805561]
|
||||||
|
position = Vector2(40, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D2" type="Marker2D" parent="WeaponContainer/Four" index="1" unique_id=878895749]
|
||||||
|
position = Vector2(-40, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D3" type="Marker2D" parent="WeaponContainer/Four" index="2" unique_id=1295456195]
|
||||||
|
position = Vector2(40, -115)
|
||||||
|
|
||||||
|
[node name="Marker2D4" type="Marker2D" parent="WeaponContainer/Four" index="3" unique_id=1608558685]
|
||||||
|
position = Vector2(-40, -115)
|
||||||
|
|
||||||
|
[node name="Five" type="Node2D" parent="WeaponContainer" index="4" unique_id=1785938762]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="WeaponContainer/Five" index="0" unique_id=996744656]
|
||||||
|
position = Vector2(40, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D2" type="Marker2D" parent="WeaponContainer/Five" index="1" unique_id=1613414350]
|
||||||
|
position = Vector2(-40, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D3" type="Marker2D" parent="WeaponContainer/Five" index="2" unique_id=41036492]
|
||||||
|
position = Vector2(60, -40)
|
||||||
|
|
||||||
|
[node name="Marker2D4" type="Marker2D" parent="WeaponContainer/Five" index="3" unique_id=1569055213]
|
||||||
|
position = Vector2(-60, -40)
|
||||||
|
|
||||||
|
[node name="Marker2D5" type="Marker2D" parent="WeaponContainer/Five" index="4" unique_id=658888569]
|
||||||
|
position = Vector2(0, -115)
|
||||||
|
|
||||||
|
[node name="Six" type="Node2D" parent="WeaponContainer" index="5" unique_id=212814573]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Marker2D" type="Marker2D" parent="WeaponContainer/Six" index="0" unique_id=1448136568]
|
||||||
|
position = Vector2(35, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D2" type="Marker2D" parent="WeaponContainer/Six" index="1" unique_id=1295815397]
|
||||||
|
position = Vector2(-35, 20)
|
||||||
|
|
||||||
|
[node name="Marker2D3" type="Marker2D" parent="WeaponContainer/Six" index="2" unique_id=604337112]
|
||||||
|
position = Vector2(35, -115)
|
||||||
|
|
||||||
|
[node name="Marker2D4" type="Marker2D" parent="WeaponContainer/Six" index="3" unique_id=395392856]
|
||||||
|
position = Vector2(-35, -115)
|
||||||
|
|
||||||
|
[node name="Marker2D5" type="Marker2D" parent="WeaponContainer/Six" index="4" unique_id=1176036243]
|
||||||
|
position = Vector2(60, -45)
|
||||||
|
|
||||||
|
[node name="Marker2D6" type="Marker2D" parent="WeaponContainer/Six" index="5" unique_id=1779481566]
|
||||||
|
position = Vector2(-60, -45)
|
||||||
|
|
||||||
|
[node name="DashTimer" type="Timer" parent="." index="4" unique_id=968231365]
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
[node name="DashCooldownTimer" type="Timer" parent="." index="4" unique_id=278610339]
|
[node name="DashCooldownTimer" type="Timer" parent="." index="5" unique_id=278610339]
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
[node name="TrailTimer" type="Timer" parent="." index="5" unique_id=2006934730]
|
[node name="TrailTimer" type="Timer" parent="." index="6" unique_id=2006934730]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
||||||
[node name="HurtboxComponent" parent="." index="6" unique_id=1155790880]
|
[node name="HurtboxComponent" parent="." index="7" unique_id=1155790880]
|
||||||
collision_layer = 32
|
collision_layer = 32
|
||||||
collision_mask = 4
|
collision_mask = 4
|
||||||
|
|
||||||
@@ -63,7 +148,7 @@ z_index = 1
|
|||||||
position = Vector2(0, -32)
|
position = Vector2(0, -32)
|
||||||
shape = SubResource("CircleShape2D_ht2l1")
|
shape = SubResource("CircleShape2D_ht2l1")
|
||||||
|
|
||||||
[node name="HealthBar" parent="." index="8" unique_id=1540037291]
|
[node name="HealthBar" parent="." index="9" unique_id=1540037291]
|
||||||
back_color = Color(0.13725491, 0.019607844, 0.02745098, 1)
|
back_color = Color(0.13725491, 0.019607844, 0.02745098, 1)
|
||||||
fill_color = Color(1, 0.2901961, 0.45490196, 1)
|
fill_color = Color(1, 0.2901961, 0.45490196, 1)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
extends Node2D
|
||||||
|
class_name WeaponContainer
|
||||||
|
|
||||||
|
@onready var one: Node2D = $One
|
||||||
|
@onready var two: Node2D = $Two
|
||||||
|
@onready var three: Node2D = $Three
|
||||||
|
@onready var four: Node2D = $Four
|
||||||
|
@onready var five: Node2D = $Five
|
||||||
|
@onready var six: Node2D = $Six
|
||||||
|
|
||||||
|
|
||||||
|
func update_weapons_positions(weapons: Array[Weapon]) -> void:
|
||||||
|
var count := weapons.size()
|
||||||
|
var reference_node: Node2D
|
||||||
|
match count:
|
||||||
|
1: reference_node = one
|
||||||
|
2: reference_node = two
|
||||||
|
3: reference_node = three
|
||||||
|
4: reference_node = four
|
||||||
|
5: reference_node = five
|
||||||
|
6: reference_node = six
|
||||||
|
|
||||||
|
var markers := reference_node.get_children()
|
||||||
|
if markers.size() != count:
|
||||||
|
return
|
||||||
|
|
||||||
|
for i in count:
|
||||||
|
weapons[i].global_position = markers[i].global_position
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://cxkyieqijftcu
|
||||||
@@ -13,6 +13,8 @@ position = Vector2(21, 1)
|
|||||||
|
|
||||||
[node name="HitboxComponent" parent="Sprite2D" index="0" unique_id=151235566 instance=ExtResource("2_gq287")]
|
[node name="HitboxComponent" parent="Sprite2D" index="0" unique_id=151235566 instance=ExtResource("2_gq287")]
|
||||||
scale = Vector2(2, 2)
|
scale = Vector2(2, 2)
|
||||||
|
collision_layer = 16
|
||||||
|
collision_mask = 8
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite2D/HitboxComponent" index="0" unique_id=1064980236]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite2D/HitboxComponent" index="0" unique_id=1064980236]
|
||||||
z_index = 1
|
z_index = 1
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ func _ready() -> void:
|
|||||||
atk_start_pos = sprite_2d.position
|
atk_start_pos = sprite_2d.position
|
||||||
|
|
||||||
|
|
||||||
func setup_weapon(data: ItemWeapon) -> void:
|
func setup_weapon(_data: ItemWeapon) -> void:
|
||||||
self.data = data
|
self.data = _data
|
||||||
collision.shape.radius = data.stats.max_range
|
collision.shape.radius = data.stats.max_range
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ radius = 150.0
|
|||||||
script = ExtResource("1_v4xn6")
|
script = ExtResource("1_v4xn6")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1011668514]
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1011668514]
|
||||||
|
z_index = 1
|
||||||
scale = Vector2(0.5, 0.5)
|
scale = Vector2(0.5, 0.5)
|
||||||
texture = ExtResource("2_uvw4m")
|
texture = ExtResource("2_uvw4m")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user