feat: Ball Hit Sound Effect
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								Game/Content/Hit.wav
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Game/Content/Hit.wav
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user