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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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; set; }
  14. public abstract int Speed { get; }
  15. public abstract bool IsRemoteAttack { 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.TryUseSpear();
  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.JumpyDumpty:
  62. return new JumpyDumpty(character, place, pos);
  63. case BulletType.BombBomb:
  64. return new BombBomb(character, place, pos);
  65. default:
  66. return null;
  67. }
  68. }
  69. public static int BulletRadius(BulletType bulletType)
  70. {
  71. switch (bulletType)
  72. {
  73. case BulletType.FlyingKnife:
  74. default:
  75. return GameData.bulletRadius;
  76. }
  77. }
  78. public static int BulletCD(BulletType bulletType)
  79. {
  80. switch (bulletType)
  81. {
  82. case BulletType.CommonAttackOfGhost:
  83. return CommonAttackOfGhost.cd;
  84. case BulletType.FlyingKnife:
  85. return FlyingKnife.cd;
  86. case BulletType.BombBomb:
  87. return BombBomb.cd;
  88. case BulletType.JumpyDumpty:
  89. return JumpyDumpty.cd;
  90. default:
  91. return GameData.basicCD;
  92. }
  93. }
  94. }
  95. }