diff --git a/Game/Behaviours/BallBehaviour.cs b/Game/Behaviours/BallBehaviour.cs index 3e5b6df..cebf123 100644 --- a/Game/Behaviours/BallBehaviour.cs +++ b/Game/Behaviours/BallBehaviour.cs @@ -1,13 +1,19 @@ using System; + +using Microsoft.Xna.Framework.Content; + using LiteNetLib; + using Pong.Network; + using Syntriax.Engine.Core; using Syntriax.Engine.Physics2D; using Syntriax.Engine.Physics2D.Abstract; +using Microsoft.Xna.Framework.Audio; namespace Pong.Behaviours; -public class BallBehaviour : BehaviourOverride +public class BallBehaviour : BehaviourOverride, IMonoGameContentLoader { public Vector2D StartDirection { get; private set; } = Vector2D.Zero; public float Speed { get; set; } = 500f; @@ -16,6 +22,12 @@ public class BallBehaviour : BehaviourOverride private readonly Random random = new(); private IRigidBody2D rigidBody = null!; private INetworkCommunicator communicator = null!; + private SoundEffect soundEffect = null!; + + public void LoadContent(ContentManager content) + { + soundEffect = content.Load("Hit"); + } protected override void OnFirstActiveFrame() { @@ -84,6 +96,8 @@ public class BallBehaviour : BehaviourOverride else rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal); + soundEffect.Play(); + SendBallData(); } diff --git a/Game/Content/Content.mgcb b/Game/Content/Content.mgcb index d1b9814..f14b8e8 100644 --- a/Game/Content/Content.mgcb +++ b/Game/Content/Content.mgcb @@ -13,6 +13,12 @@ #---------------------------------- Content ---------------------------------# +#begin Hit.wav +/importer:WavImporter +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Hit.wav + #begin UbuntuMono.spritefont /importer:FontDescriptionImporter /processor:FontDescriptionProcessor diff --git a/Game/Content/Hit.wav b/Game/Content/Hit.wav new file mode 100644 index 0000000..9bc1f99 Binary files /dev/null and b/Game/Content/Hit.wav differ