using Preparation.Interface; using Preparation.Utility; using System; namespace GameClass.GameObj { public abstract class Bullet : ObjOfCharacter { /// /// //攻击力 /// public abstract double BulletBombRange { get; } public abstract double BulletAttackRange { get; } public abstract int AP { get; } public abstract int Speed { get; } public abstract bool IsToBomb { get; } public abstract int CastTime { get; } public abstract int Backswing { get; } public abstract int RecoveryFromHit { get; } private readonly bool hasSpear; /// /// 是否有矛 /// public bool HasSpear => hasSpear; /// /// 与THUAI4不同的一个攻击判定方案,通过这个函数判断爆炸时能否伤害到target /// /// 被尝试攻击者 /// 是否可以攻击到 public abstract bool CanAttack(GameObj target); protected override bool IgnoreCollideExecutor(IGameObj targetObj) { if (targetObj.Type == GameObjType.Prop || targetObj.Type == GameObjType.Bullet) return true; return false; } public Bullet(Character player, int radius, PlaceType placeType, XY Position) : base(Position, radius, GameObjType.Bullet) { this.place = placeType; this.CanMove = true; this.moveSpeed = this.Speed; this.hasSpear = player.HasSpear; this.Parent = player; } public override bool IsRigid => true; // 默认为true public override ShapeType Shape => ShapeType.Circle; // 默认为圆形 public abstract BulletType TypeOfBullet { get; } } public static class BulletFactory { public static Bullet? GetBullet(Character character, PlaceType place, XY pos) { Bullet? newBullet = null; switch (character.BulletOfPlayer) { case BulletType.AtomBomb: newBullet = new AtomBomb(character, place, pos); break; case BulletType.LineBullet: newBullet = new LineBullet(character, place, pos); break; case BulletType.FastBullet: newBullet = new FastBullet(character, place, pos); break; case BulletType.OrdinaryBullet: newBullet = new OrdinaryBullet(character, place, pos); break; default: break; } return newBullet; } public static int BulletRadius(BulletType bulletType) { switch (bulletType) { case BulletType.AtomBomb: case BulletType.LineBullet: case BulletType.FastBullet: case BulletType.OrdinaryBullet: default: return GameData.bulletRadius; } } } }