game: add rat enemy
This commit is contained in:
@@ -6,6 +6,7 @@ extends CharacterBody2D
|
||||
@export var default_contact_damage: float = 0.0
|
||||
@export var target_distance: float = 6.0
|
||||
@export var path_update_interval: float = 1.5
|
||||
@export var xp_dropped: float = 5.0
|
||||
|
||||
@onready var target_cast: RayCast2D = $TargetCast
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@@ -97,7 +98,7 @@ func _do_nav_agent_movement():
|
||||
func check_contact_damage():
|
||||
if default_contact_damage == 0.0:
|
||||
return
|
||||
if global_position.distance_to(target.global_position) > target_distance:
|
||||
if global_position.distance_to(target.global_position) > target_distance + 2:
|
||||
return
|
||||
deal_contact_damage()
|
||||
|
||||
@@ -140,7 +141,7 @@ func die():
|
||||
|
||||
func drop_xp_orb() -> void:
|
||||
var orb: XPOrb = preload("res://scenes/xp_orb.tscn").instantiate()
|
||||
orb.value = 5
|
||||
orb.value = xp_dropped
|
||||
orb.position = position
|
||||
get_parent().call_deferred("add_child", orb)
|
||||
|
||||
|
@@ -12,7 +12,7 @@ shader_parameter/flash_amount = 0.0
|
||||
size = Vector2(32, 32)
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_satqt"]
|
||||
radius = 6.0
|
||||
radius = 4.0
|
||||
|
||||
[sub_resource type="Animation" id="Animation_satqt"]
|
||||
length = 0.001
|
||||
@@ -60,7 +60,7 @@ _data = {
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_pkqou"]
|
||||
|
||||
[node name="EnemyBase" type="CharacterBody2D"]
|
||||
[node name="EnemyBase" type="CharacterBody2D" groups=["damagable", "enemy"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 3
|
||||
script = ExtResource("1_qty17")
|
||||
|
1
scenes/enemies/enemy_bat.gd
Normal file
1
scenes/enemies/enemy_bat.gd
Normal file
@@ -0,0 +1 @@
|
||||
extends EnemyBase
|
1
scenes/enemies/enemy_bat.gd.uid
Normal file
1
scenes/enemies/enemy_bat.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bfhmjpjwdh25o
|
24
scenes/enemies/enemy_bat.tscn
Normal file
24
scenes/enemies/enemy_bat.tscn
Normal file
@@ -0,0 +1,24 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://du4t4vydra4rm"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b7vq8xspnlyeu" path="res://scenes/enemies/enemy_base.tscn" id="1_4r40l"]
|
||||
[ext_resource type="Script" uid="uid://bfhmjpjwdh25o" path="res://scenes/enemies/enemy_bat.gd" id="2_1jj4k"]
|
||||
[ext_resource type="Texture2D" uid="uid://chtjfq3bmonhj" path="res://assets/sprites/small_bat.png" id="2_608ut"]
|
||||
|
||||
[node name="EnemyBat" instance=ExtResource("1_4r40l")]
|
||||
collision_mask = 2
|
||||
script = ExtResource("2_1jj4k")
|
||||
move_speed = 175.0
|
||||
max_health = 6.0
|
||||
default_contact_damage = 5.0
|
||||
target_distance = 2.0
|
||||
xp_dropped = 8.0
|
||||
|
||||
[node name="Sprite2D" parent="." index="0"]
|
||||
texture = ExtResource("2_608ut")
|
||||
|
||||
[node name="TargetCast" parent="." index="2"]
|
||||
collision_mask = 0
|
||||
collide_with_bodies = false
|
||||
|
||||
[node name="ShapeCast2D" parent="." index="6"]
|
||||
visible = false
|
Reference in New Issue
Block a user