RolePlayingGame.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //-----------------------------------------------------------------------------
  2. // RolePlayingGame.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using Microsoft.Xna.Framework;
  8. using Microsoft.Xna.Framework.Audio;
  9. using Microsoft.Xna.Framework.Content;
  10. using Microsoft.Xna.Framework.Graphics;
  11. using Microsoft.Xna.Framework.Input;
  12. using RolePlayingGameData;
  13. namespace RolePlaying
  14. {
  15. /// <summary>
  16. /// The Game object for the Role-Playing Game starter kit.
  17. /// </summary>
  18. public class RolePlayingGame : Game
  19. {
  20. internal const int BUFFER_WIDTH = 1280;
  21. internal const int BUFFER_HEIGHT = 720;
  22. GraphicsDeviceManager graphics;
  23. ScreenManager screenManager;
  24. /// <summary>
  25. /// Create a new RolePlayingGame object.
  26. /// </summary>
  27. public RolePlayingGame()
  28. {
  29. // initialize the graphics system
  30. graphics = new GraphicsDeviceManager(this);
  31. graphics.PreferredBackBufferWidth = BUFFER_WIDTH;
  32. graphics.PreferredBackBufferHeight = BUFFER_HEIGHT;
  33. // configure the content manager
  34. Content.RootDirectory = "Content";
  35. // add a gamer-services component, which is required for the storage APIs
  36. // TODO: GamerServicesComponent was XNA-specific and not available in MonoGame
  37. // Components.Add(new GamerServicesComponent(this));
  38. // add the audio manager
  39. AudioManager.Initialize(this, @"Content\Audio\RpgAudio.xgs",
  40. @"Content\Audio\Wave Bank.xwb", @"Content\Audio\Sound Bank.xsb");
  41. // add the screen manager
  42. screenManager = new ScreenManager(this);
  43. Components.Add(screenManager);
  44. }
  45. /// <summary>
  46. /// Allows the game to perform any initialization it needs to
  47. /// before starting to run. This is where it can query for any required
  48. /// services and load any non-graphic related content. Calling base.Initialize
  49. /// will enumerate through any components and initialize them as well.
  50. /// </summary>
  51. protected override void Initialize()
  52. {
  53. InputManager.Initialize();
  54. base.Initialize();
  55. TileEngine.Viewport = graphics.GraphicsDevice.Viewport;
  56. screenManager.AddScreen(new MainMenuScreen());
  57. }
  58. /// <summary>
  59. /// LoadContent will be called once per game and is the place to load
  60. /// all of your content.
  61. /// </summary>
  62. protected override void LoadContent()
  63. {
  64. Fonts.LoadContent(Content);
  65. base.LoadContent();
  66. }
  67. /// <summary>
  68. /// UnloadContent will be called once per game and is the place to unload
  69. /// all content.
  70. /// </summary>
  71. protected override void UnloadContent()
  72. {
  73. Fonts.UnloadContent();
  74. base.UnloadContent();
  75. }
  76. /// <summary>
  77. /// Allows the game to run logic such as updating the world,
  78. /// checking for collisions, gathering input, and playing audio.
  79. /// </summary>
  80. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  81. protected override void Update(GameTime gameTime)
  82. {
  83. InputManager.Update();
  84. base.Update(gameTime);
  85. }
  86. /// <summary>
  87. /// This is called when the game should draw itself.
  88. /// </summary>
  89. /// <param name="gameTime">Provides a snapshot of timing values.</param>
  90. protected override void Draw(GameTime gameTime)
  91. {
  92. graphics.GraphicsDevice.Clear(Color.Transparent);
  93. base.Draw(gameTime);
  94. }
  95. /// <summary>
  96. /// The main entry point for the application.
  97. /// </summary>
  98. // static void Main(string[] args)
  99. // {
  100. // using (RolePlayingGame game = new RolePlayingGame())
  101. // {
  102. // game.Run();
  103. // }
  104. // }
  105. }
  106. }