Add wall hit sound and animation
This commit is contained in:
@@ -19,6 +19,10 @@ public interface IGameRepo : IDisposable
|
|||||||
|
|
||||||
event Action<InventoryItem>? RemoveItemFromInventoryEvent;
|
event Action<InventoryItem>? RemoveItemFromInventoryEvent;
|
||||||
|
|
||||||
|
event Action? PlayerAttack;
|
||||||
|
|
||||||
|
event Action? PlayerAttackedWall;
|
||||||
|
|
||||||
void Pause();
|
void Pause();
|
||||||
|
|
||||||
void Resume();
|
void Resume();
|
||||||
@@ -35,6 +39,10 @@ public interface IGameRepo : IDisposable
|
|||||||
|
|
||||||
public void RemoveItemFromInventory(InventoryItem item);
|
public void RemoveItemFromInventory(InventoryItem item);
|
||||||
|
|
||||||
|
public void OnPlayerAttack();
|
||||||
|
|
||||||
|
public void OnPlayerAttackedWall();
|
||||||
|
|
||||||
public void CloseInventory();
|
public void CloseInventory();
|
||||||
|
|
||||||
public void GameEnded();
|
public void GameEnded();
|
||||||
@@ -51,6 +59,8 @@ public class GameRepo : IGameRepo
|
|||||||
public event Action<int>? DoubleExpTimeStart;
|
public event Action<int>? DoubleExpTimeStart;
|
||||||
public event Action? DoubleExpTimeEnd;
|
public event Action? DoubleExpTimeEnd;
|
||||||
public event Action<InventoryItem>? RemoveItemFromInventoryEvent;
|
public event Action<InventoryItem>? RemoveItemFromInventoryEvent;
|
||||||
|
public event Action? PlayerAttack;
|
||||||
|
public event Action? PlayerAttackedWall;
|
||||||
|
|
||||||
public IAutoProp<bool> IsPaused => _isPaused;
|
public IAutoProp<bool> IsPaused => _isPaused;
|
||||||
private readonly AutoProp<bool> _isPaused;
|
private readonly AutoProp<bool> _isPaused;
|
||||||
@@ -105,6 +115,16 @@ public class GameRepo : IGameRepo
|
|||||||
RemoveItemFromInventoryEvent?.Invoke(item);
|
RemoveItemFromInventoryEvent?.Invoke(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnPlayerAttack()
|
||||||
|
{
|
||||||
|
PlayerAttack?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPlayerAttackedWall()
|
||||||
|
{
|
||||||
|
PlayerAttackedWall?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
public void CloseInventory()
|
public void CloseInventory()
|
||||||
{
|
{
|
||||||
CloseInventoryEvent?.Invoke();
|
CloseInventoryEvent?.Invoke();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Chickensoft.GodotNodeInterfaces;
|
|||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Zennysoft.Game.Abstractions;
|
using Zennysoft.Game.Abstractions;
|
||||||
|
using Zennysoft.Ma.Adapter;
|
||||||
|
|
||||||
namespace Zennysoft.Game.Ma;
|
namespace Zennysoft.Game.Ma;
|
||||||
|
|
||||||
@@ -17,6 +18,8 @@ public partial class InGameAudio : Node
|
|||||||
|
|
||||||
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
||||||
|
|
||||||
|
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||||
|
|
||||||
#region BGM Nodes
|
#region BGM Nodes
|
||||||
[Node] public IDimmableAudioStreamPlayer MenuBgm { get; set; } = default!;
|
[Node] public IDimmableAudioStreamPlayer MenuBgm { get; set; } = default!;
|
||||||
|
|
||||||
@@ -32,6 +35,8 @@ public partial class InGameAudio : Node
|
|||||||
#region SFX Nodes
|
#region SFX Nodes
|
||||||
[Node] public IAudioStreamPlayer PlayerAttackSFX { get; set; } = default!;
|
[Node] public IAudioStreamPlayer PlayerAttackSFX { get; set; } = default!;
|
||||||
|
|
||||||
|
[Node] public IAudioStreamPlayer PlayerAttackWallSFX { get; set; } = default!;
|
||||||
|
|
||||||
[Node] public IAudioStreamPlayer MenuScrollSFX { get; set; } = default!;
|
[Node] public IAudioStreamPlayer MenuScrollSFX { get; set; } = default!;
|
||||||
|
|
||||||
[Node] public IAudioStreamPlayer EquipSFX { get; set; } = default!;
|
[Node] public IAudioStreamPlayer EquipSFX { get; set; } = default!;
|
||||||
@@ -58,6 +63,7 @@ public partial class InGameAudio : Node
|
|||||||
InGameAudioLogic.Set(AppRepo);
|
InGameAudioLogic.Set(AppRepo);
|
||||||
InGameAudioLogic.Set(GameEventDepot);
|
InGameAudioLogic.Set(GameEventDepot);
|
||||||
InGameAudioLogic.Set(Player);
|
InGameAudioLogic.Set(Player);
|
||||||
|
InGameAudioLogic.Set(GameRepo);
|
||||||
|
|
||||||
InGameAudioBinding = InGameAudioLogic.Bind();
|
InGameAudioBinding = InGameAudioLogic.Bind();
|
||||||
|
|
||||||
@@ -69,7 +75,9 @@ public partial class InGameAudio : Node
|
|||||||
.Handle((in InGameAudioLogic.Output.PlayMenuBackSound _) => PlayMenuBackSound())
|
.Handle((in InGameAudioLogic.Output.PlayMenuBackSound _) => PlayMenuBackSound())
|
||||||
.Handle((in InGameAudioLogic.Output.PlayInventorySortedSound _) => PlayInventorySortedSound())
|
.Handle((in InGameAudioLogic.Output.PlayInventorySortedSound _) => PlayInventorySortedSound())
|
||||||
.Handle((in InGameAudioLogic.Output.PlayHealingItemSound _) => PlayHealingItemSound())
|
.Handle((in InGameAudioLogic.Output.PlayHealingItemSound _) => PlayHealingItemSound())
|
||||||
.Handle((in InGameAudioLogic.Output.PlayTeleportSound _) => PlayTeleportSound());
|
.Handle((in InGameAudioLogic.Output.PlayTeleportSound _) => PlayTeleportSound())
|
||||||
|
.Handle((in InGameAudioLogic.Output.PlayPlayerAttackSound _) => { PlayerAttackSFX.Stop(); PlayerAttackSFX.Play(); })
|
||||||
|
.Handle((in InGameAudioLogic.Output.PlayPlayerAttackWallSound _) => { PlayerAttackWallSFX.Stop(); PlayerAttackWallSFX.Play(); });
|
||||||
|
|
||||||
InGameAudioLogic.Start();
|
InGameAudioLogic.Start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=13 format=3 uid="uid://b16ejcwanod72"]
|
[gd_scene load_steps=15 format=3 uid="uid://b16ejcwanod72"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://2mnouyn1jcqs" path="res://src/audio/InGameAudio.cs" id="1_gpmcr"]
|
[ext_resource type="Script" uid="uid://2mnouyn1jcqs" path="res://src/audio/InGameAudio.cs" id="1_gpmcr"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dfu0fksb6slhx" path="res://src/audio/music/droney.mp3" id="2_8hfyr"]
|
[ext_resource type="AudioStream" uid="uid://dfu0fksb6slhx" path="res://src/audio/music/droney.mp3" id="2_8hfyr"]
|
||||||
@@ -6,7 +6,9 @@
|
|||||||
[ext_resource type="AudioStream" uid="uid://d2jrktp06xsba" path="res://src/audio/music/crossing-the-gate.mp3" id="3_wbmd6"]
|
[ext_resource type="AudioStream" uid="uid://d2jrktp06xsba" path="res://src/audio/music/crossing-the-gate.mp3" id="3_wbmd6"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dn2e2hqujlia1" path="res://src/audio/music/tar-winds.mp3" id="4_surnl"]
|
[ext_resource type="AudioStream" uid="uid://dn2e2hqujlia1" path="res://src/audio/music/tar-winds.mp3" id="4_surnl"]
|
||||||
[ext_resource type="AudioStream" uid="uid://t3g04u722f2k" path="res://src/audio/music/useless immune system-1.mp3" id="6_agr3r"]
|
[ext_resource type="AudioStream" uid="uid://t3g04u722f2k" path="res://src/audio/music/useless immune system-1.mp3" id="6_agr3r"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://cn8cugshq3o8k" path="res://src/audio/sfx/PlayerHitWallSFX.wav" id="7_8vh2f"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dor0in0x2fg48" path="res://src/audio/sfx/TempFFVII/menu-move.ogg" id="7_777nl"]
|
[ext_resource type="AudioStream" uid="uid://dor0in0x2fg48" path="res://src/audio/sfx/TempFFVII/menu-move.ogg" id="7_777nl"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://d1mlduwauechv" path="res://src/audio/sfx/PlayerAttackSFX.wav" id="7_wtvpb"]
|
||||||
[ext_resource type="AudioStream" uid="uid://r1tryiit38i8" path="res://src/audio/sfx/TempFFVII/menu-back.ogg" id="8_1xcgo"]
|
[ext_resource type="AudioStream" uid="uid://r1tryiit38i8" path="res://src/audio/sfx/TempFFVII/menu-back.ogg" id="8_1xcgo"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bjj61s8q2gwb8" path="res://src/audio/sfx/TempFFVII/junction.ogg" id="8_kwybb"]
|
[ext_resource type="AudioStream" uid="uid://bjj61s8q2gwb8" path="res://src/audio/sfx/TempFFVII/junction.ogg" id="8_kwybb"]
|
||||||
[ext_resource type="AudioStream" uid="uid://myx4s8lmarc2" path="res://src/audio/sfx/TempFFVII/something-earned.ogg" id="10_3lcw5"]
|
[ext_resource type="AudioStream" uid="uid://myx4s8lmarc2" path="res://src/audio/sfx/TempFFVII/something-earned.ogg" id="10_3lcw5"]
|
||||||
@@ -56,46 +58,45 @@ script = ExtResource("2_857rw")
|
|||||||
|
|
||||||
[node name="PlayerAttackSFX" type="AudioStreamPlayer" parent="."]
|
[node name="PlayerAttackSFX" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
script = ExtResource("2_857rw")
|
stream = ExtResource("7_wtvpb")
|
||||||
|
volume_db = -5.0
|
||||||
|
|
||||||
|
[node name="PlayerAttackWallSFX" type="AudioStreamPlayer" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
stream = ExtResource("7_8vh2f")
|
||||||
|
volume_db = -5.0
|
||||||
|
|
||||||
[node name="MenuScrollSFX" type="AudioStreamPlayer" parent="."]
|
[node name="MenuScrollSFX" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("7_777nl")
|
stream = ExtResource("7_777nl")
|
||||||
volume_db = -10.0
|
volume_db = -10.0
|
||||||
script = ExtResource("2_857rw")
|
|
||||||
|
|
||||||
[node name="MenuBackSFX" type="AudioStreamPlayer" parent="."]
|
[node name="MenuBackSFX" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("8_1xcgo")
|
stream = ExtResource("8_1xcgo")
|
||||||
volume_db = -10.0
|
volume_db = -10.0
|
||||||
script = ExtResource("2_857rw")
|
|
||||||
|
|
||||||
[node name="EquipSFX" type="AudioStreamPlayer" parent="."]
|
[node name="EquipSFX" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("8_kwybb")
|
stream = ExtResource("8_kwybb")
|
||||||
volume_db = -10.0
|
volume_db = -10.0
|
||||||
script = ExtResource("2_857rw")
|
|
||||||
|
|
||||||
[node name="HealSFX" type="AudioStreamPlayer" parent="."]
|
[node name="HealSFX" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("10_3lcw5")
|
stream = ExtResource("10_3lcw5")
|
||||||
volume_db = -10.0
|
volume_db = -10.0
|
||||||
script = ExtResource("2_857rw")
|
|
||||||
|
|
||||||
[node name="TeleportSFX" type="AudioStreamPlayer" parent="."]
|
[node name="TeleportSFX" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("11_offhc")
|
stream = ExtResource("11_offhc")
|
||||||
volume_db = -18.0
|
volume_db = -18.0
|
||||||
script = ExtResource("2_857rw")
|
|
||||||
|
|
||||||
[node name="InventorySortedSFX" type="AudioStreamPlayer" parent="."]
|
[node name="InventorySortedSFX" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("12_wprjr")
|
stream = ExtResource("12_wprjr")
|
||||||
volume_db = -15.0
|
volume_db = -15.0
|
||||||
script = ExtResource("2_857rw")
|
|
||||||
|
|
||||||
[node name="HealingItemSFX" type="AudioStreamPlayer" parent="."]
|
[node name="HealingItemSFX" type="AudioStreamPlayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
stream = ExtResource("10_3lcw5")
|
stream = ExtResource("10_3lcw5")
|
||||||
volume_db = -15.0
|
volume_db = -15.0
|
||||||
script = ExtResource("2_857rw")
|
|
||||||
|
|||||||
BIN
Zennysoft.Game.Ma/src/audio/sfx/PlayerAttackSFX.wav
Normal file
BIN
Zennysoft.Game.Ma/src/audio/sfx/PlayerAttackSFX.wav
Normal file
Binary file not shown.
24
Zennysoft.Game.Ma/src/audio/sfx/PlayerAttackSFX.wav.import
Normal file
24
Zennysoft.Game.Ma/src/audio/sfx/PlayerAttackSFX.wav.import
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://d1mlduwauechv"
|
||||||
|
path="res://.godot/imported/PlayerAttackSFX.wav-25ff4e405f0437faa32be96b9f5ca832.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://src/audio/sfx/PlayerAttackSFX.wav"
|
||||||
|
dest_files=["res://.godot/imported/PlayerAttackSFX.wav-25ff4e405f0437faa32be96b9f5ca832.sample"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
BIN
Zennysoft.Game.Ma/src/audio/sfx/PlayerHitWallSFX.wav
Normal file
BIN
Zennysoft.Game.Ma/src/audio/sfx/PlayerHitWallSFX.wav
Normal file
Binary file not shown.
24
Zennysoft.Game.Ma/src/audio/sfx/PlayerHitWallSFX.wav.import
Normal file
24
Zennysoft.Game.Ma/src/audio/sfx/PlayerHitWallSFX.wav.import
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="wav"
|
||||||
|
type="AudioStreamWAV"
|
||||||
|
uid="uid://cn8cugshq3o8k"
|
||||||
|
path="res://.godot/imported/PlayerHitWallSFX.wav-bee36ba71b5478424176ab61368ea9f8.sample"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://src/audio/sfx/PlayerHitWallSFX.wav"
|
||||||
|
dest_files=["res://.godot/imported/PlayerHitWallSFX.wav-bee36ba71b5478424176ab61368ea9f8.sample"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
force/8_bit=false
|
||||||
|
force/mono=false
|
||||||
|
force/max_rate=false
|
||||||
|
force/max_rate_hz=44100
|
||||||
|
edit/trim=false
|
||||||
|
edit/normalize=false
|
||||||
|
edit/loop_mode=0
|
||||||
|
edit/loop_begin=0
|
||||||
|
edit/loop_end=-1
|
||||||
|
compress/mode=2
|
||||||
@@ -13,6 +13,8 @@ public partial class InGameAudioLogic
|
|||||||
#region SFX
|
#region SFX
|
||||||
public readonly record struct PlayPlayerAttackSound;
|
public readonly record struct PlayPlayerAttackSound;
|
||||||
|
|
||||||
|
public readonly record struct PlayPlayerAttackWallSound;
|
||||||
|
|
||||||
public readonly record struct PlayMenuScrollSound;
|
public readonly record struct PlayMenuScrollSound;
|
||||||
|
|
||||||
public readonly record struct PlayEquipSound;
|
public readonly record struct PlayEquipSound;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
|
using Zennysoft.Ma.Adapter;
|
||||||
|
|
||||||
namespace Zennysoft.Game.Ma;
|
namespace Zennysoft.Game.Ma;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ public partial class InGameAudioLogic
|
|||||||
var player = Get<IPlayer>();
|
var player = Get<IPlayer>();
|
||||||
OnOverworldEntered();
|
OnOverworldEntered();
|
||||||
var gameEventDepot = Get<IGameEventDepot>();
|
var gameEventDepot = Get<IGameEventDepot>();
|
||||||
|
var gameRepo = Get<IGameRepo>();
|
||||||
gameEventDepot.OverworldEntered += OnOverworldEntered;
|
gameEventDepot.OverworldEntered += OnOverworldEntered;
|
||||||
gameEventDepot.DungeonAThemeAreaEntered += OnDungeonAThemeEntered;
|
gameEventDepot.DungeonAThemeAreaEntered += OnDungeonAThemeEntered;
|
||||||
gameEventDepot.MenuScrolled += OnMenuScrolled;
|
gameEventDepot.MenuScrolled += OnMenuScrolled;
|
||||||
@@ -25,11 +27,14 @@ public partial class InGameAudioLogic
|
|||||||
gameEventDepot.HealingItemConsumed += OnHealingItemConsumed;
|
gameEventDepot.HealingItemConsumed += OnHealingItemConsumed;
|
||||||
gameEventDepot.RestorativePickedUp += OnRestorativePickedUp;
|
gameEventDepot.RestorativePickedUp += OnRestorativePickedUp;
|
||||||
gameEventDepot.TeleportEntered += OnTeleportEntered;
|
gameEventDepot.TeleportEntered += OnTeleportEntered;
|
||||||
|
gameRepo.PlayerAttack += OnPlayerAttack;
|
||||||
|
gameRepo.PlayerAttackedWall += OnPlayerAttackWall;
|
||||||
});
|
});
|
||||||
OnDetach(() =>
|
OnDetach(() =>
|
||||||
{
|
{
|
||||||
var gameEventDepot = Get<IGameEventDepot>();
|
var gameEventDepot = Get<IGameEventDepot>();
|
||||||
var player = Get<IPlayer>();
|
var player = Get<IPlayer>();
|
||||||
|
var gameRepo = Get<IGameRepo>();
|
||||||
gameEventDepot.OverworldEntered -= OnOverworldEntered;
|
gameEventDepot.OverworldEntered -= OnOverworldEntered;
|
||||||
gameEventDepot.DungeonAThemeAreaEntered -= OnDungeonAThemeEntered;
|
gameEventDepot.DungeonAThemeAreaEntered -= OnDungeonAThemeEntered;
|
||||||
gameEventDepot.MenuScrolled -= OnMenuScrolled;
|
gameEventDepot.MenuScrolled -= OnMenuScrolled;
|
||||||
@@ -39,9 +44,15 @@ public partial class InGameAudioLogic
|
|||||||
player.EquippedAccessory.Changed -= OnEquippedItem;
|
player.EquippedAccessory.Changed -= OnEquippedItem;
|
||||||
gameEventDepot.InventorySorted -= OnInventorySorted;
|
gameEventDepot.InventorySorted -= OnInventorySorted;
|
||||||
gameEventDepot.TeleportEntered -= OnTeleportEntered;
|
gameEventDepot.TeleportEntered -= OnTeleportEntered;
|
||||||
|
gameRepo.PlayerAttack -= OnPlayerAttack;
|
||||||
|
gameRepo.PlayerAttackedWall -= OnPlayerAttackWall;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnPlayerAttack() => Output(new Output.PlayPlayerAttackSound());
|
||||||
|
|
||||||
|
private void OnPlayerAttackWall() => Output(new Output.PlayPlayerAttackWallSound());
|
||||||
|
|
||||||
private void OnRestorativePickedUp(Restorative restorative) => Output(new Output.PlayHealingItemSound());
|
private void OnRestorativePickedUp(Restorative restorative) => Output(new Output.PlayHealingItemSound());
|
||||||
|
|
||||||
private void OnMenuBackedOut() => Output(new Output.PlayMenuBackSound());
|
private void OnMenuBackedOut() => Output(new Output.PlayMenuBackSound());
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ using Godot.Collections;
|
|||||||
using SimpleInjector;
|
using SimpleInjector;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Zennysoft.Game.Abstractions;
|
|
||||||
using Zennysoft.Ma.Adapter;
|
using Zennysoft.Ma.Adapter;
|
||||||
|
|
||||||
namespace Zennysoft.Game.Ma;
|
namespace Zennysoft.Game.Ma;
|
||||||
@@ -88,6 +87,8 @@ public partial class Player : CharacterBody3D, IPlayer
|
|||||||
[Node] private Area3D CollisionDetector { get; set; } = default!;
|
[Node] private Area3D CollisionDetector { get; set; } = default!;
|
||||||
|
|
||||||
[Node] private Timer HealthTimer { get; set; } = default!;
|
[Node] private Timer HealthTimer { get; set; } = default!;
|
||||||
|
|
||||||
|
[Node] private RigidBody3D WallCheck { get; set; } = default!;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -211,10 +212,18 @@ public partial class Player : CharacterBody3D, IPlayer
|
|||||||
PlayerBinding
|
PlayerBinding
|
||||||
.Handle((in PlayerLogic.Output.Animations.Attack output) =>
|
.Handle((in PlayerLogic.Output.Animations.Attack output) =>
|
||||||
{
|
{
|
||||||
var attackSpeed = EquippedWeapon.Value.AttackSpeed;
|
if (PlayerIsHittingGeometry())
|
||||||
AnimationPlayer.SetSpeedScale((float)attackSpeed);
|
{
|
||||||
|
AnimationPlayer.Play("hit_wall");
|
||||||
AnimationPlayer.Play("attack");
|
_gameRepo.OnPlayerAttackedWall();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var attackSpeed = EquippedWeapon.Value.AttackSpeed;
|
||||||
|
AnimationPlayer.SetSpeedScale((float)attackSpeed);
|
||||||
|
AnimationPlayer.Play("attack");
|
||||||
|
_gameRepo.OnPlayerAttack();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.Handle((in PlayerLogic.Output.ThrowItem output) =>
|
.Handle((in PlayerLogic.Output.ThrowItem output) =>
|
||||||
{
|
{
|
||||||
@@ -230,32 +239,6 @@ public partial class Player : CharacterBody3D, IPlayer
|
|||||||
this.Provide();
|
this.Provide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CollisionDetector_AreaEntered(Area3D area)
|
|
||||||
{
|
|
||||||
if (area.GetParent() is InventoryItem inventoryItem)
|
|
||||||
{
|
|
||||||
var isAdded = Inventory.TryAdd(inventoryItem);
|
|
||||||
if (isAdded)
|
|
||||||
{
|
|
||||||
_gameRepo.AnnounceMessageOnMainScreen($"{inventoryItem.ItemName} picked up.");
|
|
||||||
inventoryItem.QueueFree();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_gameRepo.AnnounceMessageOnMainScreen($"Could not pick up {inventoryItem.ItemName}.");
|
|
||||||
}
|
|
||||||
if (area.GetParent() is DroppedItem droppedItem)
|
|
||||||
{
|
|
||||||
var isAdded = Inventory.TryAdd(droppedItem.Item);
|
|
||||||
if (isAdded)
|
|
||||||
{
|
|
||||||
_gameRepo.AnnounceMessageOnMainScreen($"{droppedItem.Item.ItemName} picked up.");
|
|
||||||
droppedItem.QueueFree();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_gameRepo.AnnounceMessageOnMainScreen($"Could not pick up {droppedItem.Item.ItemName}.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnReady()
|
public void OnReady()
|
||||||
{
|
{
|
||||||
SetPhysicsProcess(true);
|
SetPhysicsProcess(true);
|
||||||
@@ -502,7 +485,6 @@ public partial class Player : CharacterBody3D, IPlayer
|
|||||||
|
|
||||||
private void OnAnimationFinished(StringName animation)
|
private void OnAnimationFinished(StringName animation)
|
||||||
{
|
{
|
||||||
GD.Print("Attack finished");
|
|
||||||
PlayerLogic.Input(new PlayerLogic.Input.AttackAnimationFinished());
|
PlayerLogic.Input(new PlayerLogic.Input.AttackAnimationFinished());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -594,4 +576,43 @@ public partial class Player : CharacterBody3D, IPlayer
|
|||||||
if (EquippedWeapon.Value.WeaponTag == WeaponTag.Knockback)
|
if (EquippedWeapon.Value.WeaponTag == WeaponTag.Knockback)
|
||||||
enemy.Knockback(0.3f, -CurrentBasis.Z.Normalized());
|
enemy.Knockback(0.3f, -CurrentBasis.Z.Normalized());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CollisionDetector_AreaEntered(Area3D area)
|
||||||
|
{
|
||||||
|
if (area.GetParent() is InventoryItem inventoryItem)
|
||||||
|
{
|
||||||
|
var isAdded = Inventory.TryAdd(inventoryItem);
|
||||||
|
if (isAdded)
|
||||||
|
{
|
||||||
|
_gameRepo.AnnounceMessageOnMainScreen($"{inventoryItem.ItemName} picked up.");
|
||||||
|
inventoryItem.QueueFree();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_gameRepo.AnnounceMessageOnMainScreen($"Could not pick up {inventoryItem.ItemName}.");
|
||||||
|
}
|
||||||
|
if (area.GetParent() is DroppedItem droppedItem)
|
||||||
|
{
|
||||||
|
var isAdded = Inventory.TryAdd(droppedItem.Item);
|
||||||
|
if (isAdded)
|
||||||
|
{
|
||||||
|
_gameRepo.AnnounceMessageOnMainScreen($"{droppedItem.Item.ItemName} picked up.");
|
||||||
|
droppedItem.QueueFree();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_gameRepo.AnnounceMessageOnMainScreen($"Could not pick up {droppedItem.Item.ItemName}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool PlayerIsHittingGeometry()
|
||||||
|
{
|
||||||
|
var collisions = WallCheck.GetCollidingBodies();
|
||||||
|
return collisions.Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WallCheck_BodyEntered(Node body)
|
||||||
|
{
|
||||||
|
PlayerLogic.Input(new PlayerLogic.Input.AttackAnimationFinished());
|
||||||
|
GD.Print("Hit wall");
|
||||||
|
AnimationPlayer.Stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=60 format=4 uid="uid://cfecvvav8kkp6"]
|
[gd_scene load_steps=61 format=4 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="Script" uid="uid://6edayafleq8y" path="res://src/hitbox/Hitbox.cs" id="2_lb3qc"]
|
[ext_resource type="Script" uid="uid://6edayafleq8y" path="res://src/hitbox/Hitbox.cs" id="2_lb3qc"]
|
||||||
@@ -96,16 +96,28 @@ tracks/1/keys = {
|
|||||||
"values": [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
"values": [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_uxo8q"]
|
[sub_resource type="Animation" id="Animation_es4xk"]
|
||||||
resource_name = "explosion"
|
resource_name = "hit_wall"
|
||||||
length = 3.66668
|
length = 0.3
|
||||||
step = 0.0833333
|
step = 0.0833333
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("SwordSlashAnimation:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.0833333, 0.166667),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [10, 1, 11]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_w8l8m"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_w8l8m"]
|
||||||
_data = {
|
_data = {
|
||||||
&"RESET": SubResource("Animation_hcjph"),
|
&"RESET": SubResource("Animation_hcjph"),
|
||||||
&"attack": SubResource("Animation_0jjwv"),
|
&"attack": SubResource("Animation_0jjwv"),
|
||||||
&"explosion": SubResource("Animation_uxo8q")
|
&"hit_wall": SubResource("Animation_es4xk")
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_d4v1j"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_d4v1j"]
|
||||||
@@ -465,6 +477,9 @@ animations = [{
|
|||||||
"speed": 12.0
|
"speed": 12.0
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_es4xk"]
|
||||||
|
height = 1.6909
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D"]
|
[node name="Player" type="CharacterBody3D"]
|
||||||
collision_layer = 806
|
collision_layer = 806
|
||||||
collision_mask = 775
|
collision_mask = 775
|
||||||
@@ -564,3 +579,19 @@ spot_attenuation = 0.22
|
|||||||
|
|
||||||
[node name="OmniLight3D2" type="OmniLight3D" parent="."]
|
[node name="OmniLight3D2" type="OmniLight3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.65529, 0.471719)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.65529, 0.471719)
|
||||||
|
|
||||||
|
[node name="WallCheck" type="RigidBody3D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
collision_layer = 0
|
||||||
|
axis_lock_linear_x = true
|
||||||
|
axis_lock_linear_y = true
|
||||||
|
axis_lock_linear_z = true
|
||||||
|
axis_lock_angular_x = true
|
||||||
|
axis_lock_angular_y = true
|
||||||
|
axis_lock_angular_z = true
|
||||||
|
contact_monitor = true
|
||||||
|
max_contacts_reported = 100
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="WallCheck"]
|
||||||
|
transform = Transform3D(1.91069e-15, 4.37114e-08, 1, 1, -4.37114e-08, 0, 4.37114e-08, 1, -4.37114e-08, 0.293308, 1.35803, -0.602638)
|
||||||
|
shape = SubResource("CapsuleShape3D_es4xk")
|
||||||
|
|||||||
Reference in New Issue
Block a user