godot-4.1.1
John Montagu, the 4th Earl of Sandvich 2023-08-02 01:59:37 -07:00
parent 5dc8015dbf
commit 8a7a6b2d9e
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
6 changed files with 94 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=58 format=3 uid="uid://b2254pup8k161"] [gd_scene load_steps=60 format=3 uid="uid://b2254pup8k161"]
[ext_resource type="Script" path="res://Characters/Player.cs" id="1_flygr"] [ext_resource type="Script" path="res://Characters/Player.cs" id="1_flygr"]
[ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_ngsgt"] [ext_resource type="Shader" path="res://Shaders/Flash.gdshader" id="2_ngsgt"]
@ -12,6 +12,7 @@
[ext_resource type="Script" path="res://Utils/AnimationManager.cs" id="7_sdgvb"] [ext_resource type="Script" path="res://Utils/AnimationManager.cs" id="7_sdgvb"]
[ext_resource type="Script" path="res://Items/Inventory.cs" id="7_xyenu"] [ext_resource type="Script" path="res://Items/Inventory.cs" id="7_xyenu"]
[ext_resource type="Script" path="res://State/Character/PlayerRollState.cs" id="8_fy0v5"] [ext_resource type="Script" path="res://State/Character/PlayerRollState.cs" id="8_fy0v5"]
[ext_resource type="Script" path="res://State/Character/PlayerEmoteState.cs" id="8_hd2lw"]
[ext_resource type="Animation" uid="uid://8e8r3y1imvsx" path="res://Assets/Animations/stun.res" id="8_m08fh"] [ext_resource type="Animation" uid="uid://8e8r3y1imvsx" path="res://Assets/Animations/stun.res" id="8_m08fh"]
[ext_resource type="Material" uid="uid://x5qcq5muvc3g" path="res://Assets/Sprites/Particles/PlayerDamageProcessMaterial.tres" id="8_yf112"] [ext_resource type="Material" uid="uid://x5qcq5muvc3g" path="res://Assets/Sprites/Particles/PlayerDamageProcessMaterial.tres" id="8_yf112"]
[ext_resource type="Texture2D" uid="uid://c1a7lvb4uuwfy" path="res://Assets/Sprites/Particles/circle-16.png" id="9_7gumm"] [ext_resource type="Texture2D" uid="uid://c1a7lvb4uuwfy" path="res://Assets/Sprites/Particles/circle-16.png" id="9_7gumm"]
@ -59,6 +60,18 @@ tracks/1/keys = {
"update": 0, "update": 0,
"values": [0.0] "values": [0.0]
} }
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("%Sprites/Node2D/Character:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
[sub_resource type="Animation" id="Animation_mg66i"] [sub_resource type="Animation" id="Animation_mg66i"]
resource_name = "idle" resource_name = "idle"
@ -144,9 +157,28 @@ tracks/0/keys = {
"values": [10, 0] "values": [10, 0]
} }
[sub_resource type="Animation" id="Animation_xt1sg"]
resource_name = "emote"
length = 2.12501
loop_mode = 1
step = 0.125
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("%Sprites/Node2D/Character:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875, 2),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
"update": 1,
"values": [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_0tohi"] [sub_resource type="AnimationLibrary" id="AnimationLibrary_0tohi"]
_data = { _data = {
"RESET": SubResource("Animation_imqdv"), "RESET": SubResource("Animation_imqdv"),
"emote": SubResource("Animation_xt1sg"),
"idle": SubResource("Animation_mg66i"), "idle": SubResource("Animation_mg66i"),
"move": SubResource("Animation_iyr4r"), "move": SubResource("Animation_iyr4r"),
"roll": SubResource("Animation_vobpw"), "roll": SubResource("Animation_vobpw"),
@ -300,9 +332,10 @@ script = ExtResource("5_rgckv")
InitialState = NodePath("Idle") InitialState = NodePath("Idle")
Character = NodePath("..") Character = NodePath("..")
[node name="Idle" type="Node" parent="StateMachine" node_paths=PackedStringArray("MoveState", "IdleState", "Character")] [node name="Idle" type="Node" parent="StateMachine" node_paths=PackedStringArray("MoveState", "EmoteState", "IdleState", "Character")]
script = ExtResource("6_wkfdm") script = ExtResource("6_wkfdm")
MoveState = NodePath("../Move") MoveState = NodePath("../Move")
EmoteState = NodePath("../Emote")
IdleState = NodePath(".") IdleState = NodePath(".")
Character = NodePath("../..") Character = NodePath("../..")
@ -325,6 +358,11 @@ script = ExtResource("8_fy0v5")
IdleState = NodePath("../Idle") IdleState = NodePath("../Idle")
Character = NodePath("../..") Character = NodePath("../..")
[node name="Emote" type="Node" parent="StateMachine" node_paths=PackedStringArray("IdleState", "Character")]
script = ExtResource("8_hd2lw")
IdleState = NodePath("../Idle")
Character = NodePath("../..")
[node name="Animations" type="Node" parent="."] [node name="Animations" type="Node" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
script = ExtResource("7_sdgvb") script = ExtResource("7_sdgvb")
@ -416,7 +454,7 @@ use_parent_material = true
position = Vector2(0, -8) position = Vector2(0, -8)
texture = ExtResource("4_5vird") texture = ExtResource("4_5vird")
offset = Vector2(0, -4) offset = Vector2(0, -4)
hframes = 18 hframes = 35
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -4) position = Vector2(0, -4)

View File

@ -0,0 +1,36 @@
using Godot;
namespace SupaLidlGame.State.Character;
public partial class PlayerEmoteState : PlayerState
{
public override IState<CharacterState> Enter(IState<CharacterState> prevState)
{
if (prevState != this)
{
_player.MovementAnimation.Play("emote");
}
if (!CanEmote(_player))
{
return IdleState;
}
return base.Enter(prevState);
}
public override CharacterState Process(double delta)
{
if (!CanEmote(_player))
{
return IdleState;
}
return base.Process(delta);
}
protected static bool CanEmote(Characters.Player player)
{
return !player.Inventory.IsUsingItem && player.Velocity.IsZeroApprox();
}
}

View File

@ -7,6 +7,9 @@ public partial class PlayerIdleState : PlayerState
[Export] [Export]
public CharacterState MoveState { get; set; } public CharacterState MoveState { get; set; }
[Export]
public PlayerEmoteState EmoteState { get; set; }
public override IState<CharacterState> Enter(IState<CharacterState> previousState) public override IState<CharacterState> Enter(IState<CharacterState> previousState)
{ {
if (previousState is not PlayerMoveState) if (previousState is not PlayerMoveState)
@ -43,6 +46,15 @@ public partial class PlayerIdleState : PlayerState
return base.Enter(previousState); return base.Enter(previousState);
} }
public override CharacterState Input(InputEvent @event)
{
if (@event.IsActionPressed("emote"))
{
return EmoteState;
}
return base.Input(@event);
}
public override CharacterState Process(double delta) public override CharacterState Process(double delta)
{ {
base.Process(delta); base.Process(delta);

View File

@ -104,6 +104,11 @@ equip_3={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":51,"key_label":0,"unicode":51,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":51,"key_label":0,"unicode":51,"echo":false,"script":null)
] ]
} }
emote={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":71,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
[internationalization] [internationalization]