Add EnemyControllerComponent and PeriodicShootingComponent; implement enemy shooting behavior and bullet spawning

This commit is contained in:
2025-09-13 13:53:40 +02:00
parent db2a090acc
commit e6f8989d16
9 changed files with 94 additions and 111 deletions

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=28 format=3 uid="uid://bwdlmualj6xbw"]
[gd_scene load_steps=29 format=3 uid="uid://bwdlmualj6xbw"]
[ext_resource type="Shader" uid="uid://bs4xvm4qkurpr" path="res://shaders/hit_flash.tres" id="1_ep4yr"]
[ext_resource type="Texture2D" uid="uid://cu72810eyk4dx" path="res://sprites/enemy-robot.png" id="2_hjtwe"]
@@ -19,6 +19,7 @@
[ext_resource type="PackedScene" uid="uid://ck6nml06tm6ue" path="res://objects/fxs/ice_fx.tscn" id="16_68hnm"]
[ext_resource type="PackedScene" uid="uid://b12tppjkkqpt4" path="res://objects/fxs/hit_particles.tscn" id="18_pxaaa"]
[ext_resource type="Script" uid="uid://cgfynrn68lp12" path="res://scripts/components/KnockbackComponent.cs" id="19_xku20"]
[ext_resource type="Script" uid="uid://bhbgjr8ty2n85" path="res://scripts/components/EnemyControllerComponent.cs" id="20_5lji2"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pwwji"]
size = Vector2(25, 31)
@@ -97,13 +98,12 @@ RightRay = NodePath("../Right Ray")
LeftWallRay = NodePath("../Left Wall Ray")
RightWallRay = NodePath("../Right Wall Ray")
[node name="PeriodicShootingComponent" type="Node" parent="." node_paths=PackedStringArray("SideToSideMovement", "BulletSpawnRight", "BulletSpawnLeft")]
[node name="PeriodicShootingComponent" type="Node" parent="." node_paths=PackedStringArray("BulletSpawnPointRight", "BulletSpawnPointLeft")]
script = ExtResource("6_lgbyy")
BulletScene = ExtResource("7_r48kf")
SideToSideMovement = NodePath("../SideToSideMovement")
BulletSpawnRight = NodePath("../Sprite2D/right bullet spawn")
BulletSpawnLeft = NodePath("../Sprite2D/left bullet spawn")
ShootingIntervalVariation = 0.1
BulletSpawnPointRight = NodePath("../Sprite2D/right bullet spawn")
BulletSpawnPointLeft = NodePath("../Sprite2D/left bullet spawn")
ShootingIntervalVariation = 0.3
[node name="EnemyDeathComponent" type="Node" parent="." node_paths=PackedStringArray("CollisionShape", "Health")]
script = ExtResource("8_pxaaa")
@@ -187,3 +187,9 @@ process_material = SubResource("ParticleProcessMaterial_pxaaa")
[node name="KnockbackComponent" type="Node" parent="."]
script = ExtResource("19_xku20")
metadata/_custom_type_script = "uid://cgfynrn68lp12"
[node name="EnemyControllerComponent" type="Node" parent="." node_paths=PackedStringArray("MovementComponent", "ShootingComponent")]
script = ExtResource("20_5lji2")
MovementComponent = NodePath("../SideToSideMovement")
ShootingComponent = NodePath("../PeriodicShootingComponent")
metadata/_custom_type_script = "uid://bhbgjr8ty2n85"