split hurt and die options on the base enemy
parent
40d3d4c423
commit
0ac9d0fae8
|
|
@ -2364,7 +2364,7 @@ offset_bottom = 40.0
|
|||
script = ExtResource("6_p57ef")
|
||||
|
||||
[node name="SpawnTimer" type="Timer" parent="." unique_id=1852920556]
|
||||
wait_time = 0.203
|
||||
wait_time = 0.2
|
||||
autostart = true
|
||||
|
||||
[node name="Witch" parent="." unique_id=1188927311 instance=ExtResource("7_u5sy4")]
|
||||
|
|
|
|||
|
|
@ -3,12 +3,109 @@
|
|||
[ext_resource type="Script" uid="uid://cb378ofiodjbg" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||
[ext_resource type="Texture2D" uid="uid://bjwgceqri2c87" path="res://assets/Swordsman_lvl1/Without_shadow/Swordsman_lvl1_Idle_without_shadow.png" id="2_qhqgy"]
|
||||
[ext_resource type="Texture2D" uid="uid://c4dl5ytt47b45" path="res://assets/Swordsman_lvl1/Without_shadow/Swordsman_lvl1_Death_without_shadow.png" id="2_qlg0r"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpgk1lsvxnbf4" path="res://assets/Swordsman_lvl1/With_shadow/Swordsman_lvl1_Walk_Attack_with_shadow.png" id="2_tuyoq"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfb1vyk7t0pkn" path="res://assets/Swordsman_lvl1/Without_shadow/Swordsman_lvl1_Run_without_shadow.png" id="3_dqkch"]
|
||||
[ext_resource type="Texture2D" uid="uid://cw2gocls81uli" path="res://assets/Swordsman_lvl1/Without_shadow/Swordsman_lvl1_Walk_without_shadow.png" id="4_dqkch"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_u8vuu"]
|
||||
radius = 7.0
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qsb7e"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(0, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qjsmb"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(64, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_mwp2n"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(128, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_0yhus"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(192, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jlll7"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(256, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qk6i7"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(320, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_6c3st"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(0, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1da1t"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(64, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_p21yu"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(128, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_irpag"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(192, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_bpsgo"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(256, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jx8is"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(320, 64, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_vx63k"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(0, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_lw0jh"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(64, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ry8ed"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(128, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_au8ao"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(192, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_w5j5w"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(256, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_cbf1i"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(320, 128, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4vfid"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(0, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ljgr3"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(64, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fr8ja"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(128, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gvmy4"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(192, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fcu33"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(256, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qmsq4"]
|
||||
atlas = ExtResource("2_tuyoq")
|
||||
region = Rect2(320, 192, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fuw3a"]
|
||||
atlas = ExtResource("2_qlg0r")
|
||||
region = Rect2(0, 0, 64, 64)
|
||||
|
|
@ -285,6 +382,98 @@ region = Rect2(320, 192, 64, 64)
|
|||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qsb7e")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qjsmb")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_mwp2n")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_0yhus")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jlll7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qk6i7")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"attack_down",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_6c3st")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_1da1t")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_p21yu")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_irpag")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_bpsgo")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jx8is")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"attack_left",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_vx63k")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_lw0jh")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ry8ed")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_au8ao")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_w5j5w")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_cbf1i")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"attack_right",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4vfid")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ljgr3")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fr8ja")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_gvmy4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fcu33")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qmsq4")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"attack_up",
|
||||
"speed": 10.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fuw3a")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
|
|
@ -597,5 +786,4 @@ shape = SubResource("CapsuleShape2D_u8vuu")
|
|||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1616479252]
|
||||
texture_filter = 1
|
||||
sprite_frames = SubResource("SpriteFrames_giy8y")
|
||||
animation = &"idle"
|
||||
frame_progress = 0.72525793
|
||||
animation = &"attack_up"
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ func launch(target: Vector2):
|
|||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if body.is_in_group("enemies"):
|
||||
body.die()
|
||||
body.hit()
|
||||
queue_free()
|
||||
|
||||
func _remove():
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
extends EnemyBase
|
||||
|
||||
|
||||
var hits_remaining = 2
|
||||
var is_hurt = false
|
||||
|
||||
func _ready() -> void:
|
||||
super()
|
||||
speed = 0.1
|
||||
animated_sprite_2d.sprite_frames = animated_sprite_2d.sprite_frames.duplicate()
|
||||
hits_remaining = 2
|
||||
$Area2D.body_entered.connect(_on_area_2d_body_entered)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
|
@ -15,27 +12,6 @@ func _process(delta: float) -> void:
|
|||
return
|
||||
_chase_witch()
|
||||
|
||||
func die() -> void:
|
||||
hits_remaining -= 1
|
||||
if hits_remaining <= 0:
|
||||
super()
|
||||
else:
|
||||
_play_hurt()
|
||||
|
||||
func _play_hurt() -> void:
|
||||
is_hurt = true
|
||||
var hurt_anim: String
|
||||
if abs(last_direction.x) >= abs(last_direction.y):
|
||||
hurt_anim = "hurt_left" if last_direction.x < 0 else "hurt_right"
|
||||
else:
|
||||
hurt_anim = "hurt_up" if last_direction.y < 0 else "hurt_down"
|
||||
animated_sprite_2d.sprite_frames.set_animation_loop(hurt_anim, false)
|
||||
animated_sprite_2d.play(hurt_anim)
|
||||
await animated_sprite_2d.animation_finished
|
||||
is_hurt = false
|
||||
|
||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||
if is_dying or is_hurt:
|
||||
return
|
||||
if body == player:
|
||||
die()
|
||||
hit()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ extends CharacterBody2D
|
|||
@export var drop_table: Array[DropTable]
|
||||
|
||||
var is_dying = false
|
||||
var is_hurt = false
|
||||
var hits_remaining = 1
|
||||
var speed
|
||||
var witch
|
||||
var player
|
||||
|
|
@ -17,7 +19,7 @@ func _ready() -> void:
|
|||
died.connect(get_node("/root/Game/DropManager").on_enemy_died)
|
||||
witch = get_node("/root/Game/Witch")
|
||||
player = get_node("/root/Game/Player")
|
||||
pass # Replace with function body
|
||||
animated_sprite_2d.sprite_frames = animated_sprite_2d.sprite_frames.duplicate()
|
||||
|
||||
func die():
|
||||
is_dying = true
|
||||
|
|
@ -38,7 +40,26 @@ func die():
|
|||
await animated_sprite_2d.animation_finished
|
||||
queue_free()
|
||||
|
||||
func hit() -> void:
|
||||
if is_dying or is_hurt:
|
||||
return
|
||||
hits_remaining -= 1
|
||||
if hits_remaining <= 0:
|
||||
die()
|
||||
else:
|
||||
_play_hurt()
|
||||
|
||||
func _play_hurt() -> void:
|
||||
is_hurt = true
|
||||
var hurt_anim: String
|
||||
if abs(last_direction.x) >= abs(last_direction.y):
|
||||
hurt_anim = "hurt_left" if last_direction.x < 0 else "hurt_right"
|
||||
else:
|
||||
hurt_anim = "hurt_up" if last_direction.y < 0 else "hurt_down"
|
||||
animated_sprite_2d.sprite_frames.set_animation_loop(hurt_anim, false)
|
||||
animated_sprite_2d.play(hurt_anim)
|
||||
await animated_sprite_2d.animation_finished
|
||||
is_hurt = false
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
|
|
|
|||
|
|
@ -2,39 +2,39 @@ extends ProjectileBase
|
|||
|
||||
var enemies_hit = 0
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
speed = 500
|
||||
super()
|
||||
var first = get_nearest_enemy(global_position)
|
||||
if first == null:
|
||||
queue_free()
|
||||
return
|
||||
launch(first.global_position)
|
||||
speed = 500
|
||||
super()
|
||||
var first = get_nearest_enemy(global_position)
|
||||
if first == null:
|
||||
queue_free()
|
||||
return
|
||||
launch(first.global_position)
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if body.is_in_group("enemies"):
|
||||
enemies_hit += 1
|
||||
body.die()
|
||||
if enemies_hit == 20:
|
||||
queue_free()
|
||||
else:
|
||||
var next = get_nearest_enemy(global_position, body)
|
||||
if next == null:
|
||||
queue_free()
|
||||
else:
|
||||
launch(next.global_position)
|
||||
if body.is_in_group("enemies"):
|
||||
enemies_hit += 1
|
||||
body.hit()
|
||||
if enemies_hit == 20:
|
||||
queue_free()
|
||||
else:
|
||||
var next = get_nearest_enemy(global_position, body)
|
||||
if next == null:
|
||||
queue_free()
|
||||
else:
|
||||
launch(next.global_position)
|
||||
|
||||
func get_nearest_enemy(from: Vector2, exclude: Node = null) -> Node:
|
||||
var nearest = null
|
||||
var min_distance = INF
|
||||
for enemy in get_tree().get_nodes_in_group("enemies"):
|
||||
if enemy == exclude or enemy.is_dying:
|
||||
continue
|
||||
var dist = from.distance_to(enemy.global_position)
|
||||
if dist < min_distance:
|
||||
min_distance = dist
|
||||
nearest = enemy
|
||||
return nearest
|
||||
|
||||
|
||||
var nearest = null
|
||||
var min_distance = INF
|
||||
for enemy in get_tree().get_nodes_in_group("enemies"):
|
||||
if enemy == exclude or enemy.is_dying:
|
||||
continue
|
||||
var dist = from.distance_to(enemy.global_position)
|
||||
if dist < min_distance:
|
||||
min_distance = dist
|
||||
nearest = enemy
|
||||
return nearest
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue