Tutorial 17 Enemy AI and Stats

This commit is contained in:
Alan Youngblood
2024-11-20 17:22:31 -05:00
parent 23a693d4a9
commit 24bc047855
14 changed files with 88 additions and 22 deletions

View File

@ -20,6 +20,7 @@ var state = IDLE
onready var sprite = $AnimatedSprite
onready var stats = $Stats
onready var playerDetectionZone = $PlayerDetectionZone
onready var hurtbox = $Hurtbox
func _physics_process(delta):
knockback = knockback.move_toward(Vector2.ZERO, 200 * delta)
@ -51,6 +52,7 @@ func seek_player():
func _on_Hurtbox_area_entered(area):
stats.health -= area.damage
knockback = area.knockback_vector * 120
hurtbox.create_hit_effect()
#queue_free() # Replace with function body.
func _on_Stats_no_health():

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=2]
[gd_scene load_steps=18 format=2]
[ext_resource path="res://Enemies/Bat.png" type="Texture" id=1]
[ext_resource path="res://Shadows/SmallShadow.png" type="Texture" id=2]
@ -6,6 +6,7 @@
[ext_resource path="res://Enemies/Bat.gd" type="Script" id=4]
[ext_resource path="res://Stats.tscn" type="PackedScene" id=5]
[ext_resource path="res://Enemies/PlayerDetectionZone.tscn" type="PackedScene" id=6]
[ext_resource path="res://Overlap/Hitbox.tscn" type="PackedScene" id=7]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
@ -45,6 +46,9 @@ height = 6.0
[sub_resource type="CircleShape2D" id=9]
radius = 61.0328
[sub_resource type="CircleShape2D" id=10]
radius = 5.0
[node name="Bat" type="KinematicBody2D"]
collision_layer = 16
script = ExtResource( 4 )
@ -78,8 +82,16 @@ max_health = 2
modulate = Color( 1, 1, 1, 0.258824 )
shape = SubResource( 9 )
[node name="Hitbox" parent="." instance=ExtResource( 7 )]
collision_mask = 4
[node name="CollisionShape2D" parent="Hitbox" index="0"]
position = Vector2( 0, -15 )
shape = SubResource( 10 )
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"]
[editable path="Hurtbox"]
[editable path="PlayerDetectionZone"]
[editable path="Hitbox"]