feat: 1. 添加charge冲锋敌人动画和攻击脚本
2. 添加shoot射击敌人攻击脚本
This commit is contained in:
+328
-11
@@ -5,7 +5,249 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://ov4fmsbglo55" path="res://assets/sprites/Map.png" id="2_5tue2"]
|
[ext_resource type="Texture2D" uid="uid://ov4fmsbglo55" path="res://assets/sprites/Map.png" id="2_5tue2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cgljr7wcstmyp" path="res://scenes/unit/players/player_well_rounded.tscn" id="3_5tue2"]
|
[ext_resource type="PackedScene" uid="uid://cgljr7wcstmyp" path="res://scenes/unit/players/player_well_rounded.tscn" id="3_5tue2"]
|
||||||
[ext_resource type="Script" uid="uid://cegcsi6n6r4gv" path="res://scenes/arena/camera_2d.gd" id="4_aj7ud"]
|
[ext_resource type="Script" uid="uid://cegcsi6n6r4gv" path="res://scenes/arena/camera_2d.gd" id="4_aj7ud"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="6_jx0ua"]
|
[ext_resource type="PackedScene" uid="uid://bot1mnbk3iu11" path="res://scenes/unit/enemy/enemy_charger.tscn" id="6_jx0ua"]
|
||||||
|
[ext_resource type="Script" uid="uid://b5j2awtdd1a4a" path="res://scenes/unit/enemy/enemy.gd" id="7_t3vx8"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bnknrm368mpwb" path="res://resources/units/enemies/stats_enemy_shooter.tres" id="8_rhjlh"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://devt2xbk78rej" path="res://assets/sprites/shadow.png" id="9_tp84n"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://4mllmwdfhmce" path="res://assets/sprites/Enemies/Enemy_4.png" id="10_8kk48"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bkyyic3okyjxx" path="res://scenes/components/hurtbox_component.tscn" id="11_wqbss"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c0fyx8gj5uexl" path="res://scenes/components/hitbox_component.tscn" id="12_fir7s"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://2ew7i6g3p0v8" path="res://scenes/components/health_component.tscn" id="13_gy0qm"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ifmw1e7gycc8" path="res://scenes/ui/health_bar/health_bar.tscn" id="14_dh340"]
|
||||||
|
[ext_resource type="Script" uid="uid://y47blv3332q8" path="res://scenes/unit/enemy/shooting_behavior.gd" id="15_l0cts"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bmhud2e0x287r" path="res://scenes/projectiles/projectile_enemy.tscn" id="16_ybinm"]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_e15k4"]
|
||||||
|
radius = 4.0
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_bhlit"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Visuals/Sprite:scale")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(1, 1)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Visuals/Sprite:rotation")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Visuals/Sprite:position")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0, -61)]
|
||||||
|
}
|
||||||
|
tracks/3/type = "value"
|
||||||
|
tracks/3/imported = false
|
||||||
|
tracks/3/enabled = true
|
||||||
|
tracks/3/path = NodePath("Visuals/Shadow:scale")
|
||||||
|
tracks/3/interp = 1
|
||||||
|
tracks/3/loop_wrap = true
|
||||||
|
tracks/3/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0.8, 1)]
|
||||||
|
}
|
||||||
|
tracks/4/type = "value"
|
||||||
|
tracks/4/imported = false
|
||||||
|
tracks/4/enabled = true
|
||||||
|
tracks/4/path = NodePath("Visuals/Shadow:position")
|
||||||
|
tracks/4/interp = 1
|
||||||
|
tracks/4/loop_wrap = true
|
||||||
|
tracks/4/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0, 0)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_0wuuu"]
|
||||||
|
resource_name = "move"
|
||||||
|
length = 0.5
|
||||||
|
step = 0.05
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Visuals/Sprite:position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.3),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0, -61), Vector2(0, -100), Vector2(0, -61)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Visuals/Sprite:rotation")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.15, 0.4),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0, 0.0, 1.5707963267948966]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Visuals/Sprite:scale")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.15),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(1, 1), Vector2(0.8, 1.4), Vector2(0.9, 1)]
|
||||||
|
}
|
||||||
|
tracks/3/type = "value"
|
||||||
|
tracks/3/imported = false
|
||||||
|
tracks/3/enabled = true
|
||||||
|
tracks/3/path = NodePath("Visuals/Shadow:scale")
|
||||||
|
tracks/3/interp = 1
|
||||||
|
tracks/3/loop_wrap = true
|
||||||
|
tracks/3/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.3),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0.8, 1), Vector2(0.6, 1), Vector2(0.9, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_vgvef"]
|
||||||
|
resource_name = "die"
|
||||||
|
length = 0.8
|
||||||
|
loop_mode = 1
|
||||||
|
step = 0.05
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Visuals/Sprite:scale")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.20000845, 0.4000169, 0.60002536),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(1, 1), Vector2(1.2, 0.8), Vector2(1, 1), Vector2(1.2, 0.8)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Visuals/Sprite:rotation")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.0]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Visuals/Shadow:position")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0, -4)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_3po7s"]
|
||||||
|
resource_name = "idle"
|
||||||
|
length = 0.6
|
||||||
|
loop_mode = 1
|
||||||
|
step = 0.05
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Visuals/Sprite:scale")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.15, 0.3, 0.45),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0.8, 1.1), Vector2(1, 1), Vector2(0.8, 1.1), Vector2(1, 1)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("Visuals/Sprite:rotation")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.15, 0.3, 0.45),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [0.2617993877991494, 0.0, -0.2617993877991494, 0.0]
|
||||||
|
}
|
||||||
|
tracks/2/type = "value"
|
||||||
|
tracks/2/imported = false
|
||||||
|
tracks/2/enabled = true
|
||||||
|
tracks/2/path = NodePath("Visuals/Sprite:position")
|
||||||
|
tracks/2/interp = 1
|
||||||
|
tracks/2/loop_wrap = true
|
||||||
|
tracks/2/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.15, 0.3, 0.45),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0, -61), Vector2(0, -75), Vector2(0, -61), Vector2(0, -75)]
|
||||||
|
}
|
||||||
|
tracks/3/type = "value"
|
||||||
|
tracks/3/imported = false
|
||||||
|
tracks/3/enabled = true
|
||||||
|
tracks/3/path = NodePath("Visuals/Shadow:scale")
|
||||||
|
tracks/3/interp = 1
|
||||||
|
tracks/3/loop_wrap = true
|
||||||
|
tracks/3/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.15, 0.3, 0.45),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(0.8, 1), Vector2(0.6, 1), Vector2(0.8, 1), Vector2(0.6, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_w7udy"]
|
||||||
|
_data = {
|
||||||
|
&"RESET": SubResource("Animation_bhlit"),
|
||||||
|
&"die": SubResource("Animation_0wuuu"),
|
||||||
|
&"idle": SubResource("Animation_vgvef"),
|
||||||
|
&"move": SubResource("Animation_3po7s")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_lmqbh"]
|
||||||
|
radius = 150.0
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_03rrj"]
|
||||||
|
radius = 38.0
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_421q1"]
|
||||||
|
radius = 40.0
|
||||||
|
|
||||||
[node name="Arena" type="Node2D" unique_id=1021720471 node_paths=PackedStringArray("player")]
|
[node name="Arena" type="Node2D" unique_id=1021720471 node_paths=PackedStringArray("player")]
|
||||||
script = ExtResource("1_asdgj")
|
script = ExtResource("1_asdgj")
|
||||||
@@ -28,17 +270,92 @@ texture = ExtResource("2_5tue2")
|
|||||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=758039070]
|
[node name="Camera2D" type="Camera2D" parent="." unique_id=758039070]
|
||||||
script = ExtResource("4_aj7ud")
|
script = ExtResource("4_aj7ud")
|
||||||
|
|
||||||
[node name="EnemyChaserSlow" parent="." unique_id=2092979720 instance=ExtResource("6_jx0ua")]
|
[node name="EnemyCharger" parent="." unique_id=2092979720 instance=ExtResource("6_jx0ua")]
|
||||||
position = Vector2(-493, 26)
|
position = Vector2(-481, 1)
|
||||||
|
|
||||||
[node name="EnemyChaserSlow2" parent="." unique_id=1388344292 instance=ExtResource("6_jx0ua")]
|
[node name="EnemyShooter" type="Area2D" parent="." unique_id=1617000445]
|
||||||
position = Vector2(-382, 165)
|
position = Vector2(-720, -233)
|
||||||
|
collision_layer = 2
|
||||||
|
script = ExtResource("7_t3vx8")
|
||||||
|
stats = ExtResource("8_rhjlh")
|
||||||
|
|
||||||
[node name="EnemyChaserSlow3" parent="." unique_id=597651166 instance=ExtResource("6_jx0ua")]
|
[node name="Visuals" type="Node2D" parent="EnemyShooter" unique_id=395976388]
|
||||||
position = Vector2(-673, -291)
|
unique_name_in_owner = true
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
|
||||||
[node name="EnemyChaserSlow4" parent="." unique_id=770584794 instance=ExtResource("6_jx0ua")]
|
[node name="Shadow" type="Sprite2D" parent="EnemyShooter/Visuals" unique_id=2136480859]
|
||||||
position = Vector2(-785, -79)
|
modulate = Color(0.11119685, 0.11119684, 0.11119684, 1)
|
||||||
|
self_modulate = Color(0.101960786, 0.101960786, 0.101960786, 0.3372549)
|
||||||
|
scale = Vector2(0.8, 1)
|
||||||
|
texture = ExtResource("9_tp84n")
|
||||||
|
|
||||||
[node name="EnemyChaserSlow5" parent="." unique_id=364194487 instance=ExtResource("6_jx0ua")]
|
[node name="Sprite" type="Sprite2D" parent="EnemyShooter/Visuals" unique_id=1925870318]
|
||||||
position = Vector2(-385, -141)
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(0, -61)
|
||||||
|
texture = ExtResource("10_8kk48")
|
||||||
|
|
||||||
|
[node name="FirePos" type="Marker2D" parent="EnemyShooter/Visuals" unique_id=815261850]
|
||||||
|
position = Vector2(-92, -50)
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyShooter" unique_id=139786467]
|
||||||
|
position = Vector2(0, -30)
|
||||||
|
shape = SubResource("CircleShape2D_e15k4")
|
||||||
|
debug_color = Color(0.97292477, 0.10649621, 0.32710177, 0.41960785)
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="EnemyShooter" unique_id=619019243]
|
||||||
|
libraries/ = SubResource("AnimationLibrary_w7udy")
|
||||||
|
|
||||||
|
[node name="VisionArea" type="Area2D" parent="EnemyShooter" unique_id=466967301]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 2
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyShooter/VisionArea" unique_id=715489053]
|
||||||
|
position = Vector2(0, -25)
|
||||||
|
shape = SubResource("CircleShape2D_lmqbh")
|
||||||
|
|
||||||
|
[node name="HurtboxComponent" parent="EnemyShooter" unique_id=1155790880 instance=ExtResource("11_wqbss")]
|
||||||
|
collision_layer = 8
|
||||||
|
collision_mask = 16
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyShooter/HurtboxComponent" 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="EnemyShooter" unique_id=151235566 instance=ExtResource("12_fir7s")]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 32
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyShooter/HitboxComponent" unique_id=906401181]
|
||||||
|
position = Vector2(0, -30)
|
||||||
|
shape = SubResource("CircleShape2D_421q1")
|
||||||
|
debug_color = Color(0.95670325, 0.056883797, 0.5071302, 0.41960785)
|
||||||
|
|
||||||
|
[node name="HealthComponent" parent="EnemyShooter" unique_id=455886217 instance=ExtResource("13_gy0qm")]
|
||||||
|
|
||||||
|
[node name="HealthBar" parent="EnemyShooter" unique_id=1540037291 instance=ExtResource("14_dh340")]
|
||||||
|
offset_left = -46.0
|
||||||
|
offset_top = -95.0
|
||||||
|
offset_right = 50.0
|
||||||
|
offset_bottom = -75.0
|
||||||
|
back_color = Color(0.015686275, 0.05490196, 0.16862746, 1)
|
||||||
|
fill_color = Color(0.37254903, 0.5372549, 0.75686276, 1)
|
||||||
|
|
||||||
|
[node name="FlashTimer" type="Timer" parent="EnemyShooter" unique_id=2034069027]
|
||||||
|
wait_time = 0.2
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="KnockbackTimer" type="Timer" parent="EnemyShooter" unique_id=1031574323]
|
||||||
|
wait_time = 0.4
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="ShootingBehavior" type="Node2D" parent="EnemyShooter" unique_id=1533506602 node_paths=PackedStringArray("enemy", "fire_pos")]
|
||||||
|
script = ExtResource("15_l0cts")
|
||||||
|
enemy = NodePath("..")
|
||||||
|
fire_pos = NodePath("../Visuals/FirePos")
|
||||||
|
projectile_scene = ExtResource("16_ybinm")
|
||||||
|
|
||||||
|
[connection signal="on_damaged" from="EnemyShooter/HurtboxComponent" to="EnemyShooter" method="_on_hurtbox_component_on_damaged"]
|
||||||
|
[connection signal="on_health_changed" from="EnemyShooter/HealthComponent" to="EnemyShooter/HealthBar" method="_on_health_component_on_health_changed"]
|
||||||
|
[connection signal="timeout" from="EnemyShooter/FlashTimer" to="EnemyShooter" method="_on_flash_timer_timeout"]
|
||||||
|
[connection signal="timeout" from="EnemyShooter/KnockbackTimer" to="EnemyShooter" method="_on_knockback_timer_timeout"]
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
[gd_scene format=3 uid="uid://bmhud2e0x287r"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cponp20ht0gf6" path="res://scenes/projectiles/projectile_pistol.tscn" id="1_8vv1r"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dkji1b4um54aj" path="res://assets/sprites/Projectiles/Projectile_enemy.png" id="2_5d7ua"]
|
||||||
|
|
||||||
|
[node name="ProjectileEnemy" unique_id=109874266 instance=ExtResource("1_8vv1r")]
|
||||||
|
|
||||||
|
[node name="Sprite2D" parent="." index="0" unique_id=575255969]
|
||||||
|
texture = ExtResource("2_5d7ua")
|
||||||
|
|
||||||
|
[node name="HitboxComponent" parent="." index="1" unique_id=151235566]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 32
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
extends Node2D
|
||||||
|
class_name ChargeBehabior
|
||||||
|
|
||||||
|
@export var enemy: Enemy
|
||||||
|
@export var anim_effects: AnimationPlayer
|
||||||
|
@export var prep_time := 1.0
|
||||||
|
@export var cooldown := 3.0
|
||||||
|
|
||||||
|
|
||||||
|
var current_cooldown := 0.0
|
||||||
|
var charge_attack_position := Vector2.ZERO
|
||||||
|
var is_charging := false
|
||||||
|
func _ready() -> void:
|
||||||
|
current_cooldown = cooldown
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if enemy == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
if is_charging:
|
||||||
|
enemy.global_position = enemy.global_position.move_toward(charge_attack_position, (enemy.stats.speed * 5) * delta)
|
||||||
|
|
||||||
|
if enemy.global_position.distance_to(charge_attack_position) < 50:
|
||||||
|
end_charge()
|
||||||
|
else:
|
||||||
|
if current_cooldown > 0:
|
||||||
|
current_cooldown -= delta
|
||||||
|
else:
|
||||||
|
if is_instance_valid(Global.player):
|
||||||
|
charge_attack_position = Global.player.global_position
|
||||||
|
start_charge()
|
||||||
|
|
||||||
|
|
||||||
|
func start_charge() -> void:
|
||||||
|
enemy.can_move = false
|
||||||
|
anim_effects.play("charge")
|
||||||
|
await anim_effects.animation_finished
|
||||||
|
is_charging = true
|
||||||
|
|
||||||
|
func end_charge() -> void:
|
||||||
|
is_charging = false
|
||||||
|
current_cooldown = cooldown
|
||||||
|
enemy.can_move = true
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://bnmw1uhp71ipe
|
||||||
@@ -43,12 +43,17 @@ func get_move_direction() -> Vector2:
|
|||||||
return direction
|
return direction
|
||||||
|
|
||||||
func update_rotate() -> void:
|
func update_rotate() -> void:
|
||||||
if is_instance_valid(Global.player):
|
|
||||||
|
print("11111111")
|
||||||
|
|
||||||
|
if !is_instance_valid(Global.player):
|
||||||
return
|
return
|
||||||
|
|
||||||
var player_pos := Global.player.position
|
var player_pos := Global.player.position
|
||||||
|
|
||||||
var moving_right := global_position.x < player_pos.x
|
var moving_right := global_position.x < player_pos.x
|
||||||
|
|
||||||
|
print(moving_right, '111111')
|
||||||
visuals.scale = Vector2(-0.5,0.5) if moving_right else Vector2(0.5,0.5)
|
visuals.scale = Vector2(-0.5,0.5) if moving_right else Vector2(0.5,0.5)
|
||||||
|
|
||||||
func can_move_forwards_player() -> bool:
|
func can_move_forwards_player() -> bool:
|
||||||
|
|||||||
@@ -3,9 +3,62 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="1_ksdef"]
|
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="1_ksdef"]
|
||||||
[ext_resource type="Resource" uid="uid://delxlqjos3br" path="res://resources/units/enemies/stats_enemy_charger.tres" id="2_4i178"]
|
[ext_resource type="Resource" uid="uid://delxlqjos3br" path="res://resources/units/enemies/stats_enemy_charger.tres" id="2_4i178"]
|
||||||
[ext_resource type="Texture2D" uid="uid://emsi6ifyt0vf" path="res://assets/sprites/Enemies/Enemy_5.png" id="2_knpng"]
|
[ext_resource type="Texture2D" uid="uid://emsi6ifyt0vf" path="res://assets/sprites/Enemies/Enemy_5.png" id="2_knpng"]
|
||||||
|
[ext_resource type="Script" uid="uid://bnmw1uhp71ipe" path="res://scenes/unit/enemy/charge_behavior.gd" id="4_4i178"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_4i178"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Visuals/Sprite:modulate")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Color(1, 1, 1, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_1som8"]
|
||||||
|
resource_name = "charge"
|
||||||
|
length = 0.7
|
||||||
|
step = 0.05
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Visuals/Sprite:modulate")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Color(1, 1, 1, 1), Color(0.8509804, 0.2901961, 0.4509804, 1), Color(1, 1, 1, 1), Color(0.8509804, 0.2901961, 0.4509804, 1), Color(1, 1, 1, 1), Color(0.8509804, 0.2901961, 0.4509804, 1), Color(1, 1, 1, 1)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_eecfj"]
|
||||||
|
_data = {
|
||||||
|
&"RESET": SubResource("Animation_4i178"),
|
||||||
|
&"charge": SubResource("Animation_1som8")
|
||||||
|
}
|
||||||
|
|
||||||
[node name="EnemyCharger" unique_id=2092979720 instance=ExtResource("1_ksdef")]
|
[node name="EnemyCharger" unique_id=2092979720 instance=ExtResource("1_ksdef")]
|
||||||
stats = ExtResource("2_4i178")
|
stats = ExtResource("2_4i178")
|
||||||
|
|
||||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
||||||
texture = ExtResource("2_knpng")
|
texture = ExtResource("2_knpng")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" parent="HurtboxComponent" parent_id_path=PackedInt32Array(1155790880) index="0" unique_id=880029571]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" parent="HitboxComponent" parent_id_path=PackedInt32Array(151235566) index="0" unique_id=906401181]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="ChargeBehavior" type="Node2D" parent="." index="10" unique_id=1772502108 node_paths=PackedStringArray("enemy", "anim_effects")]
|
||||||
|
script = ExtResource("4_4i178")
|
||||||
|
enemy = NodePath("..")
|
||||||
|
anim_effects = NodePath("../AnimationEffects")
|
||||||
|
|
||||||
|
[node name="AnimationEffects" type="AnimationPlayer" parent="." index="11" unique_id=2036684046]
|
||||||
|
libraries/ = SubResource("AnimationLibrary_eecfj")
|
||||||
|
|||||||
@@ -3,9 +3,20 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="1_tty1r"]
|
[ext_resource type="PackedScene" uid="uid://bfuqhhe8r8asg" path="res://scenes/unit/enemy/enemy_chaser_slow.tscn" id="1_tty1r"]
|
||||||
[ext_resource type="Resource" uid="uid://bnknrm368mpwb" path="res://resources/units/enemies/stats_enemy_shooter.tres" id="2_6k67w"]
|
[ext_resource type="Resource" uid="uid://bnknrm368mpwb" path="res://resources/units/enemies/stats_enemy_shooter.tres" id="2_6k67w"]
|
||||||
[ext_resource type="Texture2D" uid="uid://4mllmwdfhmce" path="res://assets/sprites/Enemies/Enemy_4.png" id="2_tev67"]
|
[ext_resource type="Texture2D" uid="uid://4mllmwdfhmce" path="res://assets/sprites/Enemies/Enemy_4.png" id="2_tev67"]
|
||||||
|
[ext_resource type="Script" uid="uid://y47blv3332q8" path="res://scenes/unit/enemy/shooting_behavior.gd" id="4_6k67w"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bmhud2e0x287r" path="res://scenes/projectiles/projectile_enemy.tscn" id="5_kpiq8"]
|
||||||
|
|
||||||
[node name="EnemyShooter" unique_id=2092979720 instance=ExtResource("1_tty1r")]
|
[node name="EnemyShooter" unique_id=2092979720 instance=ExtResource("1_tty1r")]
|
||||||
stats = ExtResource("2_6k67w")
|
stats = ExtResource("2_6k67w")
|
||||||
|
|
||||||
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
[node name="Sprite" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="1" unique_id=1925870318]
|
||||||
texture = ExtResource("2_tev67")
|
texture = ExtResource("2_tev67")
|
||||||
|
|
||||||
|
[node name="FirePos" type="Marker2D" parent="Visuals" parent_id_path=PackedInt32Array(395976388) index="2" unique_id=815261850]
|
||||||
|
position = Vector2(-92, -50)
|
||||||
|
|
||||||
|
[node name="ShootingBehavior" type="Node2D" parent="." index="10" unique_id=1533506602 node_paths=PackedStringArray("enemy", "fire_pos")]
|
||||||
|
script = ExtResource("4_6k67w")
|
||||||
|
enemy = NodePath("..")
|
||||||
|
fire_pos = NodePath("../Visuals/FirePos")
|
||||||
|
projectile_scene = ExtResource("5_kpiq8")
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
extends Node2D
|
||||||
|
class_name ShootingBehavior
|
||||||
|
|
||||||
|
@export var enemy: Enemy
|
||||||
|
@export var fire_pos: Marker2D
|
||||||
|
@export var cooldown := 3.0
|
||||||
|
@export var projectile_count := 3
|
||||||
|
@export var arc_angle := 45.0
|
||||||
|
@export var projectile_scene: PackedScene
|
||||||
|
@export var projectile_speed := 1800.0
|
||||||
|
|
||||||
|
var current_cooldown := 0.0
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
current_cooldown = cooldown
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if enemy == null:
|
||||||
|
return
|
||||||
|
|
||||||
|
if current_cooldown > 0:
|
||||||
|
current_cooldown -= delta
|
||||||
|
else:
|
||||||
|
shoot()
|
||||||
|
current_cooldown = cooldown
|
||||||
|
|
||||||
|
func shoot() -> void:
|
||||||
|
if not is_instance_valid(Global.player):
|
||||||
|
return
|
||||||
|
|
||||||
|
enemy.can_move = false
|
||||||
|
|
||||||
|
var direction := enemy.global_position.direction_to(Global.player.global_position)
|
||||||
|
|
||||||
|
var start_angle := -arc_angle / 2.0
|
||||||
|
var angle_step := arc_angle / float(projectile_count - 1 if projectile_count > 1 else 0.0)
|
||||||
|
|
||||||
|
for i in range(projectile_count):
|
||||||
|
var projectile := projectile_scene.instantiate() as Projectile
|
||||||
|
get_tree().root.add_child(projectile)
|
||||||
|
projectile.global_position = fire_pos.global_position
|
||||||
|
|
||||||
|
var rotate_direction := direction.rotated(deg_to_rad(start_angle + angle_step * i))
|
||||||
|
var velocity := rotate_direction * projectile_speed
|
||||||
|
projectile.set_projectile(velocity, enemy.stats.damage, false, 0, enemy)
|
||||||
|
|
||||||
|
|
||||||
|
await get_tree().create_timer(1).timeout
|
||||||
|
enemy.can_move = true
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://y47blv3332q8
|
||||||
@@ -29,7 +29,7 @@ func _ready() -> void:
|
|||||||
#add_weapon(preload("uid://0388m8srn1no"))
|
#add_weapon(preload("uid://0388m8srn1no"))
|
||||||
#add_weapon(preload("uid://cwpf4ko1wqfw"))
|
#add_weapon(preload("uid://cwpf4ko1wqfw"))
|
||||||
#add_weapon(preload("uid://dgiq00qbjoc2w"))
|
#add_weapon(preload("uid://dgiq00qbjoc2w"))
|
||||||
add_weapon(preload("uid://cyobkqxhoqqbq"))
|
#add_weapon(preload("uid://cyobkqxhoqqbq"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user