Esempio n. 1
0
        public void TestGetSpawnDirectionsAt()
        {
            SpawnFutureRng future = new SpawnFutureRng();

            future.AddSpawnDirections(GetSpawnDirections());
            future.AddSpawnDirections(GetSpawnDirections());
            future.AddSpawnDirections(GetSpawnDirections());
            SpawnDirections directions = GetSpawnDirections();

            directions.Directions = 7;

            future.AddSpawnDirections(directions);
            SpawnDirections copy = future.GetSpawnDirectionsAtIndex(3);

            Assert.AreEqual(directions.Directions, copy.Directions);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes the particle System. 
        /// The Particle will spawn at the specified RECTANGLE with the defined SpawnType, 
        /// with the specified Directions, speed and the specified Gravity
        /// </summary>
        /// <param name="fontaine">Determines the spawnType:
        /// Fontain: The particles will spawn continously at the specified Point
        /// Explosion: The particles will spawn all at once at the specified Point</param>
        /// <param name="pnumParticles">Maximum particle number</param>
        /// <param name="particle_s">Spawntype:
        /// Fontain: The Particle per second (must be >= 60 to spawn any particles), also controls the particle lifetime = numParticles/particle_s
        /// Explosion: The particles Lifetime</param>
        /// <param name="Size">The Size of the Particles</param>
        /// <param name="pStdColor">The Color of the Particles</param>
        /// <param name="startpos">The Startpoint of the Rectangle where the particles are going to spawn</param>
        /// <param name="endpos">The Endpos of the Rectangle where the particles are going to spawn</param>
        /// <param name="pdirections">Determines the Directions in which the particles are going to go</param>
        /// <param name="maxSpeed">The Maxmimum x and y speed</param>
        /// <param name="tex">The Texture of the particles</param>
        /// <param name="Gravity">The Gravity Type.
        /// OverallForce: all particles will be forced in that direction
        /// Point: All particles are going to move to that direction
        /// Newton: All particles are going to have planetary Gravity, Masses can be defined with the AddNewtonMass() method</param>
        /// <param name="gravAim">
        /// Gravity Type:
        /// Overall Force: The force which will be applied.
        /// Point: The Point, the particles are heading to.
        /// Newton: No affect
        /// </param>
        /// <param name="pfriction">Particles speed will bei divided by this when they collided with sth.</param>
        /// <param name="collison">Defines if the particles can collide or not</param>
        public void Initialize(bool bla, SpawnType fontaine, int pnumParticles, float particle_s, int Size, Color pStdColor, Vector2 startpos, Vector2 endpos,
	SpawnDirections pdirections, Vector2 maxSpeed, Texture2D tex, GravityType Gravity, Vector2 gravAim,
	float pfriction, CollisionType collison)
        {
            if (startpos != endpos)
                spawnsource = SpawnSource.Rectangle;
            else
                spawnsource = SpawnSource.Point;

            masses = new List<NewtonMass>();
            collisiontype = collison;
            spawntype = fontaine;
            gravtype = Gravity;
            spawndirections = pdirections;

            size = Size;

            rand = new Random((int)DateTime.Now.Ticks);
            stdcolor = pStdColor;
            spawn = startpos;
            spawnend = endpos;
            maxspeed = maxSpeed;
            spawnperS = particle_s;
            numParticles = pnumParticles;
            positions = new Vector2[numParticles];
            velocities = new Vector2[numParticles];
            lifetimes = new float[numParticles];
            rects = new Rectangle[numParticles];
            Rotations = new float[numParticles];
            alphas = new byte[numParticles];
            floatalphas = new float[numParticles];
            collisionrectangles = new List<Rectangle>();
            collisionrectangles.Add(new Rectangle(-500000000, 0, 0, 0));
            particletex = tex;
            gravtype = Gravity;
            friction = MathHelper.Clamp(pfriction, float.Epsilon, float.MaxValue);
            gravity = gravAim;
            duration = new TimeSpan[numThreads];
            if (fontaine == SpawnType.Fontaine)
            {
                totallifetime = pnumParticles / particle_s;
            }
            else
            {
                totallifetime = particle_s;
            }
            for (int i = 0; i < pnumParticles; i++)
            {
                ResetParticle(i);
                lifetimes[i] = totallifetime + 1;
            }
            running = true;
            updatethread = new Thread[numThreads];
            newframe = new bool[numThreads];
            for (int i = 0; i < numThreads; i++)
            {
                updatethread[i] = new Thread((new ParameterizedThreadStart(UpdateThread)));
                updatethread[i].Name = "ParticleThread#" + i.ToString();
            }
            initialized = true;
            airFriction = 1;

            newSpawners = 0;
            InitalizeCUDA();
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes the particle System. 
        /// The Particle will spawn at the specified POINT with the defined SpawnType, 
        /// with the specified Directions, speed and the specified Gravity
        /// </summary>
        /// <param name="fontaine">Determines the spawnType:
        /// Fontain: The particles will spawn continously at the specified Point
        /// Explosion: The particles will spawn all at once at the specified Point</param>
        /// <param name="pnumParticles">Maximum particle number</param>
        /// <param name="particle_s">Spawntype:
        /// Fontain: The Particle per second (must be >= 60 to spawn any particles), also controls the particle lifetime = numParticles/particle_s
        /// Explosion: The particles Lifetime</param>
        /// <param name="Size">The Size of the Particles</param>
        /// <param name="pStdColor">The Color of the Particles</param>
        /// <param name="src">The Point where the particles are going to spawn</param>
        /// <param name="pdirections">Determines the Directions in which the particles are going to go</param>
        /// <param name="maxSpeed">The Maxmimum x and y speed</param>
        /// <param name="tex">The Texture of the particles</param>
        /// <param name="Gravity">The Gravity Type.
        /// OverallForce: all particles will be forced in that direction
        /// Point: All particles are going to move to that direction
        /// Newton: All particles are going to have planetary Gravity, Masses can be defined with the AddNewtonMass() method</param>
        /// <param name="gravAim">
        /// Gravity Type:
        /// Overall Force: The force which will be applied.
        /// Point: The Point, the particles are heading to.
        /// Newton: No affect
        /// </param>
        /// <param name="pfriction">Particles speed will bei divided by this when they collided with sth.</param>
        /// <param name="collison">Defines if the particles can collide or not</param>
        public void Initialize(bool bla, SpawnType fontaine, int pnumParticles, float particle_s, int Size, Color pStdColor, Vector2 src,
			SpawnDirections pdirections, Vector2 maxSpeed, Texture2D tex, GravityType Gravity, Vector2 gravAim,
			float pfriction, CollisionType collison)
        {
            Initialize(false,
                fontaine,
                pnumParticles,
                particle_s,
                Size,
                pStdColor,
                src,
                src,
                pdirections,
                maxSpeed,
                tex,
                Gravity,
                gravAim,
                pfriction,
                collison);
        }