示例#1
0
        public override Vector2 getNextPos()
        {
            double  angle  = rnd.NextDouble() * 2 * Math.PI;
            double  radius = radiusMin + (radiusMax - radiusMin) * rnd.NextDouble();
            Vector2 retv   = Util.moveByAngleDist(pos, (float)angle, (float)radius);

            return(retv);
        }
示例#2
0
        /// <summary>
        /// Construct a circular path of waypoints
        /// </summary>
        /// <param name="center"></param>
        /// <param name="radius"></param>
        /// <param name="startAngle"></param>
        /// <param name="angleIncrement"></param>
        /// <param name="steps"></param>
        /// <param name="speed"></param>
        /// <param name="Xscale">usually 1 for a circle, can vary try 0.5 and 2 to creat ovals</param>

        public void makePathCircle(Vector2 center, float radius, float startAngle, float angleIncrement, int steps, float speed, float Xscale)
        {
            lst = new List <WayPoint>();

            for (int i = 0; i < steps; i++)
            {
                Vector2 v = Util.moveByAngleDist(new Vector2(0, 0), startAngle + (i * angleIncrement), radius);
                v.X = v.X * Xscale;
                v   = v + center;
                WayPoint w = new WayPoint(v, speed);
                add(w);
            }
        }
示例#3
0
        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
                    }
                }
            }
        }