Add defeat animations for Hiro player and Hiro AI

This commit is contained in:
Raxki 2024-09-18 17:42:40 -04:00
parent be343ea543
commit d2d471472a
11 changed files with 362 additions and 15 deletions

BIN
Hiro/Hiro Defeated Nude Sprites Line.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://byc7mqu65fb4a"
path="res://.godot/imported/Hiro Defeated Nude Sprites Line.png-8ce27add5678a69dee590136bd2ef3a5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Hiro/Hiro Defeated Nude Sprites Line.png"
dest_files=["res://.godot/imported/Hiro Defeated Nude Sprites Line.png-8ce27add5678a69dee590136bd2ef3a5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
Hiro/Hiro Defeated Sprites nb.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://06a1bf8kjte6"
path="res://.godot/imported/Hiro Defeated Sprites nb.png-0498112418d31b8cab02894cf6c9c734.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Hiro/Hiro Defeated Sprites nb.png"
dest_files=["res://.godot/imported/Hiro Defeated Sprites nb.png-0498112418d31b8cab02894cf6c9c734.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=55 format=3 uid="uid://dd2km6qhpdicx"]
[gd_scene load_steps=61 format=3 uid="uid://dd2km6qhpdicx"]
[ext_resource type="Script" path="res://Scripts/hiro_ai.gd" id="1_inmen"]
[ext_resource type="Shader" uid="uid://bcnip762rd6yj" path="res://Shaders/character.tres" id="2_6u0oh"]
@ -14,6 +14,9 @@
shader = ExtResource("2_6u0oh")
shader_parameter/FlashColor = Color(1, 0, 0, 0)
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_8ov0j"]
animation = &"player_defeated"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_tyc74"]
animation = &"hurt_west"
@ -138,6 +141,12 @@ blend_point_2/node = SubResource("AnimationNodeBlendSpace2D_mr7t3")
blend_point_2/pos = 1.0
blend_mode = 1
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_0ny5g"]
animation = &"ai_defeated"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_kgin3"]
animation = &"ai_defeated_start"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_17wsb"]
animation = &"walking_north"
@ -184,19 +193,38 @@ advance_mode = 2
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_l5ng5"]
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_86ydq"]
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_yav5y"]
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_b0avg"]
allow_transition_to_self = true
states/End/position = Vector2(1026, 108)
states/Start/position = Vector2(197, 108)
states/defeated/node = SubResource("AnimationNodeAnimation_8ov0j")
states/defeated/position = Vector2(734, 74)
states/hurt/node = SubResource("AnimationNodeBlendSpace2D_h2vkc")
states/hurt/position = Vector2(329, -13)
states/idle/node = SubResource("AnimationNodeBlendSpace2D_bd8j1")
states/idle/position = Vector2(329, 108)
states/melee/node = SubResource("AnimationNodeBlendSpace1D_dc3kp")
states/melee/position = Vector2(329, 224)
states/naked/node = SubResource("AnimationNodeAnimation_0ny5g")
states/naked/position = Vector2(895, 202)
states/naked_start/node = SubResource("AnimationNodeAnimation_kgin3")
states/naked_start/position = Vector2(734, 202)
states/walk/node = SubResource("AnimationNodeBlendSpace2D_vunsg")
states/walk/position = Vector2(520, 108)
transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition_akmuq"), "idle", "walk", SubResource("AnimationNodeStateMachineTransition_sn1tm"), "walk", "idle", SubResource("AnimationNodeStateMachineTransition_5i3fu"), "idle", "melee", SubResource("AnimationNodeStateMachineTransition_y8p74"), "melee", "idle", SubResource("AnimationNodeStateMachineTransition_l17k0"), "hurt", "idle", SubResource("AnimationNodeStateMachineTransition_ln3pc")]
graph_offset = Vector2(-141, 47)
transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition_akmuq"), "idle", "walk", SubResource("AnimationNodeStateMachineTransition_sn1tm"), "walk", "idle", SubResource("AnimationNodeStateMachineTransition_5i3fu"), "idle", "melee", SubResource("AnimationNodeStateMachineTransition_y8p74"), "melee", "idle", SubResource("AnimationNodeStateMachineTransition_l17k0"), "hurt", "idle", SubResource("AnimationNodeStateMachineTransition_ln3pc"), "naked_start", "naked", SubResource("AnimationNodeStateMachineTransition_l5ng5"), "defeated", "End", SubResource("AnimationNodeStateMachineTransition_86ydq"), "naked", "End", SubResource("AnimationNodeStateMachineTransition_yav5y")]
graph_offset = Vector2(273, 34)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_vm050"]
radius = 8.0
@ -249,6 +277,7 @@ parameters/melee/2/blend_position = Vector2(0, 0)
parameters/walk/blend_position = Vector2(-0.0100167, -0.0729166)
[node name="Hitbox" type="Area2D" parent="."]
visible = false
position = Vector2(0, 1)
collision_layer = 2
collision_mask = 10
@ -259,25 +288,30 @@ shape = SubResource("CapsuleShape2D_vm050")
debug_color = Color(1, 0.133333, 0.321569, 0.419608)
[node name="MovementCollider" type="CollisionShape2D" parent="."]
visible = false
position = Vector2(-0.5, -1)
shape = SubResource("RectangleShape2D_bdqvd")
[node name="Attackbox" type="Area2D" parent="."]
visible = false
position = Vector2(0, 1)
collision_layer = 8
collision_mask = 2
input_pickable = false
[node name="Collider" type="CollisionShape2D" parent="Attackbox"]
visible = false
position = Vector2(0, -10)
shape = SubResource("CircleShape2D_md645")
disabled = true
debug_color = Color(0.745098, 0.462745, 0, 0.419608)
[node name="Meleebox" type="Area2D" parent="."]
visible = false
collision_layer = 4
[node name="DetectionArea" type="CollisionShape2D" parent="Meleebox"]
visible = false
position = Vector2(0, -13)
shape = SubResource("CapsuleShape2D_hxosv")
debug_color = Color(0.784314, 0.423529, 0.27451, 0.419608)
@ -292,6 +326,12 @@ initial_state = NodePath("Think")
[node name="Think" type="Node" parent="StateMachine/Root"]
script = ExtResource("8_pqyhf")
[node name="ToVictory" type="Node" parent="StateMachine/Root/Think"]
script = ExtResource("9_la16b")
to = NodePath("../../Victory")
event = &"has_won"
delay_in_seconds = "0.0"
[node name="ToHurt" type="Node" parent="StateMachine/Root/Think"]
script = ExtResource("9_la16b")
to = NodePath("../../Hurt")
@ -321,6 +361,12 @@ delay_in_seconds = "0.0"
[node name="Approach" type="Node" parent="StateMachine/Root"]
script = ExtResource("8_pqyhf")
[node name="ToVictory" type="Node" parent="StateMachine/Root/Approach"]
script = ExtResource("9_la16b")
to = NodePath("../../Victory")
event = &"has_won"
delay_in_seconds = "0.0"
[node name="ToHurt" type="Node" parent="StateMachine/Root/Approach"]
script = ExtResource("9_la16b")
to = NodePath("../../Hurt")
@ -342,6 +388,12 @@ delay_in_seconds = "0.0"
[node name="Chase" type="Node" parent="StateMachine/Root"]
script = ExtResource("8_pqyhf")
[node name="ToVictory" type="Node" parent="StateMachine/Root/Chase"]
script = ExtResource("9_la16b")
to = NodePath("../../Victory")
event = &"has_won"
delay_in_seconds = "0.0"
[node name="ToHurt" type="Node" parent="StateMachine/Root/Chase"]
script = ExtResource("9_la16b")
to = NodePath("../../Hurt")
@ -363,6 +415,12 @@ delay_in_seconds = "0.0"
[node name="Melee" type="Node" parent="StateMachine/Root"]
script = ExtResource("8_pqyhf")
[node name="ToVictory" type="Node" parent="StateMachine/Root/Melee"]
script = ExtResource("9_la16b")
to = NodePath("../../Victory")
event = &"has_won"
delay_in_seconds = "0.0"
[node name="ToHurt" type="Node" parent="StateMachine/Root/Melee"]
script = ExtResource("9_la16b")
to = NodePath("../../Hurt")
@ -408,6 +466,9 @@ delay_in_seconds = "0.0"
[node name="Defeat" type="Node" parent="StateMachine/Root"]
script = ExtResource("8_pqyhf")
[node name="Victory" type="Node" parent="StateMachine/Root"]
script = ExtResource("8_pqyhf")
[connection signal="animation_finished" from="AnimationTree" to="." method="_on_animation_tree_animation_finished"]
[connection signal="area_entered" from="Attackbox" to="." method="_on_attackbox_area_entered"]
[connection signal="body_entered" from="Meleebox" to="." method="_on_meleebox_body_entered"]
@ -430,3 +491,4 @@ script = ExtResource("8_pqyhf")
[connection signal="state_entered" from="StateMachine/Root/HurtReposition" to="." method="_on_hurt_reposition_state_entered"]
[connection signal="state_exited" from="StateMachine/Root/HurtReposition" to="." method="_on_hurt_reposition_state_exited"]
[connection signal="state_entered" from="StateMachine/Root/Defeat" to="." method="_on_defeat_state_entered"]
[connection signal="state_entered" from="StateMachine/Root/Victory" to="." method="_on_victory_state_entered"]

View file

@ -1,8 +1,10 @@
[gd_resource type="AnimationLibrary" load_steps=29 format=3 uid="uid://dincs5x4qucal"]
[gd_resource type="AnimationLibrary" load_steps=34 format=3 uid="uid://dincs5x4qucal"]
[ext_resource type="Texture2D" uid="uid://cm7tgomrcvq30" path="res://Hiro/Hiro Walk Sprite Cycle Line Up.png" id="1_hc7kj"]
[ext_resource type="Texture2D" uid="uid://rcidedgcjqg6" path="res://Hiro/Hiro Hurt Sprites.png" id="2_2k6ad"]
[ext_resource type="Texture2D" uid="uid://bio3egs7q7wog" path="res://Hiro/Hiro Melee Sprites.png" id="3_5swnw"]
[ext_resource type="Texture2D" uid="uid://06a1bf8kjte6" path="res://Hiro/Hiro Defeated Sprites nb.png" id="4_fugxd"]
[ext_resource type="Texture2D" uid="uid://byc7mqu65fb4a" path="res://Hiro/Hiro Defeated Nude Sprites Line.png" id="5_0f03l"]
[sub_resource type="Animation" id="Animation_04piu"]
length = 0.001
@ -1855,9 +1857,194 @@ tracks/3/keys = {
"values": [ExtResource("1_hc7kj")]
}
[sub_resource type="Animation" id="Animation_g1svr"]
resource_name = "player_defeated"
length = 0.83335
step = 0.166667
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_fugxd")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite2D:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [5]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite2D:vframes")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Sprite2D:frame")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 0.166667, 0.333333, 0.5),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 1,
"values": [1, 2, 3, 4]
}
[sub_resource type="Animation" id="Animation_ry0wg"]
resource_name = "ai_defeated"
length = 1.00003
step = 0.25
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("5_0f03l")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite2D:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [5]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite2D:vframes")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Sprite2D:frame")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 1,
"values": [1, 2, 3, 4, 0]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("Sprite2D:material:shader_parameter/FlashColor")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 0, 0, 0)]
}
[sub_resource type="Animation" id="Animation_d06fy"]
resource_name = "ai_defeated_start"
length = 0.571443
step = 0.142857
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("5_0f03l")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Sprite2D:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [5]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Sprite2D:vframes")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Sprite2D:frame")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("Sprite2D:material:shader_parameter/FlashColor")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 0, 0, 0)]
}
[resource]
_data = {
"RESET": SubResource("Animation_04piu"),
"ai_defeated": SubResource("Animation_ry0wg"),
"ai_defeated_start": SubResource("Animation_d06fy"),
"hurt_east": SubResource("Animation_kvnht"),
"hurt_north": SubResource("Animation_fytkh"),
"hurt_south": SubResource("Animation_lw5of"),
@ -1870,6 +2057,7 @@ _data = {
"kick_north": SubResource("Animation_cuaji"),
"kick_south": SubResource("Animation_hqga6"),
"kick_west": SubResource("Animation_s8xim"),
"player_defeated": SubResource("Animation_g1svr"),
"punch_east_left": SubResource("Animation_o0diw"),
"punch_east_rigth": SubResource("Animation_ar6r3"),
"punch_north_left": SubResource("Animation_1e0v6"),

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=47 format=3 uid="uid://di21xheryhp0k"]
[gd_scene load_steps=49 format=3 uid="uid://di21xheryhp0k"]
[ext_resource type="Script" path="res://Scripts/hiro_player.gd" id="1_dtymi"]
[ext_resource type="Texture2D" uid="uid://cm7tgomrcvq30" path="res://Hiro/Hiro Walk Sprite Cycle Line Up.png" id="1_ukwcc"]
@ -10,6 +10,9 @@ resource_local_to_scene = true
shader = ExtResource("2_tyej0")
shader_parameter/FlashColor = Color(1, 0, 0, 0)
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_luptt"]
animation = &"player_defeated"
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_tyc74"]
animation = &"hurt_west"
@ -180,9 +183,15 @@ advance_mode = 2
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_ouche"]
switch_mode = 2
advance_mode = 2
[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_b2867"]
allow_transition_to_self = true
states/Start/position = Vector2(197, 108)
states/defeated/node = SubResource("AnimationNodeAnimation_luptt")
states/defeated/position = Vector2(748, 100)
states/hurt/node = SubResource("AnimationNodeBlendSpace2D_h2vkc")
states/hurt/position = Vector2(329, -13)
states/idle/node = SubResource("AnimationNodeBlendSpace2D_bd8j1")
@ -191,8 +200,8 @@ states/melee/node = SubResource("AnimationNodeBlendSpace1D_dc3kp")
states/melee/position = Vector2(329, 224)
states/walk/node = SubResource("AnimationNodeBlendSpace2D_vunsg")
states/walk/position = Vector2(520, 108)
transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition_akmuq"), "idle", "walk", SubResource("AnimationNodeStateMachineTransition_sn1tm"), "walk", "idle", SubResource("AnimationNodeStateMachineTransition_5i3fu"), "idle", "melee", SubResource("AnimationNodeStateMachineTransition_y8p74"), "melee", "idle", SubResource("AnimationNodeStateMachineTransition_l17k0"), "hurt", "idle", SubResource("AnimationNodeStateMachineTransition_ln3pc")]
graph_offset = Vector2(-239, -26)
transitions = ["Start", "idle", SubResource("AnimationNodeStateMachineTransition_akmuq"), "idle", "walk", SubResource("AnimationNodeStateMachineTransition_sn1tm"), "walk", "idle", SubResource("AnimationNodeStateMachineTransition_5i3fu"), "idle", "melee", SubResource("AnimationNodeStateMachineTransition_y8p74"), "melee", "idle", SubResource("AnimationNodeStateMachineTransition_l17k0"), "hurt", "idle", SubResource("AnimationNodeStateMachineTransition_ln3pc"), "defeated", "End", SubResource("AnimationNodeStateMachineTransition_ouche")]
graph_offset = Vector2(-164, -94)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_vm050"]
radius = 8.0
@ -232,7 +241,6 @@ parameters/melee/2/blend_position = Vector2(0, 0)
parameters/walk/blend_position = Vector2(-0.0100167, -0.0729166)
[node name="Hitbox" type="Area2D" parent="."]
visible = false
position = Vector2(0, 1)
collision_layer = 2
collision_mask = 10
@ -243,7 +251,6 @@ shape = SubResource("CapsuleShape2D_vm050")
debug_color = Color(1, 0.133333, 0.321569, 0.419608)
[node name="MovementCollider" type="CollisionShape2D" parent="."]
visible = false
position = Vector2(-0.5, -1)
shape = SubResource("RectangleShape2D_bdqvd")

View file

@ -4,6 +4,7 @@ extends CharacterBody2D
@export var player_character: PlayableCharacter
@export var health = 100
@export var attack_power = 30
@export var nsfw = true
@export var KNOCKBACK_POWER = 40
@export var KNOCKBACK_REPOSITION_POWER = 75
@export var KNOCKBACK_RANDOMNESS = 50
@ -142,7 +143,10 @@ func _on_animation_tree_animation_finished(anim_name):
state_machine.send_event("melee_complete")
func _on_defeat_state_entered():
queue_free()
if nsfw:
anim_playback.travel("naked_start")
else:
anim_playback.travel("defeated")
## Aproaching
func _on_approach_state_entered():
@ -206,3 +210,14 @@ func _on_melee_state_exited():
func _on_attackbox_area_entered(area):
attack_did_hit.emit(area, attack_power, anim_tree.get("parameters/melee/0/blend_position"))
func _on_victory_state_entered():
wants_to_melee = false
anim_tree.set("parameters/conditions/melee", false)
state_machine.set_expression_property("melee_stage", 0)
velocity = Vector2.ZERO
func _on_player_been_defeated():
state_machine.send_event("has_won")

View file

@ -10,6 +10,8 @@ const FACING_ANGLE_EPSILON = 15
var can_move = true
@onready var animation_playback: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
signal attack_did_hit(other: Area2D, power: int, attack_direction: Vector2)
signal defeated
@ -82,7 +84,7 @@ func _on_enemy_attack_did_hit(other, power, attack_direction):
health = health - power
can_move = false
if health <= 0:
print("Nooooooooooooo!!")
animation_playback.travel("defeated")
defeated.emit()
velocity = Vector2.ZERO
else:
@ -90,9 +92,7 @@ func _on_enemy_attack_did_hit(other, power, attack_direction):
set_animation_direction(facing_direction)
var knockback_direction = attack_direction.rotated(deg_to_rad(randf_range(-1, 1) * KNOCKBACK_RANDOMNESS))
velocity = KNOCKBACK_POWER * knockback_direction.normalized()
var playback: AnimationNodeStateMachinePlayback = $AnimationTree.get("parameters/playback")
playback.travel("hurt")
animation_playback.travel("hurt")
$AnimationTree.set("parameters/conditions/melee", false)
func _on_animation_tree_animation_finished(anim_name):

View file

@ -42,7 +42,7 @@ void fragment() {
}
"
graph_offset = Vector2(-103.937, -135.818)
graph_offset = Vector2(-122.937, -65.8182)
mode = 1
flags/light_only = false
nodes/fragment/0/position = Vector2(600, -60)

View file

@ -47,4 +47,5 @@ player_character = NodePath("../HiroPlayer")
attack_power = 5
[connection signal="attack_did_hit" from="HiroPlayer" to="HiroAI" method="_on_player_attack_did_hit"]
[connection signal="defeated" from="HiroPlayer" to="HiroAI" method="_on_player_been_defeated"]
[connection signal="attack_did_hit" from="HiroAI" to="HiroPlayer" method="_on_enemy_attack_did_hit"]