Add basic implementation for footsteps

Add disengage to eden pillar
Fix level up sound effect trigger
This commit is contained in:
2025-11-26 02:33:03 -08:00
parent ed9e611fd9
commit 46402401b4
6 changed files with 33 additions and 6 deletions

View File

@@ -52,6 +52,7 @@ public class ExperiencePointsComponent : IExperiencePointsComponent
public void LevelUp() public void LevelUp()
{ {
SfxDatabase.Instance.Play(SoundEffect.LevelUp);
_level.OnNext(_level.Value + 1); _level.OnNext(_level.Value + 1);
var expToNextLevel = ExpToNextLevelCalculation(_level.Value); var expToNextLevel = ExpToNextLevelCalculation(_level.Value);
_currentExp.OnNext(_currentExp.Value - _expToNextLevel.Value); _currentExp.OnNext(_currentExp.Value - _expToNextLevel.Value);

View File

@@ -12,8 +12,8 @@ dest_files=["res://.godot/imported/player_steps_concrete.ogg-2210939b45b35c9b2fc
[params] [params]
loop=false loop=true
loop_offset=0 loop_offset=0.0
bpm=0 bpm=0.0
beat_count=0 beat_count=0
bar_beats=4 bar_beats=4

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://cmvimr0pvsgqy"] [gd_scene load_steps=17 format=3 uid="uid://cmvimr0pvsgqy"]
[ext_resource type="Script" uid="uid://d2m7esc5ypl7y" path="res://src/enemy/enemy_types/10. Eden Pillar/EdenPillar.cs" id="1_p8jc1"] [ext_resource type="Script" uid="uid://d2m7esc5ypl7y" path="res://src/enemy/enemy_types/10. Eden Pillar/EdenPillar.cs" id="1_p8jc1"]
[ext_resource type="PackedScene" uid="uid://cktycana6xxtp" path="res://src/enemy/enemy_types/10. Eden Pillar/EdenPillarModelView.tscn" id="3_o285m"] [ext_resource type="PackedScene" uid="uid://cktycana6xxtp" path="res://src/enemy/enemy_types/10. Eden Pillar/EdenPillarModelView.tscn" id="3_o285m"]
@@ -27,6 +27,9 @@ radius = 0.886719
[sub_resource type="CylinderShape3D" id="CylinderShape3D_xdeci"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_xdeci"]
radius = 7.98633 radius = 7.98633
[sub_resource type="CylinderShape3D" id="CylinderShape3D_t4xb3"]
radius = 20.0
[node name="Eden Pillar" type="CharacterBody3D"] [node name="Eden Pillar" type="CharacterBody3D"]
collision_layer = 10 collision_layer = 10
collision_mask = 0 collision_mask = 0
@@ -131,3 +134,11 @@ collision_mask = 32
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerDetector"] [node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerDetector"]
shape = SubResource("CylinderShape3D_xdeci") shape = SubResource("CylinderShape3D_xdeci")
[node name="LoseTrackOfPlayer" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 0
collision_mask = 32
[node name="CollisionShape3D" type="CollisionShape3D" parent="LoseTrackOfPlayer"]
shape = SubResource("CylinderShape3D_t4xb3")

View File

@@ -38,6 +38,8 @@ public partial class EdenPillar : Enemy3D, IHasPrimaryAttack, IHasSecondaryAttac
[Node] public Area3D PlayerDetector { get; set; } = default!; [Node] public Area3D PlayerDetector { get; set; } = default!;
[Node] public Area3D LoseTrackOfPlayer { get; set; } = default!;
[Node] public EngagePlayerBehavior EngagePlayerBehavior { get; set; } = default!; [Node] public EngagePlayerBehavior EngagePlayerBehavior { get; set; } = default!;
@@ -50,10 +52,13 @@ public partial class EdenPillar : Enemy3D, IHasPrimaryAttack, IHasSecondaryAttac
public void OnReady() public void OnReady()
{ {
PlayerDetector.BodyEntered += PlayerDetector_BodyEntered; PlayerDetector.BodyEntered += PlayerDetector_BodyEntered;
LoseTrackOfPlayer.BodyExited += LoseTrackOfPlayer_BodyExited;
EngagePlayerBehavior.TakeAction += PerformAction; EngagePlayerBehavior.TakeAction += PerformAction;
HealthComponent.HealthReachedZero += HealthComponent_HealthReachedZero; HealthComponent.HealthReachedZero += HealthComponent_HealthReachedZero;
} }
private void LoseTrackOfPlayer_BodyExited(Node3D body) => EngagePlayerBehavior.Disengage();
private void HealthComponent_HealthReachedZero() private void HealthComponent_HealthReachedZero()
{ {
StoneRotation.Stop(); StoneRotation.Stop();

View File

@@ -81,6 +81,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
[Node] private Timer HealthTimer { get; set; } = default!; [Node] private Timer HealthTimer { get; set; } = default!;
[Node] private RigidBody3D WallCheck { get; set; } = default!; [Node] private RigidBody3D WallCheck { get; set; } = default!;
[Node] private AudioStreamPlayer3D WalkSFX { get; set; } = default!;
#endregion #endregion
@@ -207,7 +209,6 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
var hpIncrease = rng.RandiRange(3, 6); var hpIncrease = rng.RandiRange(3, 6);
HealthComponent.RaiseMaximumHP(hpIncrease); HealthComponent.RaiseMaximumHP(hpIncrease);
ExperiencePointsComponent.LevelUp(); ExperiencePointsComponent.LevelUp();
SfxDatabase.Instance.Play(SoundEffect.LevelUp);
} }
public void Die() public void Die()
@@ -324,6 +325,10 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
_knockbackStrength *= 0.9f; _knockbackStrength *= 0.9f;
Transform = Transform with { Basis = transform.Basis }; Transform = Transform with { Basis = transform.Basis };
Velocity = velocity + (_knockbackDirection * _knockbackStrength); Velocity = velocity + (_knockbackDirection * _knockbackStrength);
if (!WalkSFX.Playing && !Velocity.IsZeroApprox())
WalkSFX.Play();
else if (Velocity.IsZeroApprox())
WalkSFX.Stop();
MoveAndSlide(); MoveAndSlide();
} }

View File

@@ -1,10 +1,11 @@
[gd_scene load_steps=54 format=3 uid="uid://cfecvvav8kkp6"] [gd_scene load_steps=55 format=3 uid="uid://cfecvvav8kkp6"]
[ext_resource type="Script" uid="uid://yxmiqy7i0t7r" path="res://src/player/Player.cs" id="1_xcol5"] [ext_resource type="Script" uid="uid://yxmiqy7i0t7r" path="res://src/player/Player.cs" id="1_xcol5"]
[ext_resource type="AudioStream" uid="uid://cth2xgoqhdf0m" path="res://src/audio/sfx/player_hit_wall.ogg" id="3_565yv"] [ext_resource type="AudioStream" uid="uid://cth2xgoqhdf0m" path="res://src/audio/sfx/player_hit_wall.ogg" id="3_565yv"]
[ext_resource type="Texture2D" uid="uid://c4ps26w7h3vpq" path="res://src/minimap/textures/player_map_icon.png" id="4_3ojaj"] [ext_resource type="Texture2D" uid="uid://c4ps26w7h3vpq" path="res://src/minimap/textures/player_map_icon.png" id="4_3ojaj"]
[ext_resource type="Texture2D" uid="uid://2ig1arptr1e8" path="res://src/vfx/Items Etc/slash_2.png" id="4_v7rlw"] [ext_resource type="Texture2D" uid="uid://2ig1arptr1e8" path="res://src/vfx/Items Etc/slash_2.png" id="4_v7rlw"]
[ext_resource type="Texture2D" uid="uid://qhxl3nejqlk1" path="res://src/vfx/World/DUST_1.png" id="5_v5qoq"] [ext_resource type="Texture2D" uid="uid://qhxl3nejqlk1" path="res://src/vfx/World/DUST_1.png" id="5_v5qoq"]
[ext_resource type="AudioStream" uid="uid://bsprdc3ka6am0" path="res://src/audio/sfx/player_steps_concrete.ogg" id="6_v7rlw"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_dw45s"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_dw45s"]
radius = 1.0 radius = 1.0
@@ -631,3 +632,7 @@ animation = &"sample"
[node name="HitWallSound" type="AudioStreamPlayer" parent="."] [node name="HitWallSound" type="AudioStreamPlayer" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
bus = &"SFX" bus = &"SFX"
[node name="WalkSFX" type="AudioStreamPlayer3D" parent="."]
unique_name_in_owner = true
stream = ExtResource("6_v7rlw")