/// <summary> /// returns the index for subsequent use as leg /// </summary> /// <param name="w"></param> /// <returns></returns> public int add(WayPoint w) { lst.Add(w); return(lst.Count() - 1); }
public void makeParticles(int num) { if (!generation || !active) { return; //no more particles to generate } if (particlecount >= maxNum) { return; // no posibility of making particls } int cnt = 0; Vector2 randy; // for varous random things for (int i = 0; i < maxNum; i++) { //particles[i] = new Particle(); if (!particles[i].active) { // make one here particles[i].tex = tex; particles[i].active = true; if (Origin == 0) { particles[i].pos.X = sysPos.X; //position particles[i].pos.Y = sysPos.Y; //position } if (Origin == 1) { particles[i].pos.X = originRectangle.X + originRectangle.Width * (float)rnd.NextDouble(); //position particles[i].pos.Y = originRectangle.Y + originRectangle.Height * (float)rnd.NextDouble(); //position } if (Origin == 2) { WayPoint wp = originWayList.getWayPoint(originWayList.getCurrentLeg()); originWayList.nextLeg(); particles[i].pos.X = wp.pos.X; //position particles[i].pos.Y = wp.pos.Y; //position } if (Origin == 3) { int q = rnd.Next(originWayList.lst.Count()); WayPoint wp = originWayList.getWayPoint(q); particles[i].pos.X = wp.pos.X; //position particles[i].pos.Y = wp.pos.Y; //position } particles[i].vel = initialVelosity; //velocity // add random bit randy = (new Vector2((float)rnd.NextDouble(), (float)rnd.NextDouble()) * initialVelosityRandom - (initialVelosityRandom / 2)); particles[i].vel = particles[i].vel + randy; particles[i].delta = delta + (randomDelta * new Vector2((float)rnd.NextDouble(), (float)rnd.NextDouble()) - randomDelta / 2); if (initalAngleHigh != 0) { //set a radial velocity float angle = rnd.Next((int)initalAngleLow, (int)initalAngleHigh); float velocity = rnd.Next((int)(initalVelocityLow * 100), (int)(initalVelocityHigh * 100)) / 100.0f; Vector2 v = Util.moveByAngleDist(new Vector2(0, 0), Util.degToRad(angle), velocity); particles[i].vel = v; } particles[i].startSize = startSize; particles[i].endSize = endSize; particles[i].startColor = startColor; particles[i].endColor = endColor; particles[i].bounds = bounds; // my bounds particles[i].AgeInTicks = 0; particles[i].maxAgeInTicks = ticksParticleDuration; particles[i].destRectangle.X = (int)particles[i].pos.X; particles[i].destRectangle.Y = (int)particles[i].pos.Y; particles[i].destRectangle.Width = (int)particles[i].startSize.X; particles[i].destRectangle.Height = (int)particles[i].startSize.Y; if (moveTowards == 1) { // 0= nix 1= towards moveTowardsPos particles[i].vel = ((moveTowardsPos - particles[i].pos) / (float)ticksParticleDuration) + randy; particles[i].delta = new Vector2(0, 0); // usually you want this } if (moveTowards == 2) { // 0= nix 1= towards moveTowardsPos Vector2 v = (particles[i].pos - moveTowardsPos); v.Normalize(); particles[i].vel = (v * moveToDrift) + randy; particles[i].delta = new Vector2(0, 0); // usually you want this } cnt++; particlecount++; totalNumberMade++; if (totalNumberMade >= totalNumberToMake) { return; } if (cnt >= num) { return; // done them all } if (particlecount >= maxNum) { return; // no more possible } } } }