public void PrintPath(Level level) { if (Config.GetProperty("Pathfinder.PrintPath", false)) { foreach (var tile in Current) { Block block = GetBlock(tile); Color color = Color.FromArgb(Math.Max(0, 255 - Current.Count * 10), 255, 255); var particle = new DustParticle(level, color); particle.Position = (Vector3)block.Coordinates + new Vector3(0.5f, 0.5f, 0.5f); particle.Spawn(); } } }
// Use this for initialization void Start() { // Create the particles and their respective stats. This includes velocity, rotation, etc. particleCount = Random.Range(minParticleCount, maxParticleCount); particles = new ArrayList(particleCount); DustParticle particle; for (int i = particleCount - 1; i >= 0; i--) { particle = new DustParticle(); particle.obj = Instantiate(dustParticles[Random.Range(0, dustParticles.Length)], transform.position, transform.rotation) as GameObject; particle.obj.transform.parent = transform; particle.renderer = particle.obj.GetComponent <SpriteRenderer>(); particle.velocity = Random.Range(minVel, maxVel); particle.angle = Random.Range(minAngle, maxAngle) * Mathf.PI / 180; particle.life = particle.lifeMax = Random.Range(minLife, maxLife); particle.rotationSpeed = Random.Range(minRotSpeed, maxRotSpeed); particles.Add(particle); } }
public override bool PerformFrame(BCBlockGameState gamestate) { //hitscan. We only "take" a single frame to hit something. //first, normalize the Velocity. _Velocity = _Velocity.Normalize(); //now, starting from _Origin, advance position by _Velocity until we hit a block or leave the gamearea. List<Block> blockshit = new List<Block>(); PointF currpos = _Origin; PointF lastpos = _Origin; bool scancomplete = false; int spawnjump = 0; int particlecomparator = Math.Max(gamestate.Particles.Count-500, 2); //particlecomparator is our modulus. This will be modulo'd with spawnjump each iteration while (!scancomplete) { spawnjump++; currpos = new PointF(currpos.X + _Velocity.X, currpos.Y + _Velocity.Y); PointF diff = new PointF(currpos.X-lastpos.X,currpos.Y-lastpos.Y); //spawn some particles here. if (spawnjump>particlecomparator && Tracer) { spawnjump = 0; for (int i = 0; i < 1; i++) { float randomspot = (float)BCBlockGameState.rgen.NextDouble(); PointF randomoffset = new PointF(currpos.X + diff.X * randomspot, currpos.Y + diff.Y * randomspot); if (BCBlockGameState.rgen.NextDouble() > 0.5) { DustParticle dp = new DustParticle(randomoffset, 3, 25, _BulletColor); dp.Important = true; gamestate.Particles.Add(dp); } else { LightOrb dp = new LightOrb(randomoffset, Color.Green, 16); dp.TTL = 25; dp.Important = true; gamestate.Particles.Add(dp); } } } //are we outside gamearea? if (!gamestate.GameArea.Contains(currpos.ToPoint())) scancomplete = true; //have we hit a block? var hitblock = BCBlockGameState.Block_HitTestOne(gamestate.Blocks, currpos); if (hitblock != null && !blockshit.Contains(hitblock)) { blockshit.Add(hitblock); if(_Strength == HitscanStrengthConstants.hitscan_bullet) { //create a bullet at currpos, make it go in our direction. Bullet bb = new Bullet(currpos, _Velocity, false); bb.BulletBrush = new SolidBrush(Color.Transparent); //invisible bullet... gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() => gamestate.GameObjects.AddLast(bb))); } else if(_Strength==HitscanStrengthConstants.hitscan_hit) { gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() => BCBlockGameState.Block_Hit(gamestate, hitblock, _Velocity))); } if (!Penetrate) scancomplete = true; } lastpos = currpos; } if (!Tracer) { DustParticle pa = new DustParticle(Origin, 800,9000,Color.Transparent); DustParticle pb = new DustParticle(currpos,800,9000,Color.Transparent); pa.Velocity = PointF.Empty; pb.Velocity = PointF.Empty; LineParticle ls = new LineParticle(pa, pb,new Pen(Color.Yellow,1)); ls.Important = true; ls.TTL = 750; gamestate.Particles.Add(ls); //show the impact point. PointF Impactpoint = currpos; for (int i = 0; i < 14 * BCBlockGameState.Settings.ParticleGenerationFactor; i++) { Particle xp = BCBlockGameState.rgen.NextDouble() > 0.5 ? (Particle) new EmitterParticle(Impactpoint,(gstate,emitter,aint,bint)=> { float ssspeed = (float)BCBlockGameState.rgen.NextDouble() * 5 + 2; PointF ssusespeed = BCBlockGameState.VaryVelocity(new PointF(0,-ssspeed), Math.PI / 10); DustParticle addit = new DustParticle(emitter.Location, 40); addit.Velocity = ssusespeed; return addit; }) : (Particle)new DustParticle(Impactpoint); float speed = (float)BCBlockGameState.rgen.NextDouble() * 5 + 2; PointF usespeed = BCBlockGameState.VaryVelocity(new PointF(0,-speed), Math.PI / 10); xp.Velocity = usespeed; gamestate.Particles.Add(xp); } } return true; //we only exist for one frame. }
public override bool PerformFrame(BCBlockGameState gamestate) { bool retval = base.PerformFrame(gamestate); //add some particles around the edges of the explosion, moving outward... if (gamestate.Particles.Count((w)=>!w.Important) < BCBlockGameState.MaxParticles) { for (int i = 0; i < (int)(25f * BCBlockGameState.ParticleGenerationFactor); i++) { const float speedmult = 1; //choose a random Angle... double randomangle = Math.PI * 2 * BCBlockGameState.rgen.NextDouble(); //create the appropriate speed vector, based on our radius... double usespeed = (_CurrentRadius / _MaxRadius) * speedmult; //should be proportional to how close we are to the maximum radius; max radius will have particles move 1... usespeed += ((BCBlockGameState.rgen.NextDouble() * 0.6) - 0.3); PointF addpointLocation = new PointF(Location.X + (float)Math.Cos(randomangle) * _CurrentRadius, Location.Y + (float)Math.Sin(randomangle) * _CurrentRadius); //create a dustparticle... PointF PointSpeed = new PointF((float)(Math.Cos(randomangle) * usespeed), (float)(Math.Sin(randomangle) * usespeed)); Particle addparticle = null; if (i % 5 != 0) { addparticle = new DustParticle(addpointLocation, PointSpeed); } else if (_ShowOrbs) { //LightOrb... LightOrb lo = new LightOrb(addpointLocation, ExplosionColor, (float)BCBlockGameState.rgen.NextDouble() * 10 + 5); lo.Velocity = PointSpeed; addparticle = lo; } if (addparticle != null) gamestate.Particles.Add(addparticle); } } //each frame, check for blocks that are within the given radius. Hell with it, we'll check their centerpoints... if (gamestate.PlayerPaddle != null) { //if( if (DamagePaddle && BCBlockGameState.RectangleIntersectsCircle(gamestate.PlayerPaddle.Getrect(), Location, _CurrentRadius)) { gamestate.PlayerPaddle.HP -= 1f; } } if (_EffectObjects) { //find all GameObjects that implement IExplodable. //we might be bothered to do the same for Balls, I suppose. No promises. IEnumerable<IExplodable> result = BCBlockGameState.Join<IExplodable>( (from ball in gamestate.Balls where ball is IExplodable && (BCBlockGameState.Distance(Location,ball.Location) < _CurrentRadius) select ball as IExplodable), (from obj in gamestate.GameObjects where obj is IExplodable select obj as IExplodable)); //in order to prevent contention issues, we will defer the loop that "effects" each item until the next gametick iteration starts. gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() => { foreach (var iterateresult in result) { PointF useVelocityEffect = new PointF(Math.Max(1,Velocity.X),Math.Max(1,Velocity.Y)); iterateresult.ExplosionInteract(this, Location, useVelocityEffect); } })); } List<Block> removethese = new List<Block>(); if (_DamageBlocks) { var blowemup = from p in gamestate.Blocks where BCBlockGameState.Distance(Location.X, Location.Y, p.CenterPoint().X, p.CenterPoint().Y) < _CurrentRadius select p; if (blowemup.Any()) { foreach (var loopblock in blowemup) { //destroy it. if (loopblock is DestructionBlock) { //special handling for combos Debug.Print("DestructionBlock detected in ExplosionEffect..."); (loopblock as DestructionBlock).ComboCount = this.ComboCount + 1; } if (DestroyAll || loopblock.MustDestroy()) { loopblock.StandardSpray(gamestate); removethese.Add(loopblock); } } lock (gamestate.Blocks) { foreach (Block removeit in removethese) { //get angle between the center of the explosion and the block's center. double Angle = BCBlockGameState.GetAngle(CenterPoint(), removeit.CenterPoint()); int useSpeed = BCBlockGameState.ClampValue((int)_MaxRadius / 2, 1, 5); PointF useVelocity = BCBlockGameState.GetVelocity(useSpeed, Angle); cBall tempball = new cBall(new PointF(removeit.CenterPoint().X-useVelocity.X,removeit.CenterPoint().Y-useVelocity.Y), useVelocity); tempball.PreviousVelocity = useVelocity; tempball.Behaviours.Add(new TempBallBehaviour()); //add a proxy behaviour to remove it as well. //tempball.Behaviours.Add(new ProxyBallBehaviour("ExplosionEffect", null, proxyperformframe, null, null, null, null, null, null)); //gamestate.Balls.AddLast(tempball); List<cBall> discardlist = new List<cBall>(); try { //this is... well, cheating... //we cannot add GameObjects to the List, except by plopping them in the ref AddedObject parameter. //however, we cannot "force" the PerformBlockHit of a block (say a destruction block) to add a GameObject (another ExplosionEffect, in that case) //we cheat. we swap out the entire gamestate.GameObject LinkedList with a new one, call the routine, and then //we add any added GameObjects to our ref parameter, and swap the old list back in, hoping nobody notices our //audacity to fiddle with core game state objects... var copiedref = gamestate.GameObjects; gamestate.GameObjects = new LinkedList<GameObject>(); removeit.PerformBlockHit(gamestate, tempball); gamestate.Blocks.Remove(removeit); var tempadded = gamestate.GameObjects; gamestate.GameObjects = copiedref; //now we add the ones we need to add to our ref array. I feel dirty. gamestate.Defer(() => { foreach (var iterate in tempadded) { gamestate.GameObjects.AddLast(iterate); } }); } catch { } //we don't add the ball to our GameState, so we don't have to worry about it persisting :D //the idea is that we want to invoke the actions of the block (which for many blocks will simply be destroyed). //at the same time, some blocks might react weirdly to having temporary balls tossed into their centers, so we make it so the ball will only live for //two frames by adding a proxyballbehaviour that ensure that. //gamestate.Blocks.Remove(removeit); gamestate.Forcerefresh = true; } //changed: instead of removing them, create a temporary ball at their center point. } } } return retval; }
private void BobberThread() { int EffectLengthi = 5000; if (BobberThreadEffectFinish == null) { BobberThreadEffectFinish = DateTime.Now; } const int numeffects = 6; while (true) { lock (ImageBackBufferCanvas) { Thread.Sleep(40); Thread.SpinWait(15); while (Form.ActiveForm == null) Thread.Sleep(50); if (!this.Visible) { Thread.Sleep(50); //nothing to do, allow other threads to run. } else { DrawFrame(); } if (performingEffect) { bool doflip = false; TimeSpan EffectLength = DateTime.Now - BobberThreadEffectStart; //currently the only supported "effect" ,draws a bunch of particles across the screen halfway. (Y). imagesdraw.Clear(); if (EffectLength.TotalMilliseconds > EffectLengthi) { performingEffect = false; prevparticlepos = new PointF(0, 0); BobberThreadEffectFinish = DateTime.Now; } else { double currpercent = (double) EffectLength.TotalMilliseconds/(double) EffectLengthi; int Xpos = (int) (((float) (ImageBackBufferbitmap.Width*1.5)*currpercent) - ((float) (ImageBackBufferbitmap.Width*0.2f))); Debug.Print("Effect currpercent=" + currpercent); // PointF addparticlepos = new PointF(Xpos, ImageBackBufferbitmap.Height / 2); int effectnumber = EffectCount%numeffects; if (effectnumber%2 == 0) { Xpos = ImageBackBufferbitmap.Width - Xpos; doflip = true; } PointF addparticlepos = new PointF(Xpos, 163); if (prevparticlepos.X == 0 && prevparticlepos.Y == 0) prevparticlepos = addparticlepos; float usehue = (((float) currpercent*3)%1)*240; Color particlecolor = new HSLColor(usehue, 240, 120); const float maxoutspeed = 1f; const int numparticles = 25; Image[] usepics = null; System.Drawing.Size? usesize; switch (effectnumber) { case 0: case 2: usepics = new Image[] { rdash.BackgroundImage }; if (effectnumber == 2) addparticlepos = new PointF(addparticlepos.X, ((float) Math.Sin(addparticlepos.X/16)*8) + addparticlepos.Y); /*for (int addp = 0; addp < numparticles*2; addp++) { Particle addparticle = new DustParticle(addparticlepos, (float) (rg.NextDouble()*4), 7500, particlecolor); lock (DrawParticles) { DrawParticles.Add(addparticle); } }*/ //create a spectrum... const float numlines = 25; const int totalsize = 100; for (int i = 0; i < numlines; i++) { float useYoffset = (totalsize/2) + (((float) i/numlines)*totalsize); float pct = ((float) i/numlines); float percenthue = (pct*240); PointF offsetamount = new PointF(addparticlepos.X - prevparticlepos.X, addparticlepos.Y - prevparticlepos.Y); //PointF firstpoint = new PointF(addparticlepos.X, useYoffset); //PointF secondpoint = new PointF(firstpoint.X+offsetamount.X,firstpoint.Y+offsetamount.Y); PointF firstpoint = addparticlepos; PointF secondpoint = prevparticlepos; if (firstpoint.X > secondpoint.X) { firstpoint = new PointF(firstpoint.X + 2, firstpoint.Y); secondpoint = new PointF(secondpoint.X - 2, secondpoint.Y); } else { firstpoint = new PointF(firstpoint.X - 2, firstpoint.Y); secondpoint = new PointF(secondpoint.X + 2, secondpoint.Y); } //float phue = (percenthue + (Xpos/2)%240 )%240; float phue = percenthue%240; Color linecoloruse = new HSLColor(phue, 240, 120); float usevel = (pct - 0.5f)*5; DustParticle dust1 = new DustParticle(firstpoint, new PointF(0, usevel)); DustParticle dust2 = new DustParticle(secondpoint, new PointF(0, usevel)); LineParticle lp = new LineParticle(dust1, dust2, linecoloruse); lock (DrawParticles) { DrawParticles.Add(lp); if (Math.Truncate((double) Xpos)%15 == 0) { //add a 5-pointed star... //StarParticle staradd = new StarParticle(addparticlepos, BCBlockGameState.GetRandomVelocity(0,3), 5, 3, 6, Color.Yellow, Color.Black, (float)(rg.NextDouble() * 2)); CharacterDebris staradd = new CharacterDebris(addparticlepos, BCBlockGameState. GetRandomVelocity(0, 3), Color.Yellow, 8, 18); DrawParticles.Add(staradd); } } } /* Particle addParticleA = new DustParticle(addparticlepos, new PointF(0, -2)); Particle addParticleB = new DustParticle(addparticlepos, new PointF(0, 2)); LineParticle lp = new LineParticle(addParticleA, addParticleB, particlecolor); lock (DrawParticles) { DrawParticles.Add(lp); } */ break; case 1: case 3: usepics = new Image[] {rdash.BackgroundImage}; if (effectnumber == 3) addparticlepos = new PointF(addparticlepos.X, ((float) Math.Sin(addparticlepos.X/32)*16) + addparticlepos.Y); for (int addp = 0; addp < numparticles; addp++) { float ppercent = (float) addp/(float) numparticles; float usespeed = (float) (((maxoutspeed*2)*ppercent) - maxoutspeed); PointF speeduse = new PointF((float) (rg.NextDouble() - 0.5d), usespeed); particlecolor = new HSLColor(ppercent*240, 240, 120); //Particle addparticle = new PolyDebris(addparticlepos, rg.NextDouble() * 2, particlecolor, 3, 4, 3, 8); Particle addparticle = new PolyDebris(addparticlepos, speeduse, particlecolor, 3, 4, 3, 8); lock (DrawParticles) { DrawParticles.Add(addparticle); } } break; case 4: usepics = new Image[] { ttoaster.BackgroundImage }; for (int addp = 0; addp < numparticles*2; addp++) { particlecolor = Color.FromArgb(rg.Next(255), rg.Next(255), 0); Particle addparticle = new DustParticle(addparticlepos, (float) (rg.NextDouble()*4), 7500, particlecolor); lock (DrawParticles) { DrawParticles.Add(addparticle); } } break; case 5: /* */ //megaman sprites... //since these are loaded if (!mmimagesloaded) { mmimagesloaded = true; try { mmimages = BCBlockGameState.Imageman.getImageFrames("megaman"); } catch { mmimagesloaded = false; } } if (mmimagesloaded) { if ((DateTime.Now - lastmmFrameChange) > mmFrameDelayTime) { //advance the frame. mmimageframe++; } mmimageframe = mmimageframe%mmimages.Length; //they are... or should be, loaded now. usepics = new Image[] {mmimages[mmimageframe]}; usesize = new Size(usepics[0].Size.Width*3, usepics[0].Size.Height*3); } break; /* case 3: addparticlepos = new PointF(addparticlepos.X, ((float)Math.Sin(addparticlepos.X / 16) * 8) + addparticlepos.Y); for (int addp = 0; addp < numparticles; addp++) { Particle addparticle = new PolyDebris(addparticlepos, rg.NextDouble()*2, particlecolor, 3, 4, 3, 8); lock (DrawParticles) { DrawParticles.Add(addparticle); } } break; */ } drawimagedata dd = new drawimagedata(); //dd.DrawImage = (Image) usepic.Clone(); dd.ImageFrames = usepics; if (doflip) dd.DrawImage.RotateFlip(RotateFlipType.RotateNoneFlipX); dd.Location = addparticlepos; //imagesdraw.Add(new drawimagedata(BCBlockGameState.Imageman.GetLoadedImage("rdash") double ang = BCBlockGameState.GetAngle(prevparticlepos, addparticlepos); Debug.Print("chosen angle=" + ang); dd.Angle = ang; //if (doflip) dd.Angle += (float) Math.PI; imagesdraw.Add(dd); prevparticlepos = addparticlepos; } } else if ((DateTime.Now - BobberThreadEffectFinish.Value).TotalSeconds >= 60) { EffectCount++; EffectCount = EffectCount%numeffects; switch (EffectCount) { case 0: case 1: case 2: case 3: EffectLengthi = 5000; if (BCBlockGameState.Soundman != null) //can be null, if you press shift during startup and take a while on the screen presented... { if (BCBlockGameState.Soundman.HasSound("asboom")) { BCBlockGameState.Soundman.PlaySound("asboom", 3.0f); } } break; case 4: iSoundSourceObject grabsound; if (BCBlockGameState.Soundman != null) { if (((grabsound = BCBlockGameState.Soundman.GetSoundRnd("TTOASTER")) != null)) { grabsound.Play(false, 3.0f); } } break; case 5: if(BCBlockGameState.Soundman!=null) BCBlockGameState.Soundman.PlaySound("ray"); break; } Debug.Print("invoking effect #" + EffectCount); performingEffect = true; BobberThreadEffectStart = DateTime.Now; } } } }
private void defaultemitter(cBall onball,BCBlockGameState gamestate) { Particle addparticle = new DustParticle(onball); }
private void BobberThread() { int EffectLengthi = 5000; if (BobberThreadEffectFinish == null) { BobberThreadEffectFinish = DateTime.Now; } const int numeffects = 6; while (true) { lock (ImageBackBufferCanvas) { Thread.Sleep(50); Thread.SpinWait(15); while (Form.ActiveForm == null) { Thread.Sleep(0); } if (!this.Visible) { Thread.Sleep(0); //nothing to do, allow other threads to run. } else { DrawFrame(); } if (performingEffect) { bool doflip = false; TimeSpan EffectLength = DateTime.Now - BobberThreadEffectStart; //currently the only supported "effect" ,draws a bunch of particles across the screen halfway. (Y). imagesdraw.Clear(); if (EffectLength.TotalMilliseconds > EffectLengthi) { performingEffect = false; prevparticlepos = new PointF(0, 0); BobberThreadEffectFinish = DateTime.Now; } else { double currpercent = (double)EffectLength.TotalMilliseconds / (double)EffectLengthi; int Xpos = (int) (((float)(ImageBackBufferbitmap.Width * 1.5) * currpercent) - ((float)(ImageBackBufferbitmap.Width * 0.2f))); Debug.Print("Effect currpercent=" + currpercent); // PointF addparticlepos = new PointF(Xpos, ImageBackBufferbitmap.Height / 2); int effectnumber = EffectCount % numeffects; if (effectnumber % 2 == 0) { Xpos = ImageBackBufferbitmap.Width - Xpos; doflip = true; } PointF addparticlepos = new PointF(Xpos, 163); if (prevparticlepos.X == 0 && prevparticlepos.Y == 0) { prevparticlepos = addparticlepos; } float usehue = (((float)currpercent * 3) % 1) * 240; Color particlecolor = new HSLColor(usehue, 240, 120); const float maxoutspeed = 1f; const int numparticles = 25; Image usepic = null; System.Drawing.Size?usesize; switch (effectnumber) { case 0: case 2: usepic = rdash.BackgroundImage; if (effectnumber == 2) { addparticlepos = new PointF(addparticlepos.X, ((float)Math.Sin(addparticlepos.X / 16) * 8) + addparticlepos.Y); } /*for (int addp = 0; addp < numparticles*2; addp++) * { * Particle addparticle = new DustParticle(addparticlepos, (float) (rg.NextDouble()*4), * 7500, particlecolor); * * * lock (DrawParticles) * { * DrawParticles.Add(addparticle); * } * }*/ //create a spectrum... const float numlines = 25; const int totalsize = 100; for (int i = 0; i < numlines; i++) { float useYoffset = (totalsize / 2) + (((float)i / numlines) * totalsize); float pct = ((float)i / numlines); float percenthue = (pct * 240); PointF offsetamount = new PointF(addparticlepos.X - prevparticlepos.X, addparticlepos.Y - prevparticlepos.Y); //PointF firstpoint = new PointF(addparticlepos.X, useYoffset); //PointF secondpoint = new PointF(firstpoint.X+offsetamount.X,firstpoint.Y+offsetamount.Y); PointF firstpoint = addparticlepos; PointF secondpoint = prevparticlepos; if (firstpoint.X > secondpoint.X) { firstpoint = new PointF(firstpoint.X + 2, firstpoint.Y); secondpoint = new PointF(secondpoint.X - 2, secondpoint.Y); } else { firstpoint = new PointF(firstpoint.X - 2, firstpoint.Y); secondpoint = new PointF(secondpoint.X + 2, secondpoint.Y); } //float phue = (percenthue + (Xpos/2)%240 )%240; float phue = percenthue % 240; Color linecoloruse = new HSLColor(phue, 240, 120); float usevel = (pct - 0.5f) * 5; DustParticle dust1 = new DustParticle(firstpoint, new PointF(0, usevel)); DustParticle dust2 = new DustParticle(secondpoint, new PointF(0, usevel)); LineParticle lp = new LineParticle(dust1, dust2, linecoloruse); lock (DrawParticles) { DrawParticles.Add(lp); if (Math.Truncate((double)Xpos) % 15 == 0) { //add a 5-pointed star... //StarParticle staradd = new StarParticle(addparticlepos, BCBlockGameState.GetRandomVelocity(0,3), 5, 3, 6, Color.Yellow, Color.Black, (float)(rg.NextDouble() * 2)); CharacterDebris staradd = new CharacterDebris(addparticlepos, BCBlockGameState. GetRandomVelocity(0, 3), Color.Yellow, 8, 18); DrawParticles.Add(staradd); } } } /* * Particle addParticleA = new DustParticle(addparticlepos, new PointF(0, -2)); * Particle addParticleB = new DustParticle(addparticlepos, new PointF(0, 2)); * LineParticle lp = new LineParticle(addParticleA, addParticleB, particlecolor); * * lock (DrawParticles) * { * DrawParticles.Add(lp); * } * * */ break; case 1: case 3: usepic = rdash.BackgroundImage; if (effectnumber == 3) { addparticlepos = new PointF(addparticlepos.X, ((float)Math.Sin(addparticlepos.X / 32) * 16) + addparticlepos.Y); } for (int addp = 0; addp < numparticles; addp++) { float ppercent = (float)addp / (float)numparticles; float usespeed = (float)(((maxoutspeed * 2) * ppercent) - maxoutspeed); PointF speeduse = new PointF((float)(rg.NextDouble() - 0.5d), usespeed); particlecolor = new HSLColor(ppercent * 240, 240, 120); //Particle addparticle = new PolyDebris(addparticlepos, rg.NextDouble() * 2, particlecolor, 3, 4, 3, 8); Particle addparticle = new PolyDebris(addparticlepos, speeduse, particlecolor, 3, 4, 3, 8); lock (DrawParticles) { DrawParticles.Add(addparticle); } } break; case 4: usepic = ttoaster.BackgroundImage; for (int addp = 0; addp < numparticles * 2; addp++) { particlecolor = Color.FromArgb(rg.Next(255), rg.Next(255), 0); Particle addparticle = new DustParticle(addparticlepos, (float)(rg.NextDouble() * 4), 7500, particlecolor); lock (DrawParticles) { DrawParticles.Add(addparticle); } } break; case 5: /* * */ //megaman sprites... //since these are loaded if (!mmimagesloaded) { mmimagesloaded = true; try { mmimages = BCBlockGameState.Imageman.getImageFrames("megaman"); } catch { mmimagesloaded = false; } } if (mmimagesloaded) { if ((DateTime.Now - lastmmFrameChange) > mmFrameDelayTime) { //advance the frame. mmimageframe++; } mmimageframe = mmimageframe % mmimages.Length; //they are... or should be, loaded now. usepic = mmimages[mmimageframe]; usesize = new Size(usepic.Size.Width * 3, usepic.Size.Height * 3); } break; /* * case 3: * * addparticlepos = new PointF(addparticlepos.X, ((float)Math.Sin(addparticlepos.X / 16) * 8) + addparticlepos.Y); * for (int addp = 0; addp < numparticles; addp++) * { * Particle addparticle = new PolyDebris(addparticlepos, rg.NextDouble()*2, particlecolor, 3, 4, 3, 8); * * * lock (DrawParticles) * { * DrawParticles.Add(addparticle); * } * } * break; */ } drawimagedata dd = new drawimagedata(); dd.DrawImage = (Image)usepic.Clone(); if (doflip) { dd.DrawImage.RotateFlip(RotateFlipType.RotateNoneFlipX); } dd.Location = addparticlepos; //imagesdraw.Add(new drawimagedata(BCBlockGameState.Imageman.GetLoadedImage("rdash") double ang = BCBlockGameState.GetAngle(prevparticlepos, addparticlepos); Debug.Print("chosen angle=" + ang); dd.Angle = ang; if (doflip) { dd.Angle += (float)Math.PI; } imagesdraw.Add(dd); prevparticlepos = addparticlepos; } } else if ((DateTime.Now - BobberThreadEffectFinish.Value).TotalSeconds >= 60) { EffectCount++; EffectCount = EffectCount % numeffects; switch (EffectCount) { case 0: case 1: case 2: case 3: EffectLengthi = 5000; if (BCBlockGameState.Soundman != null) //can be null, if you press shift during startup and take a while on the screen presented... { if (BCBlockGameState.Soundman.HasSound("asboom")) { BCBlockGameState.Soundman.PlaySound("asboom", 3.0f); } } break; case 4: iSoundSourceObject grabsound; if (BCBlockGameState.Soundman != null) { if (((grabsound = BCBlockGameState.Soundman.GetSoundRnd("TTOASTER")) != null)) { grabsound.Play(false, 3.0f); } } break; case 5: if (BCBlockGameState.Soundman != null) { BCBlockGameState.Soundman.PlaySound("ray"); } break; } Debug.Print("invoking effect #" + EffectCount); performingEffect = true; BobberThreadEffectStart = DateTime.Now; } } } }