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.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. private readonly bool hasSpear;
  20. /// <summary>
  21. /// 是否有矛
  22. /// </summary>
  23. public bool HasSpear => hasSpear;
  24. /// <summary>
  25. /// 与THUAI4不同的一个攻击判定方案,通过这个函数判断爆炸时能否伤害到target
  26. /// </summary>
  27. /// <param name="target">被尝试攻击者</param>
  28. /// <returns>是否可以攻击到</returns>
  29. public abstract bool CanAttack(GameObj target);
  30. protected override bool IgnoreCollideExecutor(IGameObj targetObj)
  31. {
  32. if (targetObj.Type == GameObjType.Prop || targetObj.Type == GameObjType.Bullet)
  33. return true;
  34. return false;
  35. }
  36. public Bullet(Character player, int radius, PlaceType placeType, XY Position) :
  37. base(Position, radius, GameObjType.Bullet)
  38. {
  39. this.place = placeType;
  40. this.CanMove = true;
  41. this.moveSpeed = this.Speed;
  42. this.hasSpear = player.HasSpear;
  43. this.Parent = player;
  44. }
  45. public override bool IsRigid => true; // 默认为true
  46. public override ShapeType Shape => ShapeType.Circle; // 默认为圆形
  47. public abstract BulletType TypeOfBullet { get; }
  48. }
  49. public static class BulletFactory
  50. {
  51. public static Bullet? GetBullet(Character character, PlaceType place, XY pos)
  52. {
  53. Bullet? newBullet = null;
  54. switch (character.BulletOfPlayer)
  55. {
  56. case BulletType.AtomBomb:
  57. newBullet = new AtomBomb(character, place, pos);
  58. break;
  59. case BulletType.LineBullet:
  60. newBullet = new LineBullet(character, place, pos);
  61. break;
  62. case BulletType.FastBullet:
  63. newBullet = new FastBullet(character, place, pos);
  64. break;
  65. case BulletType.OrdinaryBullet:
  66. newBullet = new OrdinaryBullet(character, place, pos);
  67. break;
  68. default:
  69. break;
  70. }
  71. return newBullet;
  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. default:
  82. return GameData.bulletRadius;
  83. }
  84. }
  85. }
  86. }