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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. lock (beAttackedLock)
  18. {
  19. if (hp <= 0 || NoHp())
  20. return false; // 原来已经死了
  21. if (bullet.Parent.TeamID != this.TeamID)
  22. {
  23. if (TryUseShield())
  24. {
  25. if (bullet.HasSpear)
  26. {
  27. int subHp = TrySubHp(bullet.AP);
  28. bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(subHp) + GameData.ScorePropUseSpear);
  29. bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * subHp));
  30. }
  31. else
  32. return false;
  33. }
  34. else
  35. {
  36. int subHp = TrySubHp(bullet.AP + GameData.ApSpearAdd);
  37. bullet.Parent.AddScore(GameData.TrickerScoreAttackStudent(subHp));
  38. bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * subHp));
  39. }
  40. #if DEBUG
  41. Console.WriteLine($"PlayerID:{ID} is being shot! Now his hp is {hp}.");
  42. #endif
  43. if (hp <= 0)
  44. TryActivatingLIFE(); // 如果有复活甲
  45. }
  46. return hp <= 0;
  47. }
  48. }
  49. protected int fixSpeed;
  50. /// <summary>
  51. /// 修理电机速度
  52. /// </summary>
  53. public int FixSpeed
  54. {
  55. get => fixSpeed;
  56. set
  57. {
  58. lock (gameObjLock)
  59. {
  60. fixSpeed = value;
  61. }
  62. }
  63. }
  64. /// <summary>
  65. /// 原初修理电机速度
  66. /// </summary>
  67. public int OrgFixSpeed { get; protected set; }
  68. protected int treatSpeed = GameData.basicTreatSpeed;
  69. public int TreatSpeed
  70. {
  71. get => treatSpeed;
  72. set
  73. {
  74. lock (gameObjLock)
  75. {
  76. treatSpeed = value;
  77. }
  78. }
  79. }
  80. public int OrgTreatSpeed { get; protected set; }
  81. public int MaxGamingAddiction { get; protected set; }
  82. private int gamingAddiction;
  83. public int GamingAddiction
  84. {
  85. get => gamingAddiction;
  86. set
  87. {
  88. if (gamingAddiction > 0)
  89. lock (gameObjLock)
  90. gamingAddiction = value <= MaxGamingAddiction ? value : MaxGamingAddiction;
  91. else
  92. lock (gameObjLock)
  93. gamingAddiction = 0;
  94. }
  95. }
  96. private int selfHealingTimes = 1;//剩余的自愈次数
  97. public int SelfHealingTimes
  98. {
  99. get => selfHealingTimes;
  100. set
  101. {
  102. lock (gameObjLock)
  103. selfHealingTimes = (value > 0) ? value : 0;
  104. }
  105. }
  106. private int degreeOfTreatment = 0;
  107. public int DegreeOfTreatment
  108. {
  109. get => degreeOfTreatment;
  110. set
  111. {
  112. if (value > 0)
  113. lock (gameObjLock)
  114. degreeOfTreatment = (value < MaxHp - HP) ? value : MaxHp - HP;
  115. else
  116. lock (gameObjLock)
  117. degreeOfTreatment = 0;
  118. }
  119. }
  120. private int timeOfRescue = 0;
  121. public int TimeOfRescue
  122. {
  123. get => timeOfRescue;
  124. set
  125. {
  126. if (value > 0)
  127. lock (gameObjLock)
  128. timeOfRescue = (value < GameData.basicTimeOfRescue) ? value : GameData.basicTimeOfRescue;
  129. else
  130. lock (gameObjLock)
  131. timeOfRescue = 0;
  132. }
  133. }
  134. public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType)
  135. {
  136. this.OrgFixSpeed = this.fixSpeed = ((IStudent)Occupation).FixSpeed;
  137. }
  138. }
  139. }