feat: Ball Hit Sound Effect
This commit is contained in:
parent
b1582ab5c2
commit
d5a904fe8f
|
@ -1,13 +1,19 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
|
||||||
using LiteNetLib;
|
using LiteNetLib;
|
||||||
|
|
||||||
using Pong.Network;
|
using Pong.Network;
|
||||||
|
|
||||||
using Syntriax.Engine.Core;
|
using Syntriax.Engine.Core;
|
||||||
using Syntriax.Engine.Physics2D;
|
using Syntriax.Engine.Physics2D;
|
||||||
using Syntriax.Engine.Physics2D.Abstract;
|
using Syntriax.Engine.Physics2D.Abstract;
|
||||||
|
using Microsoft.Xna.Framework.Audio;
|
||||||
|
|
||||||
namespace Pong.Behaviours;
|
namespace Pong.Behaviours;
|
||||||
|
|
||||||
public class BallBehaviour : BehaviourOverride
|
public class BallBehaviour : BehaviourOverride, IMonoGameContentLoader
|
||||||
{
|
{
|
||||||
public Vector2D StartDirection { get; private set; } = Vector2D.Zero;
|
public Vector2D StartDirection { get; private set; } = Vector2D.Zero;
|
||||||
public float Speed { get; set; } = 500f;
|
public float Speed { get; set; } = 500f;
|
||||||
|
@ -16,6 +22,12 @@ public class BallBehaviour : BehaviourOverride
|
||||||
private readonly Random random = new();
|
private readonly Random random = new();
|
||||||
private IRigidBody2D rigidBody = null!;
|
private IRigidBody2D rigidBody = null!;
|
||||||
private INetworkCommunicator communicator = null!;
|
private INetworkCommunicator communicator = null!;
|
||||||
|
private SoundEffect soundEffect = null!;
|
||||||
|
|
||||||
|
public void LoadContent(ContentManager content)
|
||||||
|
{
|
||||||
|
soundEffect = content.Load<SoundEffect>("Hit");
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnFirstActiveFrame()
|
protected override void OnFirstActiveFrame()
|
||||||
{
|
{
|
||||||
|
@ -84,6 +96,8 @@ public class BallBehaviour : BehaviourOverride
|
||||||
else
|
else
|
||||||
rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
|
rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
|
||||||
|
|
||||||
|
soundEffect.Play();
|
||||||
|
|
||||||
SendBallData();
|
SendBallData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,12 @@
|
||||||
|
|
||||||
#---------------------------------- Content ---------------------------------#
|
#---------------------------------- Content ---------------------------------#
|
||||||
|
|
||||||
|
#begin Hit.wav
|
||||||
|
/importer:WavImporter
|
||||||
|
/processor:SoundEffectProcessor
|
||||||
|
/processorParam:Quality=Best
|
||||||
|
/build:Hit.wav
|
||||||
|
|
||||||
#begin UbuntuMono.spritefont
|
#begin UbuntuMono.spritefont
|
||||||
/importer:FontDescriptionImporter
|
/importer:FontDescriptionImporter
|
||||||
/processor:FontDescriptionProcessor
|
/processor:FontDescriptionProcessor
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue