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

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