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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. public abstract bool CanBeBombed(GameObjType gameObjType);
  31. protected override bool IgnoreCollideExecutor(IGameObj targetObj)
  32. {
  33. if (targetObj.Type == GameObjType.Prop || targetObj.Type == GameObjType.Bullet)
  34. return true;
  35. return false;
  36. }
  37. public Bullet(Character player, int radius, PlaceType placeType, XY Position) :
  38. base(Position, radius, GameObjType.Bullet)
  39. {
  40. this.place = placeType;
  41. this.CanMove = true;
  42. this.moveSpeed = this.Speed;
  43. this.hasSpear = player.HasSpear;
  44. this.Parent = player;
  45. }
  46. public override bool IsRigid => true; // 默认为true
  47. public override ShapeType Shape => ShapeType.Circle; // 默认为圆形
  48. public abstract BulletType TypeOfBullet { get; }
  49. }
  50. public static class BulletFactory
  51. {
  52. public static Bullet? GetBullet(Character character, PlaceType place, XY pos)
  53. {
  54. Bullet? newBullet = null;
  55. switch (character.BulletOfPlayer)
  56. {
  57. case BulletType.AtomBomb:
  58. newBullet = new AtomBomb(character, place, pos);
  59. break;
  60. case BulletType.LineBullet:
  61. newBullet = new LineBullet(character, place, pos);
  62. break;
  63. case BulletType.FastBullet:
  64. newBullet = new FastBullet(character, place, pos);
  65. break;
  66. case BulletType.OrdinaryBullet:
  67. newBullet = new OrdinaryBullet(character, place, pos);
  68. break;
  69. default:
  70. break;
  71. }
  72. return newBullet;
  73. }
  74. public static int BulletRadius(BulletType bulletType)
  75. {
  76. switch (bulletType)
  77. {
  78. case BulletType.AtomBomb:
  79. case BulletType.LineBullet:
  80. case BulletType.FastBullet:
  81. case BulletType.OrdinaryBullet:
  82. default:
  83. return GameData.bulletRadius;
  84. }
  85. }
  86. }
  87. }