2
0

CatapultGame.cs 3.1 KB

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