|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- using Preparation.Interface;
- using Preparation.Utility;
- using System;
-
- namespace GameClass.GameObj
- {
- internal sealed class CommonAttackOfGhost : Bullet
- {
- public CommonAttackOfGhost(Character player, PlaceType placeType, XY pos, int radius = GameData.bulletRadius) :
- base(player, radius, placeType, pos)
- {
- }
- public override double BulletBombRange => 0;
- public override double BulletAttackRange => GameData.basicAttackShortRange;
- public override int AP => GameData.basicApOfGhost;
- public override int Speed => GameData.basicBulletMoveSpeed;
- public override bool IsToBomb => false;
- public override int CastTime => GameData.basicCastTime;
- public override int Backswing => GameData.basicBackswing;
- public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
- public override bool CanAttack(GameObj target)
- {
- return false;
- }
-
- public override BulletType TypeOfBullet => BulletType.CommonAttackOfGhost;
-
- }
- internal sealed class FlyingKnife : Bullet
- {
- public FlyingKnife(Character player, PlaceType placeType, XY pos, int radius = GameData.bulletRadius) :
- base(player, radius, placeType, pos)
- {
- }
- public override double BulletBombRange => 0;
- public override double BulletAttackRange => GameData.basicRemoteAttackRange * 13;
- public override int AP => GameData.basicApOfGhost / 5 * 4;
- public override int Speed => GameData.basicBulletMoveSpeed * 2;
- public override bool IsToBomb => false;
- public override int CastTime => GameData.basicCastTime;
- public override int Backswing => GameData.basicBackswing / 5 * 3;
- public override int RecoveryFromHit => GameData.basicRecoveryFromHit / 4 * 3;
- public override bool CanAttack(GameObj target)
- {
- return false;
- }
-
- public override BulletType TypeOfBullet => BulletType.FlyingKnife;
-
- }
-
- internal sealed class AtomBomb : Bullet
- {
- public AtomBomb(Character player, PlaceType placeType, XY pos, int radius = GameData.bulletRadius) :
- base(player, radius, placeType, pos)
- {
- }
- public override double BulletBombRange => GameData.basicBulletBombRange / 3 * 7;
- public override double BulletAttackRange => GameData.basicAttackShortRange / 9 * 7;
- public override int AP => GameData.basicApOfGhost / 3 * 7;
- public override int Speed => GameData.basicBulletMoveSpeed / 3 * 2;
- public override int CastTime => GameData.basicCastTime;
- public override int Backswing => GameData.basicBackswing;
- public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
- public override bool IsToBomb => true;
- public override bool CanAttack(GameObj target)
- {
- // 圆形攻击范围
- return XY.Distance(this.Position, target.Position) <= BulletBombRange;
- }
-
- public override BulletType TypeOfBullet => BulletType.AtomBomb;
-
- }
-
- internal sealed class OrdinaryBullet : Bullet // 1倍攻击范围,1倍攻击力,一倍速
- {
- public OrdinaryBullet(Character player, PlaceType placeType, XY pos, int radius = GameData.bulletRadius) :
- base(player, radius, placeType, pos)
- {
- }
- public override double BulletBombRange => GameData.basicBulletBombRange / 6 * 5;
- public override double BulletAttackRange => GameData.basicAttackShortRange / 2;
- public override int AP => GameData.basicApOfGhost / 6 * 5;
- public override int Speed => GameData.basicBulletMoveSpeed / 6 * 5;
- public override int CastTime => GameData.basicCastTime;
- public override int Backswing => GameData.basicBackswing;
- public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
- public override bool IsToBomb => true;
- public override bool CanAttack(GameObj target)
- {
- // 圆形攻击范围
- return XY.Distance(this.Position, target.Position) <= BulletBombRange;
- }
-
- public override BulletType TypeOfBullet => BulletType.OrdinaryBullet;
- }
-
- internal sealed class FastBullet : Bullet // 1倍攻击范围,0.2倍攻击力,2倍速
- {
- public FastBullet(Character player, PlaceType placeType, XY pos, int radius = GameData.bulletRadius) :
- base(player, radius, placeType, pos)
- {
- }
- public override double BulletBombRange => GameData.basicBulletBombRange / 4 * 2;
- public override double BulletAttackRange => GameData.basicAttackShortRange;
- public override int AP => (int)(0.5 * GameData.basicApOfGhost);
- public override int Speed => 5 * GameData.basicBulletMoveSpeed / 3;
- public override int CastTime => GameData.basicCastTime;
- public override int Backswing => GameData.basicBackswing;
- public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
- public override bool IsToBomb => true;
-
- public override bool CanAttack(GameObj target)
- {
- // 圆形攻击范围
- return XY.Distance(this.Position, target.Position) <= BulletBombRange;
- }
-
- public override BulletType TypeOfBullet => BulletType.FastBullet;
- }
-
- internal sealed class LineBullet : Bullet // 直线爆炸,宽度1格,长度为2倍爆炸范围
- {
- public LineBullet(Character player, PlaceType placeType, XY pos, int radius = GameData.bulletRadius) :
- base(player, radius, placeType, pos)
- {
- }
- public override double BulletBombRange => GameData.basicBulletBombRange / 3 * 4;
- public override double BulletAttackRange => 0.1 * GameData.basicAttackShortRange;
- public override int AP => GameData.basicApOfGhost / 3 * 2;
- public override int Speed => GameData.basicBulletMoveSpeed / 3;
- public override int CastTime => GameData.basicCastTime;
- public override int Backswing => GameData.basicBackswing;
- public override int RecoveryFromHit => GameData.basicRecoveryFromHit;
- public override bool IsToBomb => true;
-
- public override bool CanAttack(GameObj target)
- {
- double FacingAngle = Math.Atan2(this.FacingDirection.y, this.FacingDirection.x);
- if (Math.Abs(FacingAngle - Math.PI / 2) < 1e-2)
- {
- if (target.Position.y - this.Position.y > BulletBombRange)
- return false;
- if (target.Position.x < this.Position.x + GameData.numOfPosGridPerCell / 2 && target.Position.x > this.Position.x - GameData.numOfPosGridPerCell / 2)
- return true;
- return false;
- }
- else if (Math.Abs(FacingAngle - Math.PI * 3 / 2) < 1e-2)
- {
- if (target.Position.y - this.Position.y < -BulletBombRange)
- return false;
- if (target.Position.x < this.Position.x + GameData.numOfPosGridPerCell / 2 && target.Position.x > this.Position.x - GameData.numOfPosGridPerCell / 2)
- return true;
- return false;
- }
- else if (Math.Abs(FacingAngle) < 1e-2)
- {
- if (target.Position.x - this.Position.x > BulletBombRange)
- return false;
- if (target.Position.y < this.Position.y + GameData.numOfPosGridPerCell / 2 && target.Position.y > this.Position.y - GameData.numOfPosGridPerCell / 2)
- return true;
- return false;
- }
- else if (Math.Abs(FacingAngle - Math.PI) < 1e-2)
- {
- if (target.Position.x - this.Position.x < -BulletBombRange)
- return false;
- if (target.Position.y < this.Position.y + GameData.numOfPosGridPerCell / 2 && target.Position.y > this.Position.y - GameData.numOfPosGridPerCell / 2)
- return true;
- return false;
- }
- double vertical = Math.Tan(FacingAngle + Math.PI / 2);
- bool posValue = vertical * Math.Cos(FacingAngle) - Math.Sin(FacingAngle) > 0;
- double dist;
- dist = vertical * (target.Position.x - this.Position.x) - (target.Position.y - this.Position.y) / Math.Sqrt(1 + vertical * vertical);
- if (Math.Abs(dist) > BulletBombRange)
- return false;
- else if (dist < 0 && posValue) // 位于直线两侧
- return false;
- vertical = Math.Tan(FacingAngle);
- dist = Math.Abs(vertical * (target.Position.x - this.Position.x) - (target.Position.y - this.Position.y)) / Math.Sqrt(1 + vertical * vertical);
- if (dist > GameData.numOfPosGridPerCell / 2)
- return false;
- return true;
- }
-
- public override BulletType TypeOfBullet => BulletType.LineBullet;
- }
-
- }
|