PlayerStatus.cs 495 B

12345678910111213141516171819202122232425262728293031
  1. namespace LearnStorage
  2. {
  3. /// <summary>
  4. ///
  5. /// </summary>
  6. public class PlayerStatus
  7. {
  8. private int health = 100;
  9. private int armor = 100;
  10. public int Health
  11. { // 保险做法 // 避免生命值被直接修改
  12. get
  13. {
  14. return this.health; // 把血量返回出去
  15. }
  16. set
  17. {
  18. this.health = value; // 将传入值赋给health
  19. }
  20. }
  21. public int Armor
  22. {
  23. get
  24. {
  25. return this.armor;
  26. }
  27. }
  28. }
  29. }