some refactoring

This commit is contained in:
Victor Turgeon
2023-10-11 02:44:09 -04:00
parent c05a396954
commit a19250777f
6 changed files with 39 additions and 15 deletions

View File

@@ -1,8 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://brnx3xyyd0e71"]
[gd_scene load_steps=5 format=3 uid="uid://brnx3xyyd0e71"]
[ext_resource type="PackedScene" uid="uid://kkfxguj0lr5a" path="res://Scenes/Spawnables/template_spawnable.tscn" id="1_verf7"]
[ext_resource type="Texture2D" uid="uid://ddvr5ltbo8ome" path="res://Assets/Bat/noBKG_BatFlight_strip.png" id="2_0p8tq"]
[ext_resource type="Script" path="res://Scenes/Spawnables/AIs/ai_bat.gd" id="2_x3ldf"]
[sub_resource type="AtlasTexture" id="AtlasTexture_bnd0j"]
atlas = ExtResource("2_0p8tq")
region = Rect2(0, 0, 64, 64)
[node name="BatSpawnable" instance=ExtResource("1_verf7")]
maxHp = 10
attackSpeed = 50.0
@@ -10,6 +15,10 @@ speed = 4000.0
damage = 1
priority = 1
expReward = 50
cost = 100
minSpawnRange = 10.0
monsterName = "Bat"
monsterIcon = SubResource("AtlasTexture_bnd0j")
[node name="AnimatedSprite2D" parent="." index="1"]
frame_progress = 0.482614

View File

@@ -12,7 +12,8 @@ const ATTACK_COOLDOWN : float = 100
@export var cost : int = 0
@export var minSpawnRange : float = 0
@export var canAttack : bool = true
@export var monsterName : String = ""
@export var monsterIcon : Texture2D = null
@onready var ai : Node = $AI
@onready var animatedSprite : AnimatedSprite2D = $AnimatedSprite2D
@@ -29,6 +30,8 @@ var enemy : CharacterBody2D = null
var currentHp : int = 0
var cooldown : float = 0
signal signal_death(monster : TemplateSpawnable)
func _ready():
enemy = get_node("../Enemy")
currentHp = maxHp
@@ -95,6 +98,7 @@ func receive_damage(dmg):
func die():
enemy.remove_foe(self)
signal_death.emit(self)
bodyCollision.disabled = true
damageCollision.disabled = true
spawnableUI.visible = false