CatapultGame.cs 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //-----------------------------------------------------------------------------
  2. // CatapultGame.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using Microsoft.Xna.Framework;
  11. using Microsoft.Xna.Framework.Audio;
  12. using Microsoft.Xna.Framework.Content;
  13. //using Microsoft.Xna.Framework.GamerServices; // Not available in MonoGame 3.8
  14. using Microsoft.Xna.Framework.Graphics;
  15. using Microsoft.Xna.Framework.Input;
  16. using Microsoft.Xna.Framework.Input.Touch;
  17. using Microsoft.Xna.Framework.Media;
  18. //using Microsoft.Xna.Framework.Net; // Not available in MonoGame 3.8
  19. using GameStateManagement;
  20. namespace CatapultGame
  21. {
  22. /// <summary>
  23. /// This is the main type for your game
  24. /// </summary>
  25. public class CatapultGame : Game
  26. {
  27. GraphicsDeviceManager graphics;
  28. ScreenManager screenManager;
  29. // By preloading any assets used by UI rendering, we avoid framerate glitches
  30. // when they suddenly need to be loaded in the middle of a menu transition.
  31. static readonly string[] preloadAssets =
  32. {
  33. "gradient",
  34. "cat",
  35. "chat_ready",
  36. "chat_able",
  37. "chat_talking",
  38. "chat_mute",
  39. };
  40. public CatapultGame ()
  41. {
  42. graphics = new GraphicsDeviceManager (this);
  43. //graphics.SynchronizeWithVerticalRetrace = false;
  44. Content.RootDirectory = "Content";
  45. // Frame rate is 30 fps by default for Windows Phone.
  46. TargetElapsedTime = TimeSpan.FromTicks (333333);
  47. //Create a new instance of the Screen Manager
  48. screenManager = new ScreenManager (this);
  49. Components.Add (screenManager);
  50. Components.Add (new MessageDisplayComponent (this));
  51. // Components.Add (new GamerServicesComponent (this)); // Not available in MonoGame 3.8
  52. //Add two new screens
  53. screenManager.AddScreen (new BackgroundScreen (), null);
  54. screenManager.AddScreen (new MainMenuScreen (), null);
  55. // Listen for invite notification events.
  56. // NetworkSession.InviteAccepted += (sender, e) => NetworkSessionComponent.InviteAccepted (screenManager, e); // Not available in MonoGame 3.8
  57. IsMouseVisible = true;
  58. #if ___MOBILE___
  59. graphics.IsFullScreen = true;
  60. #endif
  61. graphics.PreferredBackBufferHeight = 480;
  62. graphics.PreferredBackBufferWidth = 800;
  63. AudioManager.Initialize (this);
  64. }
  65. /// <summary>
  66. /// Allows the game to perform any initialization it needs to before starting to run.
  67. /// This is where it can query for any required services and load any non-graphic
  68. /// related content. Calling base.Initialize will enumerate through any components
  69. /// and initialize them as well.
  70. /// </summary>
  71. protected override void Initialize ()
  72. {
  73. base.Initialize ();
  74. }
  75. protected override void LoadContent ()
  76. {
  77. AudioManager.LoadSounds ();
  78. base.LoadContent ();
  79. }
  80. }
  81. }