public DirectShooter(int ID, LinkedList <Bullet> mBullet, BulletInfo bulletData, int frequency, Vector2 relativePosition, int startFrame, int life, Sprite target, string eventString, int eventLoopFrame, float randomRadius, bool isSelfSnipe, int bindingID, bool relativeBinding) : base(ID, relativePosition, startFrame, life, bindingID) { this.localBullet = mBullet; this.bulletData = bulletData; this.frequency = frequency; this.randomRadius = randomRadius; this.target = target; this.isSelfSnipe = isSelfSnipe; this.isHighLight = bulletData.isHighLight; this.fireCircleRadius = bulletData.fireRadius; this.fireInCircle = bulletData.isFireInCircle; this.randomPosition = Vector2.Zero; this.circlePosition = Vector2.Zero; this.bulletEvent = new List <BarrageEvent>(); this.myEvent = new List <BarrageEvent>(); this.myEventReader = new EventReader(); this.currentEvent = new List <BarrageEvent>(); this.relativeBinding = relativeBinding; //处理子弹事件 if (bulletData.bulletEvent.Length != 0) { bulletEvent = myEventReader.ReadEvent(bulletData.bulletEvent); } if (eventString.Length != 0) { myEvent = myEventReader.ReadEvent(eventString); } eventID = 0; this.eventLoopFrame = eventLoopFrame; }
public override void Initialize(int iStartFrame) { //修正发射器位置 if (isAbsolutePos) { this.relativePosition = new Vector2(x.iGunPosX2, x.iGunPosY2); this.position = relativePosition; } else { this.relativePosition = new Vector2(x.iGunPosX, x.iGunPosY); this.position = getSpritePosition() + relativePosition; } bulletData = new BulletInfo( x.iBulletType, x.fBulletSpeed, x.fFireAngle, x.fBulletAcc, x.iBulletAccAngle, x.iBulletLife, x.eBulletToward, x.iBulletHeadAngle, x.strBulletEvent, x.iBulletEventCycleTime, x.bHighLight, x.fLocationRadius, x.eBulletCreatePos, x.bKillOutBullet, x.bMask, x.bReflex, x.bForce); this.frequency = x.iCycleTime; this.randomRadius = x.fLaserLength; this.isSelfSnipe = x.bSelfSnipe; this.isHighLight = bulletData.isHighLight; this.fireCircleRadius = bulletData.fireRadius; this.fireInCircle = bulletData.isFireInCircle; this.randomPosition = Vector2.Zero; this.circlePosition = Vector2.Zero; eventID = 0; this.eventLoopFrame = x.iGunEventCycleTime; base.Initialize(iStartFrame); }
private void AddBullet(Vector2 position, float relativeDegree) { if (isSelfSnipe)//检查自机狙 { Vector2 dire = this.target.getPosition() - position; float snipeDegree = MathHelper.ToDegrees((float)Math.Acos(dire.X / dire.Length())); if (dire.Y < 0) { snipeDegree = 360 - snipeDegree; } if (lines % 2 != 0) { bulletData.speedDirec = snipeDegree; } else { bulletData.speedDirec = snipeDegree - anglePerLine / 2; } } int i = 0; while (i < lines) { randomBulletData = new BulletInfo(0, 0, 0, 0, 0, 0, directionType.SPEED, 0, "", 0, false, 0, 1, true, false, false, false); CheckRandomAttribute(); this.position = getSpritePosition() + relativePosition; if (fireInCircle)//设置发射半径 { circlePosition = Vector2.Zero; float fireAngle = MathHelper.ToRadians(bulletData.speedDirec + anglePerLine * i); this.circlePosition.X += (float)(this.fireCircleRadius * Math.Cos(fireAngle)); this.circlePosition.Y += (float)(this.fireCircleRadius * Math.Sin(fireAngle)); } Bullet newBullet = new Bullet(bulletData.ID, position + randomPosition + circlePosition, bulletData.speed + randomBulletData.speed + randomEventSpeed, relativeDegree + bulletData.speedDirec + anglePerLine * i + randomBulletData.speedDirec + randomEventSpeedDirec, bulletData.acceleration + randomBulletData.acceleration + randomEventAcc, bulletData.accelerationDegree + randomBulletData.accelerationDegree + randomEventAccDirec, bulletData.life + randomBulletData.life, bulletData.directType, (localBullet.Count % 500.0f) * 0.001f + 0.2f); //设置布尔变量值 newBullet.forceAvailable = bulletData.forceAvailable; newBullet.reflexAvailable = bulletData.reflexAvailable; newBullet.maskAvailable = bulletData.maskAvailable; newBullet.outDisappear = bulletData.outScreenDisappear; //添加子弹事件 if (bulletEvent.Count != 0) { newBullet.setEvent(bulletEvent); } //子弹事件添加完毕 if (this.target != null) { newBullet.setTarget(this.target); } localBullet.AddFirst(newBullet); i++; } }
public override void Initialize(int iStartFrame) { //修正发射器位置 if (isAbsolutePos) { this.relativePosition = new Vector2(x.iGunPosX2, x.iGunPosY2); this.position = relativePosition; } else { this.relativePosition = new Vector2(x.iGunPosX, x.iGunPosY); this.position = getSpritePosition() + relativePosition; } bulletData = new BulletInfo( x.iBulletType, x.fBulletSpeed, x.fFireAngle, x.fBulletAcc, x.iBulletAccAngle, x.iBulletLife, x.eBulletToward, x.iBulletHeadAngle, x.strBulletEvent, x.iBulletEventCycleTime, x.bHighLight, x.fLocationRadius, x.eBulletCreatePos, x.bKillOutBullet, x.bMask, x.bReflex, x.bForce); this.frequency = x.iCycleTime; this.angleRange = x.iGunAngleRange; this.lines = x.iFireNumber; this.randomRadius = x.fLaserLength; this.isSelfSnipe = x.bSelfSnipe; this.isHighLight = bulletData.isHighLight; this.fireCircleRadius = bulletData.fireRadius; this.fireInCircle = bulletData.isFireInCircle; anglePerLine = (float)angleRange / lines; this.randomAttribute = x.eRandomValue; this.randomHalfHight = x.fRandomHalfHeight; this.randomHalfWidth = x.fRandomHalfLength; this.randomRange = x.fRandomRange; this.randomPosition = Vector2.Zero; this.circlePosition = Vector2.Zero; this.position.Y += randomHalfHight * 2 * (float)ran.NextDouble() - randomHalfHight; this.position.X += randomHalfWidth * 2 * (float)ran.NextDouble() - randomHalfWidth; eventID = 0; this.eventLoopFrame = x.iGunEventCycleTime; randomEventSpeed = 0; randomEventSpeedDirec = 0; randomEventAcc = 0; randomEventAccDirec = 0; base.Initialize(iStartFrame); }
public MultiShooter(int ID, LinkedList <Bullet> mBullet, BulletInfo bulletData, int frequency, int angleRange, int lines, Vector2 relativePosition, int startFrame, int life) : this(ID, mBullet, bulletData, frequency, angleRange, lines, relativePosition, startFrame, life, null, "", life, 0, false, -1, false) { }