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