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

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