You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Character.Student.cs 4.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using Preparation.Utility;
  2. using Preparation.Interface;
  3. using System;
  4. namespace GameClass.GameObj
  5. {
  6. public class Student : Character
  7. {
  8. protected int fixSpeed;
  9. /// <summary>
  10. /// 修理电机速度
  11. /// </summary>
  12. public int FixSpeed
  13. {
  14. get => fixSpeed;
  15. set
  16. {
  17. lock (gameObjLock)
  18. {
  19. fixSpeed = value;
  20. }
  21. }
  22. }
  23. /// <summary>
  24. /// 原初修理电机速度
  25. /// </summary>
  26. public int OrgFixSpeed { get; protected set; }
  27. protected int treatSpeed = GameData.basicTreatSpeed;
  28. public int TreatSpeed
  29. {
  30. get => treatSpeed;
  31. set
  32. {
  33. lock (gameObjLock)
  34. {
  35. treatSpeed = value;
  36. }
  37. }
  38. }
  39. public int OrgTreatSpeed { get; protected set; }
  40. public int MaxGamingAddiction { get; protected set; }
  41. private int gamingAddiction;
  42. public int GamingAddiction
  43. {
  44. get => gamingAddiction;
  45. set
  46. {
  47. if (value > 0)
  48. lock (gameObjLock)
  49. gamingAddiction = value <= MaxGamingAddiction ? value : MaxGamingAddiction;
  50. else
  51. lock (gameObjLock)
  52. gamingAddiction = 0;
  53. }
  54. }
  55. private int selfHealingTimes = 1;//剩余的自愈次数
  56. public int SelfHealingTimes
  57. {
  58. get => selfHealingTimes;
  59. set
  60. {
  61. lock (gameObjLock)
  62. selfHealingTimes = (value > 0) ? value : 0;
  63. }
  64. }
  65. private int degreeOfTreatment = 0;
  66. public int DegreeOfTreatment
  67. {
  68. get => degreeOfTreatment;
  69. private set
  70. {
  71. degreeOfTreatment = value;
  72. }
  73. }
  74. public void SetDegreeOfTreatment0()
  75. {
  76. DegreeOfTreatment = 0;
  77. }
  78. public bool SetDegreeOfTreatment(int value, Student whoTreatYou)
  79. {
  80. if (value <= 0) { degreeOfTreatment = 0; return false; }
  81. if (value >= MaxHp - HP)
  82. {
  83. whoTreatYou.AddScore(GameData.StudentScoreTreat(MaxHp - HP));
  84. HP = MaxHp;
  85. degreeOfTreatment = 0;
  86. return true;
  87. }
  88. if (value >= GameData.basicTreatmentDegree)
  89. {
  90. whoTreatYou.AddScore(GameData.StudentScoreTreat(GameData.basicTreatmentDegree));
  91. HP += GameData.basicTreatmentDegree;
  92. DegreeOfTreatment = 0;
  93. return true;
  94. }
  95. DegreeOfTreatment = value;
  96. return false;
  97. }
  98. public bool AddDegreeOfTreatment(int value, Student student)
  99. {
  100. return SetDegreeOfTreatment(value + degreeOfTreatment, student);
  101. }
  102. private int timeOfRescue = 0;
  103. public int TimeOfRescue
  104. {
  105. get => timeOfRescue;
  106. set
  107. {
  108. if (value > 0)
  109. lock (gameObjLock)
  110. timeOfRescue = (value < GameData.basicTimeOfRescue) ? value : GameData.basicTimeOfRescue;
  111. else
  112. lock (gameObjLock)
  113. timeOfRescue = 0;
  114. }
  115. }
  116. public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType)
  117. {
  118. this.OrgFixSpeed = this.fixSpeed = ((IStudentType)Occupation).FixSpeed;
  119. this.TreatSpeed = this.OrgTreatSpeed = ((IStudentType)Occupation).TreatSpeed;
  120. this.MaxGamingAddiction = ((IStudentType)Occupation).MaxGamingAddiction;
  121. }
  122. }
  123. public class Golem : Student, IGolem
  124. {
  125. private Character? parent; // 主人
  126. public Character? Parent
  127. {
  128. get => parent;
  129. set
  130. {
  131. lock (gameObjLock)
  132. {
  133. parent = value;
  134. }
  135. }
  136. }
  137. public override void AddScore(long add)
  138. {
  139. if (parent == null)
  140. base.AddScore(add);
  141. else parent.AddScore(add);
  142. }
  143. public Golem(XY initPos, int initRadius, Character? parent) : base(initPos, initRadius, CharacterType.Robot)
  144. {
  145. this.parent = parent;
  146. }
  147. }
  148. }