diff --git a/game/src/AI/EnemyPassivePatrol.tscn b/game/src/AI/EnemyPassivePatrol.tscn index c1ffc1f..c3a5aa8 100644 --- a/game/src/AI/EnemyPassivePatrol.tscn +++ b/game/src/AI/EnemyPassivePatrol.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=13 format=2] [ext_resource path="res://src/AI/EnemyPassivePatrol.gd" type="Script" id=1] [ext_resource path="res://src/Combat/DamageSource.gd" type="Script" id=2] @@ -16,6 +16,33 @@ extents = Vector2( 50, 20 ) [sub_resource type="CircleShape2D" id=2] radius = 33.0 +[sub_resource type="Animation" id=3] +resource_name = "FadeOut" +tracks/0/type = "value" +tracks/0/path = NodePath("../../Body:color_fill") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.2, 1 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 0, +"values": [ Color( 0.615686, 0, 1, 1 ), Color( 1, 0, 0, 0.8 ), Color( 1, 0, 0, 0 ) ] +} +tracks/1/type = "value" +tracks/1/path = NodePath("../../Body:color_outline") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/keys = { +"times": PoolRealArray( 0, 1 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Color( 0.270588, 0.0745098, 0.619608, 1 ), Color( 0.270588, 0.0745098, 0.619608, 0 ) ] +} + [node name="EnemyPassivePatrol" type="KinematicBody2D"] collision_layer = 16 collision_mask = 2 @@ -42,7 +69,8 @@ shape = SubResource( 2 ) [node name="Body" type="Node2D" parent="."] script = ExtResource( 4 ) size = Vector2( 100, 40 ) -color_fill = Color( 0.384314, 0.368627, 0.929412, 1 ) +outline = Vector2( 6, 6 ) +color_fill = Color( 0.615686, 0, 1, 1 ) color_outline = Color( 0.270588, 0.0745098, 0.619608, 1 ) [node name="StateMachine" type="Node" parent="."] @@ -54,7 +82,6 @@ script = ExtResource( 6 ) [node name="Hooked" type="Node" parent="StateMachine"] script = ExtResource( 7 ) -state_when_struck = "Stunned" hooked_color = Color( 0.886275, 0.415686, 0.133333, 1 ) [node name="Stunned" type="Node" parent="StateMachine"] @@ -65,4 +92,7 @@ next_state = "Destroyed" script = ExtResource( 9 ) hurt_color = Color( 1, 0, 0, 1 ) +[node name="AnimationPlayer" type="AnimationPlayer" parent="StateMachine/Destroyed"] +anims/FadeOut = SubResource( 3 ) + [editable path="HookTarget"] diff --git a/game/src/AI/States/Destroyed.gd b/game/src/AI/States/Destroyed.gd index 6edc436..8abd9f6 100644 --- a/game/src/AI/States/Destroyed.gd +++ b/game/src/AI/States/Destroyed.gd @@ -10,21 +10,7 @@ export var hurt_color: Color func enter(msg: Dictionary = {}) -> void: owner.hook_target.set_color(Color(0, 0, 0, 0)) owner.body.set_color_fill(hurt_color) - - yield(do_color(), "completed") - - owner.queue_free() - - -func do_color() -> void: - var start_fill_color: Color = owner.body.color_fill - var start_outline_color: Color = owner.body.color_outline - - for i in range(0, 30): - start_fill_color.a = lerp(1, 0, i / 30.0) - start_outline_color.a = lerp(1, 0, i / 30.0) - - owner.body.set_color_fill(start_fill_color) - owner.body.set_color_outline(start_outline_color) - - yield(get_tree(), "idle_frame") \ No newline at end of file + var animation_player: AnimationPlayer = $AnimationPlayer + animation_player.play("FadeOut") + yield(animation_player, "animation_finished") + owner.queue_free() \ No newline at end of file diff --git a/game/src/AI/States/Hooked.gd b/game/src/AI/States/Hooked.gd index 998008c..1fc7a0f 100644 --- a/game/src/AI/States/Hooked.gd +++ b/game/src/AI/States/Hooked.gd @@ -6,7 +6,6 @@ It simply waits until the player body collides with the hitbox, colors the body, """ -export var state_when_struck: String export var hooked_color: Color @@ -16,4 +15,4 @@ func enter(msg: Dictionary = {}) -> void: func _on_Player_body_entered(body: Player) -> void: - _state_machine.transition_to(state_when_struck, {player = body}) \ No newline at end of file + _state_machine.transition_to("Stunned", {player = body}) \ No newline at end of file diff --git a/game/src/AI/States/HorizontalPatrol.gd b/game/src/AI/States/HorizontalPatrol.gd index 2117b49..e818646 100644 --- a/game/src/AI/States/HorizontalPatrol.gd +++ b/game/src/AI/States/HorizontalPatrol.gd @@ -12,7 +12,7 @@ onready var _direction: int = owner.direction func enter(msg: Dictionary = {}) -> void: owner.hook_target.connect("hooked_onto_from", self, "_on_Hook_hooked_onto_from", [], CONNECT_ONESHOT) owner.hitbox.connect("body_entered", self, "_on_Player_body_entered") - owner.hook_target.set_is_active(true) + owner.hook_target.is_active = true func exit() -> void: