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 6.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using Preparation.Utility;
  2. using Preparation.Interface;
  3. using System;
  4. namespace GameClass.GameObj
  5. {
  6. public class Student : Character
  7. {
  8. /// <summary>
  9. /// 遭受攻击
  10. /// </summary>
  11. /// <param name="subHP"></param>
  12. /// <param name="hasSpear"></param>
  13. /// <param name="attacker">伤害来源</param>
  14. /// <returns>人物在受到攻击后死了吗</returns>
  15. public bool BeAttacked(Bullet bullet)
  16. {
  17. #if DEBUG
  18. Debugger.Output(this, "is being shot!");
  19. #endif
  20. lock (beAttackedLock)
  21. {
  22. if (hp <= 0 || NoHp())
  23. return false; // 原来已经死了
  24. if (bullet.Parent.IsGhost() != this.IsGhost())
  25. {
  26. #if DEBUG
  27. Debugger.Output(bullet, " 's AP is " + bullet.AP.ToString());
  28. #endif
  29. if (TryUseShield())
  30. {
  31. if (bullet.HasSpear)
  32. {
  33. int subHp = TrySubHp(bullet.AP);
  34. #if DEBUG
  35. Debugger.Output(this, "is being shot! Now his hp is" + HP.ToString());
  36. #endif
  37. bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(subHp) + GameData.ScorePropUseSpear);
  38. bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * subHp));
  39. }
  40. else
  41. return false;
  42. }
  43. else
  44. {
  45. int subHp;
  46. if (bullet.HasSpear)
  47. {
  48. subHp = TrySubHp(bullet.AP + GameData.ApSpearAdd);
  49. #if DEBUG
  50. Debugger.Output(this, "is being shot with Spear! Now his hp is" + HP.ToString());
  51. #endif
  52. }
  53. else
  54. {
  55. subHp = TrySubHp(bullet.AP);
  56. #if DEBUG
  57. Debugger.Output(this, "is being shot! Now his hp is" + HP.ToString());
  58. #endif
  59. }
  60. bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(subHp));
  61. bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * subHp));
  62. }
  63. if (hp <= 0)
  64. TryActivatingLIFE(); // 如果有复活甲
  65. }
  66. return hp <= 0;
  67. }
  68. }
  69. protected int fixSpeed;
  70. /// <summary>
  71. /// 修理电机速度
  72. /// </summary>
  73. public int FixSpeed
  74. {
  75. get => fixSpeed;
  76. set
  77. {
  78. lock (gameObjLock)
  79. {
  80. fixSpeed = value;
  81. }
  82. }
  83. }
  84. /// <summary>
  85. /// 原初修理电机速度
  86. /// </summary>
  87. public int OrgFixSpeed { get; protected set; }
  88. protected int treatSpeed = GameData.basicTreatSpeed;
  89. public int TreatSpeed
  90. {
  91. get => treatSpeed;
  92. set
  93. {
  94. lock (gameObjLock)
  95. {
  96. treatSpeed = value;
  97. }
  98. }
  99. }
  100. public int OrgTreatSpeed { get; protected set; }
  101. public int MaxGamingAddiction { get; protected set; }
  102. private int gamingAddiction;
  103. public int GamingAddiction
  104. {
  105. get => gamingAddiction;
  106. set
  107. {
  108. if (value > 0)
  109. lock (gameObjLock)
  110. gamingAddiction = value <= MaxGamingAddiction ? value : MaxGamingAddiction;
  111. else
  112. lock (gameObjLock)
  113. gamingAddiction = 0;
  114. }
  115. }
  116. private int selfHealingTimes = 1;//剩余的自愈次数
  117. public int SelfHealingTimes
  118. {
  119. get => selfHealingTimes;
  120. set
  121. {
  122. lock (gameObjLock)
  123. selfHealingTimes = (value > 0) ? value : 0;
  124. }
  125. }
  126. private int degreeOfTreatment = 0;
  127. public int DegreeOfTreatment
  128. {
  129. get => degreeOfTreatment;
  130. set
  131. {
  132. if (value > 0)
  133. lock (gameObjLock)
  134. degreeOfTreatment = (value < MaxHp - HP) ? value : MaxHp - HP;
  135. else
  136. lock (gameObjLock)
  137. degreeOfTreatment = 0;
  138. }
  139. }
  140. private int timeOfRescue = 0;
  141. public int TimeOfRescue
  142. {
  143. get => timeOfRescue;
  144. set
  145. {
  146. if (value > 0)
  147. lock (gameObjLock)
  148. timeOfRescue = (value < GameData.basicTimeOfRescue) ? value : GameData.basicTimeOfRescue;
  149. else
  150. lock (gameObjLock)
  151. timeOfRescue = 0;
  152. }
  153. }
  154. public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType)
  155. {
  156. this.OrgFixSpeed = this.fixSpeed = ((IStudent)Occupation).FixSpeed;
  157. this.TreatSpeed = this.OrgTreatSpeed = ((IStudent)Occupation).TreatSpeed;
  158. this.MaxGamingAddiction = ((IStudent)Occupation).MaxGamingAddiction;
  159. }
  160. }
  161. public class Golem : Student
  162. {
  163. private Character? parent; // 主人
  164. public Character? Parent
  165. {
  166. get => parent;
  167. set
  168. {
  169. lock (gameObjLock)
  170. {
  171. parent = value;
  172. }
  173. }
  174. }
  175. public Golem(XY initPos, int initRadius, Character? parent) : base(initPos, initRadius, CharacterType.Robot)
  176. {
  177. this.parent = parent;
  178. }
  179. }
  180. }