Add sword-swing sound effects.

GitOrigin-RevId: 946a808c6f7e96297ec291f2b8e55ae062d5193b
This commit is contained in:
Colin McMillen 2020-02-27 20:23:05 -05:00
parent f4581ecaf8
commit de8ca4a374
4 changed files with 19 additions and 0 deletions

View File

@ -222,6 +222,7 @@ namespace SemiColinGames {
if (input[0].Attack && !input[1].Attack && swordSwingTime <= 0) { if (input[0].Attack && !input[1].Attack && swordSwingTime <= 0) {
swordSwingTime = 0.3; swordSwingTime = 0.3;
swordSwingNum = (swordSwingNum + 1) % swordSwingMax; swordSwingNum = (swordSwingNum + 1) % swordSwingMax;
SoundEffects.SwordSwings[swordSwingNum % SoundEffects.SwordSwings.Length].Play();
} }
result.Y = ySpeed * modelTime; result.Y = ySpeed * modelTime;

View File

@ -11,6 +11,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Camera.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Camera.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ExtensionMethods.cs" /> <Compile Include="$(MSBuildThisFileDirectory)ExtensionMethods.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SoundEffects.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Text.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Text.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Textures.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Textures.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Clock.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Clock.cs" />

View File

@ -64,6 +64,7 @@ namespace SemiColinGames {
// Called once per game. Loads all game content. // Called once per game. Loads all game content.
protected override void LoadContent() { protected override void LoadContent() {
base.LoadContent(); base.LoadContent();
SoundEffects.Load(Content);
Textures.Load(Content); Textures.Load(Content);
linesOfSight = new LinesOfSight(GraphicsDevice); linesOfSight = new LinesOfSight(GraphicsDevice);
LoadLevel(); LoadLevel();

16
Shared/SoundEffects.cs Normal file
View File

@ -0,0 +1,16 @@
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
namespace SemiColinGames {
public static class SoundEffects {
public static SoundEffect[] SwordSwings = new SoundEffect[4];
public static void Load(ContentManager content) {
SwordSwings[0] = content.Load<SoundEffect>("sfx/zapsplat/sword_whoosh_1");
SwordSwings[1] = content.Load<SoundEffect>("sfx/zapsplat/sword_whoosh_2");
SwordSwings[2] = content.Load<SoundEffect>("sfx/zapsplat/sword_whoosh_3");
SwordSwings[3] = content.Load<SoundEffect>("sfx/zapsplat/sword_whoosh_4");
}
}
}