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.cs 4.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using Preparation.Interface;
  2. using Preparation.Utility;
  3. using System;
  4. namespace GameClass.GameObj
  5. {
  6. public abstract class Bullet : ObjOfCharacter
  7. {
  8. /// <summary>
  9. /// //攻击力
  10. /// </summary>
  11. public abstract double BulletBombRange { get; }
  12. public abstract double BulletAttackRange { get; }
  13. public abstract int AP { get; }
  14. public abstract int Speed { get; }
  15. public abstract bool IsToBomb { get; }
  16. public abstract int CastTime { get; }
  17. public abstract int Backswing { get; }
  18. public abstract int RecoveryFromHit { get; }
  19. public abstract int CD { get; }
  20. private readonly bool hasSpear;
  21. /// <summary>
  22. /// 是否有矛
  23. /// </summary>
  24. public bool HasSpear => hasSpear;
  25. /// <summary>
  26. /// 与THUAI4不同的一个攻击判定方案,通过这个函数判断爆炸时能否伤害到target
  27. /// </summary>
  28. /// <param name="target">被尝试攻击者</param>
  29. /// <returns>是否可以攻击到</returns>
  30. public abstract bool CanAttack(GameObj target);
  31. public abstract bool CanBeBombed(GameObjType gameObjType);
  32. protected override bool IgnoreCollideExecutor(IGameObj targetObj)
  33. {
  34. if (targetObj.Type == GameObjType.Prop || targetObj.Type == GameObjType.Bullet)
  35. return true;
  36. return false;
  37. }
  38. public Bullet(Character player, int radius, PlaceType placeType, XY Position) :
  39. base(Position, radius, GameObjType.Bullet)
  40. {
  41. this.place = placeType;
  42. this.CanMove = true;
  43. this.moveSpeed = this.Speed;
  44. this.hasSpear = player.HasSpear;
  45. this.Parent = player;
  46. }
  47. public override bool IsRigid => true; // 默认为true
  48. public override ShapeType Shape => ShapeType.Circle; // 默认为圆形
  49. public abstract BulletType TypeOfBullet { get; }
  50. }
  51. public static class BulletFactory
  52. {
  53. public static Bullet? GetBullet(Character character, PlaceType place, XY pos)
  54. {
  55. switch (character.BulletOfPlayer)
  56. {
  57. case BulletType.FlyingKnife:
  58. return new FlyingKnife(character, place, pos);
  59. case BulletType.CommonAttackOfGhost:
  60. return new CommonAttackOfGhost(character, place, pos);
  61. case BulletType.AtomBomb:
  62. return new AtomBomb(character, place, pos);
  63. case BulletType.LineBullet:
  64. return new LineBullet(character, place, pos);
  65. case BulletType.FastBullet:
  66. return new FastBullet(character, place, pos);
  67. case BulletType.OrdinaryBullet:
  68. return new OrdinaryBullet(character, place, pos);
  69. default:
  70. return null;
  71. }
  72. }
  73. public static int BulletRadius(BulletType bulletType)
  74. {
  75. switch (bulletType)
  76. {
  77. case BulletType.AtomBomb:
  78. case BulletType.LineBullet:
  79. case BulletType.FastBullet:
  80. case BulletType.OrdinaryBullet:
  81. case BulletType.FlyingKnife:
  82. default:
  83. return GameData.bulletRadius;
  84. }
  85. }
  86. public static int BulletCD(BulletType bulletType)
  87. {
  88. switch (bulletType)
  89. {
  90. case BulletType.CommonAttackOfGhost:
  91. return CommonAttackOfGhost.cd;
  92. case BulletType.FlyingKnife:
  93. return FlyingKnife.cd;
  94. case BulletType.AtomBomb:
  95. case BulletType.LineBullet:
  96. case BulletType.FastBullet:
  97. case BulletType.OrdinaryBullet:
  98. default:
  99. return GameData.basicCD;
  100. }
  101. }
  102. }
  103. }