feat: Ball Hit Sound Effect
This commit is contained in:
parent
b1582ab5c2
commit
d5a904fe8f
|
@ -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<SoundEffect>("Hit");
|
||||
}
|
||||
|
||||
protected override void OnFirstActiveFrame()
|
||||
{
|
||||
|
@ -84,6 +96,8 @@ public class BallBehaviour : BehaviourOverride
|
|||
else
|
||||
rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
|
||||
|
||||
soundEffect.Play();
|
||||
|
||||
SendBallData();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue