PlayerSaveData.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //-----------------------------------------------------------------------------
  2. // PlayerSaveData.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using System;
  8. using System.Collections.Generic;
  9. using RolePlaying.Data;
  10. namespace RolePlaying
  11. {
  12. /// <summary>
  13. /// Serializable data for the state of a player.
  14. /// </summary>
  15. public class PlayerSaveData
  16. {
  17. /// <summary>
  18. /// The asset name of the player itself.
  19. /// </summary>
  20. public string assetName;
  21. /// <summary>
  22. /// The character level of the player.
  23. /// </summary>
  24. public int characterLevel;
  25. /// <summary>
  26. /// The experience gained by the player since their last level.
  27. /// </summary>
  28. public int experience;
  29. /// <summary>
  30. /// The asset names of the equipped gear.
  31. /// </summary>
  32. public List<string> equipmentAssetNames = new List<string>();
  33. /// <summary>
  34. /// All permanent statistics modifiers to the character (i.e. damage).
  35. /// </summary>
  36. public StatisticsValue statisticsModifiers;
  37. /// <summary>
  38. /// Creates a new PlayerData object.
  39. /// </summary>
  40. public PlayerSaveData() { }
  41. /// <summary>
  42. /// Creates a new PlayerData object from the given Player object.
  43. /// </summary>
  44. public PlayerSaveData(Player player)
  45. : this()
  46. {
  47. // check the parameter
  48. if (player == null)
  49. {
  50. throw new ArgumentNullException("player");
  51. }
  52. assetName = player.AssetName;
  53. characterLevel = player.CharacterLevel;
  54. experience = player.Experience;
  55. foreach (Equipment equipment in player.EquippedEquipment)
  56. {
  57. equipmentAssetNames.Add(equipment.AssetName);
  58. }
  59. statisticsModifiers = player.StatisticsModifiers;
  60. }
  61. }
  62. }