2
0

RolePlayingGame.cs 4.3 KB

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