public override void Shoot() { Owner.ApplyShake(ShakeDuration, ShakeIntensity); var b = new HitscanBullet(Owner.transform.position, Owner.transform.forward, Owner, _damageFalloff, _knockbackFalloff, 1); var particleID = SimpleParticleSpawner.ParticleID.BULLET; var particle = SimpleParticleSpawner.Instance.particles[particleID].GetComponentInChildren <ParticleSystem>(); var speed = particle.main.startSpeed.constant * particle.main.simulationSpeed; var lifeTime = b.objDist / speed; SimpleParticleSpawner.Instance.SpawnParticle(particle.gameObject, Owner.transform.position, Owner.transform.rotation, lifeTime); var muzzleFlashID = SimpleParticleSpawner.ParticleID.MUZZLE_FLASH; var muzzleFlashParticle = SimpleParticleSpawner.Instance.particles[muzzleFlashID].GetComponentInChildren <ParticleSystem>(); SimpleParticleSpawner.Instance.SpawnParticle(muzzleFlashParticle.gameObject, _muzzle.transform.position, Owner.transform.forward, Owner.transform); }
void CalculatePelletsDispersion(float depth) { for (int i = 0; i < shotgunStatsData.pellets; i++) { var dispersionPoint = Random.Range(-shotgunStatsData.maxDispersionRadius, shotgunStatsData.maxDispersionRadius); var dir = Owner.transform.forward + (Owner.transform.right * dispersionPoint); var b = new HitscanBullet(Owner.transform.position, dir.normalized, Owner, _damageFalloff, _knockbackFalloff, shotgunStatsData.pellets); var bulletParticleID = SimpleParticleSpawner.ParticleID.BULLET; var bulletParticle = SimpleParticleSpawner.Instance.particles[bulletParticleID].GetComponentInChildren <ParticleSystem>(); var speed = bulletParticle.main.startSpeed.constant * bulletParticle.main.simulationSpeed; var lifeTime = b.objDist / speed; SimpleParticleSpawner.Instance.SpawnParticle(bulletParticle.gameObject, Owner.transform.position, dir, lifeTime); } var muzzleFlashID = SimpleParticleSpawner.ParticleID.MUZZLE_FLASH; var muzzleFlashParticle = SimpleParticleSpawner.Instance.particles[muzzleFlashID].GetComponentInChildren <ParticleSystem>(); SimpleParticleSpawner.Instance.SpawnParticle(muzzleFlashParticle.gameObject, _muzzle.transform.position, Owner.transform.forward, Owner.transform); }
private void ShootFunction(int chargeticks) { // TerminatorBehaviour Power Levels // Each Terminator Power up will add one to the power. //Power Level One: Machine gun // Power level Two: Shoot a single ball from the center of the paddle upwards. // Power Level Three: similar to Level one, but it shoots from each side of the paddle. //power level Four: shoots a single laser from the center of the paddle. //power level Five: shoots a laser from each side. // power level Six: Shoot a single ball from the center of the paddle upwards: however, //this will have a laserspinball behaviour, delay set to half a second. //power level Seven, same as five, but with laser spin //power level eight: SpinShot. if (mstate.PlayerPaddle == null) return; //only shoot if we are the first in the list of behaviours that are this type.... if (!mstate.PlayerPaddle.Behaviours.Contains(this)) return; if (mstate.PlayerPaddle.Behaviours.First((x) => x.GetType() == typeof (TerminatorBehaviour)) == this) { if (mstate.PlayerPaddle.Energy == 0) { BCBlockGameState.Soundman.PlaySound("shootfail"); //and, again, showmanship at work- "shoot" some black light orbs... to simulate smoke... for (int i = 0; i < 6; i++) { PointF usespeed = new PointF(0, (float) (-3 - (BCBlockGameState.rgen.NextDouble()))); usespeed = BCBlockGameState.VaryVelocity(usespeed, Math.PI/6); LightOrb addorb = new LightOrb(mstate.PlayerPaddle.Getrect().CenterPoint(), BCBlockGameState.rgen.NextDouble() > 0.5d ? Color.Black : Color.Gray, 15 + (float) (15*BCBlockGameState.rgen.NextDouble())); addorb.Velocity = usespeed; addorb.VelocityDecay = new PointF(0.9f, 0.85f); mstate.Particles.Add(addorb); //take damage, too... } mstate.PlayerPaddle.HP -= 10; return; } else { BCBlockGameState.Soundman.PlaySound("firelaser"); } mstate.PlayerPaddle.Energy--; Paddle pad = mstate.PlayerPaddle; RectangleF paddlerect = mstate.PlayerPaddle.Getrect(); PointF MiddleTop = new PointF(paddlerect.Left + (paddlerect.Width/2), paddlerect.Top); PointF LeftTop = new PointF(paddlerect.Left, paddlerect.Top); PointF RightTop = new PointF(paddlerect.Right, paddlerect.Top); Pen ChosenPenColor = new Pen(Color.Blue, 2); //TODO: make it depend on the paddle health. (blue when full, red when damaged). //if the powerlevel exceeds MaxPowerup... if (PowerLevel > MaxPowerup) { MachineGunTimer = new Timer(MachineGun, null, 60, 130); //120 ms delay... } //if it's larger than powerLevel*2, set it to powerLevel*2... if (PowerLevel > PowerLevel*2) PowerLevel = PowerLevel*2; int pPowerLevel = ((PowerLevel - 1)%(MaxPowerup)) + 1; //Power Level One: Machine gun if (pPowerLevel == 1) { if (PowerLevel == 1) { for (int i = 0; i < 5; i++) { Bullet firebullet = new Bullet( new PointF( mstate.PlayerPaddle.Getrect().Left + (mstate.PlayerPaddle.Getrect().Width/2), mstate.PlayerPaddle.Getrect().Top), BCBlockGameState.VaryVelocity(new PointF(0, -10), Math.PI/7)); mstate.GameObjects.AddLast(firebullet); } } else { Bullet firebullet = new Bullet( new PointF( mstate.PlayerPaddle.Getrect().Left + (mstate.PlayerPaddle.Getrect().Width/2), mstate.PlayerPaddle.Getrect().Top), BCBlockGameState.VaryVelocity(new PointF(0, -10), Math.PI/7)); mstate.GameObjects.AddLast(firebullet); } } else if (pPowerLevel == 2) { // Power level Two: Shoot a single ball from the center of the paddle upwards. (temp) cBall shootball = new cBall(MiddleTop, BCBlockGameState.VaryVelocity(new PointF(0, -8), Math.PI/8)); shootball.Radius = 3; shootball.DrawColor = Color.Yellow; shootball.DrawPen = new Pen(Color.GreenYellow); shootball.Behaviours.Add(new TempBallBehaviour()); mstate.ShootBalls.AddRange(new cBall[] {shootball}); } else if (pPowerLevel == 3) { // Power Level Three: similar to Level one, but it shoots from each side of the paddle. PointF[] Originspots = new PointF[] {LeftTop, RightTop}; foreach (PointF ShotOrigin in Originspots) { cBall shootit = new cBall(ShotOrigin, BCBlockGameState.VaryVelocity(new PointF(0f, -8.8f), Math.PI/8.8f)); shootit.Radius = 3; shootit.DrawColor = Color.Yellow; shootit.DrawPen = new Pen(Color.RoyalBlue); shootit.Behaviours.Add(new TempBallBehaviour()); mstate.ShootBalls.Add(shootit); } } else if (pPowerLevel == 4) { //weak hitscan, straight upwards. HitscanBullet hsb = new HitscanBullet(paddlerect.TopCenter(), new PointF(0, -2)); hsb.Penetrate = false; hsb.Strength = HitscanBullet.HitscanStrengthConstants.hitscan_bullet; mstate.GameObjects.AddLast(hsb); BCBlockGameState.Soundman.PlaySound("laser2"); } else if (pPowerLevel == 5) { for (int i = 0; i < 5; i++) { PointF selectedvelocity = BCBlockGameState.VaryVelocity(new PointF(0, -8), Math.PI/16); HitscanBullet hsb = new HitscanBullet(paddlerect.TopCenter(), selectedvelocity); hsb.Penetrate = false; hsb.Strength = HitscanBullet.HitscanStrengthConstants.hitscan_bullet; mstate.GameObjects.AddLast(hsb); BCBlockGameState.Soundman.PlaySound("laser2"); } } else if (pPowerLevel == 6) { //power level Four: shoots a single laser from the center of the paddle. LaserShot ShootLaser = new LaserShot(MiddleTop, new PointF(0, -9), ChosenPenColor, 36); mstate.GameObjects.AddLast(ShootLaser); } else if (pPowerLevel == 7) { PointF[] Originspots = new PointF[] {LeftTop, RightTop}; PointF usevelocity = BCBlockGameState.VaryVelocity(new PointF(0f, -8.8f), Math.PI/8.9f); foreach (PointF ShotOrigin in Originspots) { LaserShot ShootLaser = new LaserShot(ShotOrigin, usevelocity, ChosenPenColor); mstate.GameObjects.AddLast(ShootLaser); //power level Five: shoots a laser from each side. } } else if (pPowerLevel == 8) { cBall shootball = new cBall(MiddleTop, BCBlockGameState.VaryVelocity(new PointF(0f, -1f), Math.PI/10)); shootball.Behaviours.Add(new LaserSpinBehaviour(new TimeSpan(0, 0, 0, 0, 300))); shootball.Behaviours.Add(new TempBallBehaviour()); shootball.Radius = 3; shootball.DrawColor = Color.Yellow; shootball.DrawPen = new Pen(Color.GreenYellow); mstate.ShootBalls.Add(shootball); // power level Six: Shoot a single ball from the center of the paddle upwards: however, //this will have a laserspinball behaviour, delay set to half a second. } else if (pPowerLevel == 9) { //power level Seven, same as five, but with laser spin //also same as 6 but with two of them... PointF[] Originspots = new PointF[] {LeftTop, RightTop}; foreach (PointF ShotOrigin in Originspots) { cBall shootball = new cBall(ShotOrigin, BCBlockGameState.VaryVelocity(new PointF(0f, -9f), Math.PI/10)); shootball.Behaviours.Add(new LaserSpinBehaviour(new TimeSpan(0, 0, 0, 300))); shootball.Behaviours.Add(new TempBallBehaviour()); shootball.Radius = 3; shootball.DrawColor = Color.Yellow; shootball.DrawPen = new Pen(Color.GreenYellow); mstate.ShootBalls.Add(shootball); } } else if (pPowerLevel == 10) { //spinshot PointF selectedspeed = BCBlockGameState.VaryVelocity(new PointF(0, -9f), Math.PI/10); SpinShot shootit = new SpinShot(mstate, new PointF( mstate.PlayerPaddle.Getrect().Left + (mstate.PlayerPaddle.Getrect().Width/2), mstate.PlayerPaddle.Getrect().Top), 12, 16, ((float) Math.PI/6), selectedspeed); mstate.GameObjects.AddLast(shootit); } } else { Debug.Print("Terminator Behaviour not first Terminator in behaviours collection... ignoring..."); } }