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.

SkillManager.PassiveSkill.cs 7.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Reflection.Emit;
  3. using System.Threading;
  4. using GameClass.GameObj;
  5. using Preparation.Interface;
  6. using Preparation.Utility;
  7. using Timothy.FrameRateTask;
  8. namespace Gaming // 被动技能开局时就释放,持续到游戏结束
  9. {
  10. public partial class Game
  11. {
  12. private partial class SkillManager
  13. {
  14. public void Meditate(Character player)
  15. {
  16. const int learningDegree = GameData.basicFixSpeed / 4;
  17. WriteAnswers activeSkill = (WriteAnswers)player.FindIActiveSkill(ActiveSkillType.WriteAnswers);
  18. new Thread
  19. (
  20. () =>
  21. {
  22. new FrameRateTaskExecutor<int>
  23. (
  24. () => gameMap.Timer.IsGaming && !player.IsResetting,
  25. () =>
  26. {
  27. if (player.Commandable()) activeSkill.DegreeOfMeditation += learningDegree;
  28. else activeSkill.DegreeOfMeditation = 0;
  29. Debugger.Output(player, "with " + (((WriteAnswers)activeSkill).DegreeOfMeditation).ToString());
  30. },
  31. timeInterval: GameData.frameDuration,
  32. () => 0,
  33. maxTotalDuration: GameData.gameDuration
  34. )
  35. {
  36. AllowTimeExceed = true,
  37. MaxTolerantTimeExceedCount = ulong.MaxValue,
  38. TimeExceedAction = b =>
  39. {
  40. if (b)
  41. Console.WriteLine("Fetal Error: The computer runs so slow that passive skill time exceeds!!!!!!");
  42. #if DEBUG
  43. else
  44. {
  45. Console.WriteLine("Debug info: passive skill time exceeds for once.");
  46. }
  47. #endif
  48. }
  49. }.Start();
  50. }
  51. )
  52. { IsBackground = true }.Start();
  53. }
  54. public void RecoverAfterBattle(Character player)
  55. {
  56. const int recoverDegree = 5; // 每帧回复血量
  57. int nowHP = player.HP;
  58. int lastHP = nowHP;
  59. long waitTime = 0;
  60. const long interval = 10000; // 每隔interval时间不受伤害,角色即开始回血
  61. new Thread
  62. (
  63. () =>
  64. {
  65. new FrameRateTaskExecutor<int>
  66. (
  67. () => true,
  68. () =>
  69. {
  70. lastHP = nowHP; // lastHP等于上一帧的HP
  71. nowHP = player.HP; // nowHP更新为这一帧的HP
  72. if (lastHP > nowHP) // 这一帧扣血了
  73. {
  74. waitTime = 0;
  75. }
  76. else if (waitTime < interval)
  77. {
  78. waitTime += GameData.frameDuration;
  79. }
  80. if (waitTime >= interval) // 回复时,每帧(50ms)回复5,即1s回复100。
  81. player.TryAddHp(recoverDegree);
  82. },
  83. timeInterval: GameData.frameDuration,
  84. () => 0,
  85. maxTotalDuration: GameData.gameDuration
  86. )
  87. {
  88. AllowTimeExceed = true,
  89. MaxTolerantTimeExceedCount = ulong.MaxValue,
  90. TimeExceedAction = b =>
  91. {
  92. if (b)
  93. Console.WriteLine("Fetal Error: The computer runs so slow that passive skill time exceeds!!!!!!");
  94. #if DEBUG
  95. else
  96. {
  97. Console.WriteLine("Debug info: passive skill time exceeds for once.");
  98. }
  99. #endif
  100. }
  101. }.Start();
  102. }
  103. )
  104. { IsBackground = true }.Start();
  105. }
  106. public void SpeedUpWhenLeavingGrass(Character player)
  107. {
  108. PlaceType nowPlace = gameMap.GetPlaceType(player.Position);
  109. PlaceType lastPlace = nowPlace;
  110. bool speedup = false;
  111. const int SpeedUpTime = 2000; // 加速时间:2s
  112. new Thread
  113. (
  114. () =>
  115. {
  116. new FrameRateTaskExecutor<int>
  117. (
  118. () => true,
  119. () =>
  120. {
  121. lastPlace = nowPlace;
  122. nowPlace = gameMap.GetPlaceType(player.Position);
  123. if ((lastPlace == PlaceType.Grass) && nowPlace == PlaceType.Null)
  124. {
  125. if (!speedup)
  126. {
  127. new Thread(() =>
  128. {
  129. speedup = true;
  130. player.AddMoveSpeed(SpeedUpTime, 3.0);
  131. speedup = false;
  132. })
  133. { IsBackground = true }.Start();
  134. }
  135. }
  136. },
  137. timeInterval: GameData.frameDuration,
  138. () => 0,
  139. maxTotalDuration: GameData.gameDuration
  140. )
  141. {
  142. AllowTimeExceed = true,
  143. MaxTolerantTimeExceedCount = ulong.MaxValue,
  144. TimeExceedAction = b =>
  145. {
  146. if (b)
  147. Console.WriteLine("Fetal Error: The computer runs so slow that passive skill time exceeds!!!!!!");
  148. #if DEBUG
  149. else
  150. {
  151. Console.WriteLine("Debug info: passive skill time exceeds for once.");
  152. }
  153. #endif
  154. }
  155. }.Start();
  156. }
  157. )
  158. { IsBackground = true }.Start();
  159. }
  160. public void Vampire(Character player)
  161. {
  162. player.OriVampire = 0.5;
  163. player.Vampire = player.OriVampire;
  164. }
  165. }
  166. }
  167. }