Exemplo n.º 1
0
        internal void UpdateAndDraw(float a_elapsedTime, SpriteBatch a_spriteBatch, Camera a_camera, Vector2 position)
        {
            if (shouldUpdateAndDraw == true)
            {
                for (int i = 0; i < MAX_PARTICLES; i++)
                {
                    //Update particle
                    allParticles.ElementAt(i).Update(a_elapsedTime, position, i);

                    //Check if particle is alive
                    if (allParticles.ElementAt(i).IsAlive())
                    {
                        //Get particle position and convert to view coordinates
                        Vector2 particleCenterPosition = a_camera.getViewPosition(allParticles.ElementAt(i).getParticlePostion().X, allParticles.ElementAt(i).getParticlePostion().Y - .45f, new Vector2(a_camera.getScreenWidth(), a_camera.getScreenHeight()));

                        float a = allParticles.ElementAt(i).getVisibility();
                        Color particleColor = new Color(a, a, a, a);

                        //Spark destination rectangle
                        Rectangle destinationRectangle = new Rectangle((int)particleCenterPosition.X, (int)particleCenterPosition.Y, 10, 10);

                        a_spriteBatch.Draw(sparkTexture, destinationRectangle, particleColor);
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal void UpdateAndDraw(float a_elapsedTime, SpriteBatch a_spriteBatch, Camera a_camera)
        {
            particleSystemTL += a_elapsedTime;

            releaseTimer += a_elapsedTime;

            while (releaseTimer >= releaseRate)
            {
                if (totalParticles < maxParticles)
                {
                    allSmokeParticles.Add(new SmokeParticle(systemPosition, totalParticles));
                    totalParticles += 1;
                }
                releaseTimer -= releaseRate;
            }

            for (int index = 0; index < allSmokeParticles.Count; index++)
            {

                //Update particle
                allSmokeParticles.ElementAt(index).Update(a_elapsedTime, systemPosition, index);

                //Check if particle is alive
                if (allSmokeParticles.ElementAt(index).IsAlive())
                {
                    //Get particle position and convert to view coordinates
                    Vector2 particleCenterPosition = a_camera.getViewPosition(allSmokeParticles.ElementAt(index).getParticlePostion().X, allSmokeParticles.ElementAt(index).getParticlePostion().Y - .45f, new Vector2(a_camera.getScreenWidth(), a_camera.getScreenHeight()));

                    //Spark destination rectangle
                    Rectangle destinationRectangle = new Rectangle((int)particleCenterPosition.X, (int)particleCenterPosition.Y, smokeTexture.Width, smokeTexture.Height);

                    float a = allSmokeParticles.ElementAt(index).GetVisibility();
                    Color particleColor = new Color(a, a, a, a);

                    scale = allSmokeParticles.ElementAt(index).getScale();

                    rotation = allSmokeParticles.ElementAt(index).getRotation();

                    a_spriteBatch.Draw(smokeTexture, particleCenterPosition, null, particleColor, rotation, textureOrigin, scale, SpriteEffects.None, 0);

                }

            }

            for (int z = 0; z < allSmokeParticles.Count; z++)
            {
                allSmokeParticles.ElementAt(z).Update(a_elapsedTime, systemPosition, z);
                if (!allSmokeParticles.ElementAt(z).IsAlive())
                {
                    allSmokeParticles.RemoveAt(z);
                    z--;
                }
            }
        }