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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using Preparation.Utility;
  2. using Preparation.Interface;
  3. using System;
  4. namespace GameClass.GameObj
  5. {
  6. public class Student : Character
  7. {
  8. private readonly object beAttackedLock = new();
  9. /// <summary>
  10. /// 遭受攻击
  11. /// </summary>
  12. /// <param name="subHP"></param>
  13. /// <param name="hasSpear"></param>
  14. /// <param name="attacker">伤害来源</param>
  15. /// <returns>人物在受到攻击后死了吗</returns>
  16. public bool BeAttacked(Bullet bullet)
  17. {
  18. lock (beAttackedLock)
  19. {
  20. if (hp <= 0 || NoHp())
  21. return false; // 原来已经死了
  22. if (bullet.Parent.TeamID != this.TeamID)
  23. {
  24. if (CanBeAwed()) PlayerState = PlayerStateType.Stunned;
  25. if (HasShield)
  26. {
  27. if (bullet.HasSpear)
  28. _ = TrySubHp(bullet.AP);
  29. else
  30. return false;
  31. }
  32. else
  33. {
  34. bullet.Parent.HP = (int)(bullet.Parent.HP + (bullet.Parent.Vampire * TrySubHp(bullet.AP)));
  35. }
  36. #if DEBUG
  37. Console.WriteLine($"PlayerID:{ID} is being shot! Now his hp is {hp}.");
  38. #endif
  39. if (hp <= 0)
  40. TryActivatingLIFE(); // 如果有复活甲
  41. }
  42. return hp <= 0;
  43. }
  44. }
  45. protected int fixSpeed;
  46. /// <summary>
  47. /// 修理电机速度
  48. /// </summary>
  49. public int FixSpeed
  50. {
  51. get => fixSpeed;
  52. set
  53. {
  54. lock (gameObjLock)
  55. {
  56. fixSpeed = value;
  57. }
  58. }
  59. }
  60. /// <summary>
  61. /// 原初修理电机速度
  62. /// </summary>
  63. public int OrgFixSpeed { get; protected set; }
  64. protected int treatSpeed = GameData.basicTreatSpeed;
  65. public int TreatSpeed
  66. {
  67. get => treatSpeed;
  68. set
  69. {
  70. lock (gameObjLock)
  71. {
  72. treatSpeed = value;
  73. }
  74. }
  75. }
  76. public int OrgTreatSpeed { get; protected set; }
  77. public int MaxGamingAddiction { get; protected set; }
  78. private int gamingAddiction;
  79. public int GamingAddiction
  80. {
  81. get => gamingAddiction;
  82. set
  83. {
  84. if (gamingAddiction > 0)
  85. lock (gameObjLock)
  86. gamingAddiction = value <= MaxGamingAddiction ? value : MaxGamingAddiction;
  87. else
  88. lock (gameObjLock)
  89. gamingAddiction = 0;
  90. }
  91. }
  92. private int selfHealingTimes = 1;//剩余的自愈次数
  93. public int SelfHealingTimes
  94. {
  95. get => selfHealingTimes;
  96. set
  97. {
  98. lock (gameObjLock)
  99. selfHealingTimes = (value > 0) ? value : 0;
  100. }
  101. }
  102. private int degreeOfTreatment = 0;
  103. public int DegreeOfTreatment
  104. {
  105. get => degreeOfTreatment;
  106. set
  107. {
  108. if (value > 0)
  109. lock (gameObjLock)
  110. degreeOfTreatment = (value < MaxHp - HP) ? value : MaxHp - HP;
  111. else
  112. lock (gameObjLock)
  113. degreeOfTreatment = 0;
  114. }
  115. }
  116. private int timeOfRescue = 0;
  117. public int TimeOfRescue
  118. {
  119. get => timeOfRescue;
  120. set
  121. {
  122. if (value > 0)
  123. lock (gameObjLock)
  124. timeOfRescue = (value < GameData.basicTimeOfRescue) ? value : GameData.basicTimeOfRescue;
  125. else
  126. lock (gameObjLock)
  127. timeOfRescue = 0;
  128. }
  129. }
  130. public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType)
  131. {
  132. this.OrgFixSpeed = this.fixSpeed = ((IStudent)Occupation).FixSpeed;
  133. }
  134. }
  135. }