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 9.0 kB

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