GameResourceTexture2D.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // GameResourceTexture2D.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.Text;
  13. using Microsoft.Xna.Framework;
  14. using Microsoft.Xna.Framework.Graphics;
  15. #endregion
  16. namespace RobotGameData.Resource
  17. {
  18. /// <summary>
  19. /// A resource element structure with Texture2D class.
  20. /// When an image file is loaded from the resource manager,
  21. /// it gets stored here.
  22. /// </summary>
  23. public class GameResourceTexture2D : GameResourceBase
  24. {
  25. #region Fields
  26. Texture2D texture2D = null;
  27. #endregion
  28. #region Properties
  29. public Texture2D Texture2D
  30. {
  31. get { return texture2D; }
  32. }
  33. #endregion
  34. /// <summary>
  35. /// Constructor.
  36. /// </summary>
  37. /// <param name="key">key name</param>
  38. /// <param name="assetName">asset name</param>
  39. /// <param name="resource">texture resource</param>
  40. public GameResourceTexture2D(string key, string assetName, Texture2D resource)
  41. : base(key, assetName)
  42. {
  43. this.texture2D = resource;
  44. this.resource = (object)this.texture2D;
  45. }
  46. protected override void Dispose(bool disposing)
  47. {
  48. if (disposing)
  49. {
  50. if (texture2D != null)
  51. {
  52. texture2D.Dispose();
  53. texture2D = null;
  54. }
  55. }
  56. base.Dispose(disposing);
  57. }
  58. }
  59. }