Description:
Add basic sound.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r578:7f1b7ee713b3 -

1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -1,6 +1,7
1
1
2 using System;
2 using System;
3 using Microsoft.Xna.Framework;
3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Audio;
4 using Microsoft.Xna.Framework.Graphics;
5 using Microsoft.Xna.Framework.Graphics;
5 using Microsoft.Xna.Framework.Input;
6 using Microsoft.Xna.Framework.Input;
6
7
@@ -45,8 +46,10
45 private int height;
46 private int height;
46 private int width;
47 private int width;
47
48
49 private SoundEffect sound;
50
48 public InputEngine(int menuBarHeight, Camera camera,
51 public InputEngine(int menuBarHeight, Camera camera,
49 GraphicsDeviceManager gdm, int height, int width) {
52 GraphicsDeviceManager gdm, int height, int width, SoundEffect sound) {
50 //initialize to blank for now
53 //initialize to blank for now
51 this.keyboardPrev = new KeyboardState();
54 this.keyboardPrev = new KeyboardState();
52 this.menuBarHeight = menuBarHeight;
55 this.menuBarHeight = menuBarHeight;
@@ -55,6 +58,7
55 this.graphicsDevice = gdm.GraphicsDevice;
58 this.graphicsDevice = gdm.GraphicsDevice;
56 this.height = height;
59 this.height = height;
57 this.width = width;
60 this.width = width;
61 this.sound = sound;
58 }
62 }
59
63
60
64
@@ -281,6 +285,7
281 if ( mouseCur.LeftButton == ButtonState.Released && mousePrev.LeftButton == ButtonState.Pressed)
285 if ( mouseCur.LeftButton == ButtonState.Released && mousePrev.LeftButton == ButtonState.Pressed)
282 {
286 {
283 SendMessage(new AdjustSelection {Type = AdjustmentType.Complete });
287 SendMessage(new AdjustSelection {Type = AdjustmentType.Complete });
288 // SendMessage(new
284 }
289 }
285
290
286 if (mouseCur.LeftButton == ButtonState.Pressed && mousePrev.LeftButton == ButtonState.Pressed)
291 if (mouseCur.LeftButton == ButtonState.Pressed && mousePrev.LeftButton == ButtonState.Pressed)
@@ -294,17 +299,18
294 && MathUtils.Between(gridPosition.Y, 0, this.height))
299 && MathUtils.Between(gridPosition.Y, 0, this.height))
295 {
300 {
296 foreach (ref readonly var entity in ReadEntities<CursorComponent>()) {
301 foreach (ref readonly var entity in ReadEntities<CursorComponent>()) {
297
298
299 var cursorComponent = GetComponent<CursorComponent>(entity);
302 var cursorComponent = GetComponent<CursorComponent>(entity);
300
303
301 SetComponent(entity, new CursorComponent { position = gridPosition,
304 SetComponent(entity, new CursorComponent { position = gridPosition,
302 size = 1 });
305 size = 1 });
303
304 }
306 }
305 }
307 }
306
307 }
308 }
309 else if (ImGui.IsAnyItemHovered()) {
310 if (mouseCur.LeftButton == ButtonState.Pressed && mousePrev.LeftButton == ButtonState.Released) {
311 this.sound.Play(1.0f, 0.0f, 0.0f);
312 }
313 }
308
314
309 #endregion
315 #endregion
310 this.keyboardPrev = keyboardCur;
316 this.keyboardPrev = keyboardCur;
@@ -44,9 +44,10
44
44
45 private SpriteBatch batch;
45 private SpriteBatch batch;
46 private SpriteBatch tileBatch;
46 private SpriteBatch tileBatch;
47 #if DEBUG
47 // #if DEBUG
48 private SoundEffect sound;
48 private SoundEffect sound;
49 #endif
49 private SoundEffect clickSound;
50 // #endif
50 private SpriteFont monoFont;
51 private SpriteFont monoFont;
51 private SpriteFont largeMonoFont;
52 private SpriteFont largeMonoFont;
52
53
@@ -193,9 +194,10
193 this.batch = new SpriteBatch(GraphicsDevice);
194 this.batch = new SpriteBatch(GraphicsDevice);
194 this.tileBatch = new SpriteBatch(GraphicsDevice);
195 this.tileBatch = new SpriteBatch(GraphicsDevice);
195
196
196 #if DEBUG
197 // #if DEBUG
197 sound = Content.Load<SoundEffect>("FNASound");
198 this.sound = Content.Load<SoundEffect>("FNASound");
198 #endif
199 this.clickSound = Content.Load<SoundEffect>("Click");
200 // #endif
199 Tile.TileSetTexture = Content.Load<Texture2D>(@"merged_tileset");
201 Tile.TileSetTexture = Content.Load<Texture2D>(@"merged_tileset");
200 var texture = Content.Load<Texture2D>(@"solid_tileset");
202 var texture = Content.Load<Texture2D>(@"solid_tileset");
201
203
@@ -265,8 +267,8
265
267
266 Logging.Debug(this.Story.ContinueMaximally());
268 Logging.Debug(this.Story.ContinueMaximally());
267
269
268 WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, this.camera, gdm,
270 WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, this.camera, gdm,
269 this.simulation.map.MapHeight, this.simulation.map.MapWidth));
271 this.simulation.map.MapHeight, this.simulation.map.MapWidth, this.clickSound));
270 WorldBuilder.AddEngine(new UIEngine(this.Story));
272 WorldBuilder.AddEngine(new UIEngine(this.Story));
271 WorldBuilder.AddEngine(new DialogEngine(this.Story, this.grammar));
273 WorldBuilder.AddEngine(new DialogEngine(this.Story, this.grammar));
272
274
@@ -424,9 +426,10
424 protected override void UnloadContent()
426 protected override void UnloadContent()
425 {
427 {
426 batch.Dispose();
428 batch.Dispose();
427 #if DEBUG
429 // #if DEBUG
428 sound.Dispose();
430 sound.Dispose();
429 #endif
431 clickSound.Dispose();
432 // #endif
430 Tile.TileSetTexture.Dispose();
433 Tile.TileSetTexture.Dispose();
431 Logging.Success("Disposed of Tile texture.");
434 Logging.Success("Disposed of Tile texture.");
432 if (Quad.PixelTexture != null)
435 if (Quad.PixelTexture != null)
@@ -475,11 +478,11
475 Stopwatch stopWatch = new Stopwatch();
478 Stopwatch stopWatch = new Stopwatch();
476 stopWatch.Start();
479 stopWatch.Start();
477
480
478 #if DEBUG
481 // #if DEBUG
479 float volume = 1.0f;
482 float volume = 1.0f;
480 float pitch = 0.0f;
483 float pitch = 0.0f;
481 float pan = 0.0f;
484 float pan = 0.0f;
482 #endif
485 // #endif
483
486
484 KeyboardState keyboardCur = Keyboard.GetState();
487 KeyboardState keyboardCur = Keyboard.GetState();
485 MouseState mouseCur = Mouse.GetState();
488 MouseState mouseCur = Mouse.GetState();
@@ -487,14 +490,14
487 #region input
490 #region input
488
491
489 #region misc_keys
492 #region misc_keys
490 #if DEBUG
493 // #if DEBUG
491 if (keyboardCur.IsKeyDown(Keys.OemBackslash)
494 if (keyboardCur.IsKeyDown(Keys.OemBackslash)
492 && keyboardPrev.IsKeyUp(Keys.OemBackslash)
495 && keyboardPrev.IsKeyUp(Keys.OemBackslash)
493 && keyboardCur.IsKeyDown(Keys.LeftShift))
496 && keyboardCur.IsKeyDown(Keys.LeftShift))
494 {
497 {
495 sound.Play(volume, pitch, pan);
498 sound.Play(volume, pitch, pan);
496 }
499 }
497 #endif
500 // #endif
498 #endregion misc_keys
501 #endregion misc_keys
499 #endregion input
502 #endregion input
500
503
@@ -90,26 +90,26
90 new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2,
90 new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2,
91 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
91 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
92 new Vector2(((x - y + size) * Tile.TileSpriteWidth / 2), (x + y + size) * Tile.TileSpriteHeight / 2) + adjust2,
92 new Vector2(((x - y + size) * Tile.TileSpriteWidth / 2), (x + y + size) * Tile.TileSpriteHeight / 2) + adjust2,
93 color, 0.79f);
93 color, 0.77f);
94
94
95 //Bottom right
95 //Bottom right
96 Line.drawLine(batch,
96 Line.drawLine(batch,
97 new Vector2(((x + size - y) * Tile.TileSpriteWidth / 2), (x + size + y) * Tile.TileSpriteHeight / 2) + adjust2,
97 new Vector2(((x + size - y) * Tile.TileSpriteWidth / 2), (x + size + y) * Tile.TileSpriteHeight / 2) + adjust2,
98 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
98 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
99 new Vector2(((x + size - (y + size)) * Tile.TileSpriteWidth / 2), (x + size + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2,
99 new Vector2(((x + size - (y + size)) * Tile.TileSpriteWidth / 2), (x + size + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2,
100 color, 0.79f);
100 color, 0.77f);
101 //Bottom left
101 //Bottom left
102 Line.drawLine(batch,
102 Line.drawLine(batch,
103 new Vector2(((x - (y + size)) * Tile.TileSpriteWidth / 2), (x + y + size) * Tile.TileSpriteHeight / 2) + adjust2,
103 new Vector2(((x - (y + size)) * Tile.TileSpriteWidth / 2), (x + y + size) * Tile.TileSpriteHeight / 2) + adjust2,
104 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
104 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
105 new Vector2(((x + size - (y + size)) * Tile.TileSpriteWidth / 2), (x + size + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2,
105 new Vector2(((x + size - (y + size)) * Tile.TileSpriteWidth / 2), (x + size + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2,
106 color, 0.79f);
106 color, 0.77f);
107 //Upper left
107 //Upper left
108 Line.drawLine(batch,
108 Line.drawLine(batch,
109 new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2,
109 new Vector2(((x - y) * Tile.TileSpriteWidth / 2), (x + y) * Tile.TileSpriteHeight / 2) + adjust2,
110 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
110 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
111 new Vector2(((x - (y + size)) * Tile.TileSpriteWidth / 2), (x + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2,
111 new Vector2(((x - (y + size)) * Tile.TileSpriteWidth / 2), (x + (y + size)) * Tile.TileSpriteHeight / 2) + adjust2,
112 color, 0.79f);
112 color, 0.77f);
113 }
113 }
114
114
115
115
@@ -89,6 +89,9
89 <None Include="Content\FNASound.wav">
89 <None Include="Content\FNASound.wav">
90 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
90 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
91 </None>
91 </None>
92 <None Include="Content\Click.wav">
93 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
94 </None>
92 <None Include="packages.config" />
95 <None Include="packages.config" />
93 <!-- <None Include="Content\part4_tileset.png"> -->
96 <!-- <None Include="Content\part4_tileset.png"> -->
94 <!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> -->
97 <!-- <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> -->
You need to be logged in to leave comments. Login now