PlayerSaveData.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #region File Description
  2. //-----------------------------------------------------------------------------
  3. // PlayerSaveData.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 RolePlayingGameData;
  13. #endregion
  14. namespace RolePlaying
  15. {
  16. /// <summary>
  17. /// Serializable data for the state of a player.
  18. /// </summary>
  19. public class PlayerSaveData
  20. {
  21. /// <summary>
  22. /// The asset name of the player itself.
  23. /// </summary>
  24. public string assetName;
  25. /// <summary>
  26. /// The character level of the player.
  27. /// </summary>
  28. public int characterLevel;
  29. /// <summary>
  30. /// The experience gained by the player since their last level.
  31. /// </summary>
  32. public int experience;
  33. /// <summary>
  34. /// The asset names of the equipped gear.
  35. /// </summary>
  36. public List<string> equipmentAssetNames = new List<string>();
  37. /// <summary>
  38. /// All permanent statistics modifiers to the character (i.e. damage).
  39. /// </summary>
  40. public StatisticsValue statisticsModifiers;
  41. #region Initialization
  42. /// <summary>
  43. /// Creates a new PlayerData object.
  44. /// </summary>
  45. public PlayerSaveData() { }
  46. /// <summary>
  47. /// Creates a new PlayerData object from the given Player object.
  48. /// </summary>
  49. public PlayerSaveData(Player player)
  50. : this()
  51. {
  52. // check the parameter
  53. if (player == null)
  54. {
  55. throw new ArgumentNullException("player");
  56. }
  57. assetName = player.AssetName;
  58. characterLevel = player.CharacterLevel;
  59. experience = player.Experience;
  60. foreach (Equipment equipment in player.EquippedEquipment)
  61. {
  62. equipmentAssetNames.Add(equipment.AssetName);
  63. }
  64. statisticsModifiers = player.StatisticsModifiers;
  65. }
  66. #endregion
  67. }
  68. }