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.

Bullet.Ghost.cs 8.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. using System;
  4. namespace GameClass.GameObj
  5. {
  6. internal sealed class CommonAttackOfGhost : Bullet
  7. {
  8. public CommonAttackOfGhost(Character player, int radius = GameData.bulletRadius) :
  9. base(player, radius)
  10. {
  11. }
  12. public override double BulletBombRange => 0;
  13. public override double BulletAttackRange => GameData.basicAttackShortRange;
  14. public override int AP => GameData.basicApOfGhost;
  15. public override int Speed => GameData.basicBulletMoveSpeed;
  16. public override bool IsToBomb => false;
  17. public override int Backswing => GameData.basicBackswing;
  18. public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
  19. public override bool CanAttack(GameObj target)
  20. {
  21. return false;
  22. }
  23. public override BulletType TypeOfBullet => BulletType.CommonAttackOfGhost;
  24. }
  25. internal sealed class FlyingKnife : Bullet
  26. {
  27. public FlyingKnife(Character player, int radius = GameData.bulletRadius) :
  28. base(player, radius)
  29. {
  30. }
  31. public override double BulletBombRange => 0;
  32. public override double BulletAttackRange => GameData.basicRemoteAttackRange * 13;
  33. public override int AP => GameData.basicApOfGhost / 5 * 4;
  34. public override int Speed => GameData.basicBulletMoveSpeed * 2;
  35. public override bool IsToBomb => false;
  36. public override int Backswing => GameData.basicBackswing / 5 * 3;
  37. public override int RecoveryFromHit => GameData.basicRecoveryFromHit / 4 * 3;
  38. public override bool CanAttack(GameObj target)
  39. {
  40. return false;
  41. }
  42. public override BulletType TypeOfBullet => BulletType.FlyingKnife;
  43. }
  44. internal sealed class AtomBomb : Bullet
  45. {
  46. public AtomBomb(Character player, int radius = GameData.bulletRadius) :
  47. base(player, radius)
  48. {
  49. }
  50. public override double BulletBombRange => GameData.basicBulletBombRange / 3 * 7;
  51. public override double BulletAttackRange => GameData.basicAttackShortRange / 9 * 7;
  52. public override int AP => GameData.basicApOfGhost / 3 * 7;
  53. public override int Speed => GameData.basicBulletMoveSpeed / 3 * 2;
  54. public override int Backswing => GameData.basicBackswing;
  55. public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
  56. public override bool IsToBomb => true;
  57. public override bool CanAttack(GameObj target)
  58. {
  59. // 圆形攻击范围
  60. return XY.Distance(this.Position, target.Position) <= BulletBombRange;
  61. }
  62. public override BulletType TypeOfBullet => BulletType.AtomBomb;
  63. }
  64. internal sealed class OrdinaryBullet : Bullet // 1倍攻击范围,1倍攻击力,一倍速
  65. {
  66. public OrdinaryBullet(Character player, int radius = GameData.bulletRadius) :
  67. base(player, radius)
  68. {
  69. }
  70. public override double BulletBombRange => GameData.basicBulletBombRange / 6 * 5;
  71. public override double BulletAttackRange => GameData.basicAttackShortRange / 2;
  72. public override int AP => GameData.basicApOfGhost / 6 * 5;
  73. public override int Speed => GameData.basicBulletMoveSpeed / 6 * 5;
  74. public override int Backswing => GameData.basicBackswing;
  75. public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
  76. public override bool IsToBomb => true;
  77. public override bool CanAttack(GameObj target)
  78. {
  79. // 圆形攻击范围
  80. return XY.Distance(this.Position, target.Position) <= BulletBombRange;
  81. }
  82. public override BulletType TypeOfBullet => BulletType.OrdinaryBullet;
  83. }
  84. internal sealed class FastBullet : Bullet // 1倍攻击范围,0.2倍攻击力,2倍速
  85. {
  86. public FastBullet(Character player, int radius = GameData.bulletRadius) :
  87. base(player, radius)
  88. {
  89. }
  90. public override double BulletBombRange => GameData.basicBulletBombRange / 4 * 2;
  91. public override double BulletAttackRange => GameData.basicAttackShortRange;
  92. public override int AP => (int)(0.5 * GameData.basicApOfGhost);
  93. public override int Speed => 5 * GameData.basicBulletMoveSpeed / 3;
  94. public override int Backswing => GameData.basicBackswing;
  95. public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
  96. public override bool IsToBomb => true;
  97. public override bool CanAttack(GameObj target)
  98. {
  99. // 圆形攻击范围
  100. return XY.Distance(this.Position, target.Position) <= BulletBombRange;
  101. }
  102. public override BulletType TypeOfBullet => BulletType.FastBullet;
  103. }
  104. internal sealed class LineBullet : Bullet // 直线爆炸,宽度1格,长度为2倍爆炸范围
  105. {
  106. public LineBullet(Character player, int radius = GameData.bulletRadius) :
  107. base(player, radius)
  108. {
  109. }
  110. public override double BulletBombRange => GameData.basicBulletBombRange / 3 * 4;
  111. public override double BulletAttackRange => 0.1 * GameData.basicAttackShortRange;
  112. public override int AP => GameData.basicApOfGhost / 3 * 2;
  113. public override int Speed => GameData.basicBulletMoveSpeed / 3;
  114. public override int Backswing => GameData.basicBackswing;
  115. public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
  116. public override bool IsToBomb => true;
  117. public override bool CanAttack(GameObj target)
  118. {
  119. double FacingAngle = Math.Atan2(this.FacingDirection.y, this.FacingDirection.x);
  120. if (Math.Abs(FacingAngle - Math.PI / 2) < 1e-2)
  121. {
  122. if (target.Position.y - this.Position.y > BulletBombRange)
  123. return false;
  124. if (target.Position.x < this.Position.x + GameData.numOfPosGridPerCell / 2 && target.Position.x > this.Position.x - GameData.numOfPosGridPerCell / 2)
  125. return true;
  126. return false;
  127. }
  128. else if (Math.Abs(FacingAngle - Math.PI * 3 / 2) < 1e-2)
  129. {
  130. if (target.Position.y - this.Position.y < -BulletBombRange)
  131. return false;
  132. if (target.Position.x < this.Position.x + GameData.numOfPosGridPerCell / 2 && target.Position.x > this.Position.x - GameData.numOfPosGridPerCell / 2)
  133. return true;
  134. return false;
  135. }
  136. else if (Math.Abs(FacingAngle) < 1e-2)
  137. {
  138. if (target.Position.x - this.Position.x > BulletBombRange)
  139. return false;
  140. if (target.Position.y < this.Position.y + GameData.numOfPosGridPerCell / 2 && target.Position.y > this.Position.y - GameData.numOfPosGridPerCell / 2)
  141. return true;
  142. return false;
  143. }
  144. else if (Math.Abs(FacingAngle - Math.PI) < 1e-2)
  145. {
  146. if (target.Position.x - this.Position.x < -BulletBombRange)
  147. return false;
  148. if (target.Position.y < this.Position.y + GameData.numOfPosGridPerCell / 2 && target.Position.y > this.Position.y - GameData.numOfPosGridPerCell / 2)
  149. return true;
  150. return false;
  151. }
  152. double vertical = Math.Tan(FacingAngle + Math.PI / 2);
  153. bool posValue = vertical * Math.Cos(FacingAngle) - Math.Sin(FacingAngle) > 0;
  154. double dist;
  155. dist = vertical * (target.Position.x - this.Position.x) - (target.Position.y - this.Position.y) / Math.Sqrt(1 + vertical * vertical);
  156. if (Math.Abs(dist) > BulletBombRange)
  157. return false;
  158. else if (dist < 0 && posValue) // 位于直线两侧
  159. return false;
  160. vertical = Math.Tan(FacingAngle);
  161. dist = Math.Abs(vertical * (target.Position.x - this.Position.x) - (target.Position.y - this.Position.y)) / Math.Sqrt(1 + vertical * vertical);
  162. if (dist > GameData.numOfPosGridPerCell / 2)
  163. return false;
  164. return true;
  165. }
  166. public override BulletType TypeOfBullet => BulletType.LineBullet;
  167. }
  168. }