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.

PassiveSkill.cs 5.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. using System;
  2. using System.Threading;
  3. using GameClass.GameObj;
  4. using Preparation.GameData;
  5. using Preparation.Interface;
  6. using Preparation.Utility;
  7. using Timothy.FrameRateTask;
  8. namespace GameClass.Skill //被动技能开局时就释放,持续到游戏结束
  9. {
  10. public class RecoverAfterBattle : IPassiveSkill //脱战回血,普通子弹
  11. {
  12. private readonly BulletType initBullet = BulletType.OrdinaryBullet;
  13. public BulletType InitBullet => initBullet;
  14. //以上参数以后再改
  15. public void SkillEffect(Character player)
  16. {
  17. const int recoverDegree = 5; //每帧回复血量
  18. int nowHP = player.HP;
  19. int lastHP = nowHP;
  20. long waitTime = 0;
  21. const long interval = 10000; //每隔interval时间不受伤害,角色即开始回血
  22. new Thread
  23. (
  24. () =>
  25. {
  26. new FrameRateTaskExecutor<int>
  27. (
  28. () => true,
  29. () =>
  30. {
  31. lastHP = nowHP; //lastHP等于上一帧的HP
  32. nowHP = player.HP; //nowHP更新为这一帧的HP
  33. if (lastHP > nowHP) //这一帧扣血了
  34. {
  35. waitTime = 0;
  36. }
  37. else if (waitTime < interval)
  38. {
  39. waitTime += GameData.frameDuration;
  40. }
  41. if (waitTime >= interval) //回复时,每帧(50ms)回复5,即1s回复100。
  42. player.TryAddHp(recoverDegree);
  43. },
  44. timeInterval: GameData.frameDuration,
  45. () => 0,
  46. maxTotalDuration: GameData.gameDuration
  47. )
  48. {
  49. AllowTimeExceed = true,
  50. MaxTolerantTimeExceedCount = ulong.MaxValue,
  51. TimeExceedAction = b =>
  52. {
  53. if (b) Console.WriteLine("Fetal Error: The computer runs so slow that passive skill time exceeds!!!!!!");
  54. #if DEBUG
  55. else
  56. {
  57. Console.WriteLine("Debug info: passive skill time exceeds for once.");
  58. }
  59. #endif
  60. }
  61. }.Start();
  62. }
  63. )
  64. { IsBackground = true }.Start();
  65. }
  66. }
  67. public class SpeedUpWhenLeavingGrass : IPassiveSkill // 3倍速
  68. {
  69. private readonly BulletType initBullet = BulletType.FastBullet;
  70. public BulletType InitBullet => initBullet;
  71. //以上参数以后再改
  72. public void SkillEffect(Character player)
  73. {
  74. PlaceType nowPlace = player.Place;
  75. PlaceType lastPlace = nowPlace;
  76. bool speedup = false;
  77. const int SpeedUpTime = 2000; //加速时间:2s
  78. new Thread
  79. (
  80. () =>
  81. {
  82. new FrameRateTaskExecutor<int>
  83. (
  84. () => true,
  85. () =>
  86. {
  87. lastPlace = nowPlace;
  88. nowPlace = player.Place;
  89. if ((lastPlace == PlaceType.Grass1 || lastPlace == PlaceType.Grass2 || lastPlace == PlaceType.Grass3) && nowPlace == PlaceType.Land)
  90. {
  91. if (!speedup)
  92. {
  93. new Thread(() =>
  94. {
  95. speedup = true;
  96. player.AddMoveSpeed(SpeedUpTime, 3.0);
  97. speedup = false;
  98. })
  99. { IsBackground = true }.Start();
  100. }
  101. }
  102. },
  103. timeInterval: GameData.frameDuration,
  104. () => 0,
  105. maxTotalDuration: GameData.gameDuration
  106. )
  107. {
  108. AllowTimeExceed = true,
  109. MaxTolerantTimeExceedCount = ulong.MaxValue,
  110. TimeExceedAction = b =>
  111. {
  112. if (b) Console.WriteLine("Fetal Error: The computer runs so slow that passive skill time exceeds!!!!!!");
  113. #if DEBUG
  114. else
  115. {
  116. Console.WriteLine("Debug info: passive skill time exceeds for once.");
  117. }
  118. #endif
  119. }
  120. }.Start();
  121. }
  122. )
  123. { IsBackground = true }.Start();
  124. }
  125. }
  126. public class Vampire : IPassiveSkill //被动就是吸血,普通子弹
  127. {
  128. private readonly BulletType initBullet = BulletType.LineBullet;
  129. public BulletType InitBullet => initBullet;
  130. //以上参数以后再改
  131. public void SkillEffect(Character player)
  132. {
  133. player.OriVampire = 0.5;
  134. player.Vampire = player.OriVampire;
  135. }
  136. }
  137. public class NoPassiveSkill : IPassiveSkill //没技能,这种情况不应该发生,先定义着以防意外
  138. {
  139. private readonly BulletType initBullet = BulletType.OrdinaryBullet;
  140. public BulletType InitBullet => initBullet;
  141. //以上参数以后再改
  142. public void SkillEffect(Character player)
  143. {
  144. }
  145. }
  146. }