Exemplo n.º 1
0
 public static void SpawnParticle(ParticleProperties props, Vector2f position, Vector2f velocity)
 {
     if (props.Type == ParticleType.PT_SmokePuff)
     {
         SpawnSmokePuff(position, velocity, props.col, props.sizeSingle, props.lifeTime);
     }
     else if (props.Type == ParticleType.PT_SmokeCloud)
     {
         SpawnSmokeCloud(position, props.sizeMultiple, props.sizeSingle, props.col, props.lifeTime);
     }
     else if (props.Type == ParticleType.PT_DebrisSingle)
     {
         SpawnSingleDebris(position, velocity, props.col, props.sizeSingle, props.lifeTime);
     }
     else if (props.Type == ParticleType.PT_Debris_Multiple)
     {
         SpawnMultipleDebris(position, (float)Math.Sqrt(velocity.X * velocity.X + velocity.Y * velocity.Y), props.col, props.sizeSingle, props.lifeTime);
     }
     else if (props.Type == ParticleType.PT_RainDrop)
     {
         SpawnRainDrop(position, velocity, props);
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Exemplo n.º 2
0
 public ParticleEmitter(FloatRect shape, ParticleProperties props, float spawnFrequency, FloatRect initialParticleVelocity = new FloatRect())
 {
     _shape                   = shape;
     _properties              = props;
     _spawnTimeCurrent        = 1.0f / spawnFrequency;
     _spawnTimeTotal          = 1.0f / spawnFrequency;
     _initialParticleVelocity = initialParticleVelocity;
 }
Exemplo n.º 3
0
        public static void CreateSparksSpawner(FloatRect rect, Color col, float spawnFrequency)
        {
            ParticleProperties props = new ParticleProperties();

            props.Type              = ParticleManager.ParticleType.PT_Debris_Multiple;
            props.col               = col;
            props.lifeTime          = 2.0f;
            props.sizeMultiple      = 0.0f;
            props.sizeSingle        = 6;
            props.RotationType      = ParticleRotationType.PRT_Velocity;
            props.AffectedByGravity = true;

            ParticleEmitter emitter = new ParticleEmitter(rect, props, spawnFrequency, new FloatRect(-40, -250, 80, 40));

            ParticleManager.AddEmitter(emitter);
        }
Exemplo n.º 4
0
        public static void CreateChimney(FloatRect rect, Color col, float spawnFrequency)
        {
            ParticleProperties props = new ParticleProperties();

            props.Type              = ParticleManager.ParticleType.PT_SmokePuff;
            props.col               = col;
            props.lifeTime          = 14.0f;
            props.sizeMultiple      = 0.0f;
            props.sizeSingle        = 5;
            props.RotationType      = ParticleRotationType.PRT_None;
            props.AffectedByGravity = false;

            ParticleEmitter emitter = new ParticleEmitter(rect, props, spawnFrequency, new FloatRect(-5, -50, 10, 5));

            ParticleManager.AddEmitter(emitter);
        }
Exemplo n.º 5
0
        public static void CreateRainArea(FloatRect rect, Color col, float spawnFrequency)
        {
            ParticleProperties props = new ParticleProperties();

            props.Type              = ParticleManager.ParticleType.PT_RainDrop;
            props.col               = col;
            props.lifeTime          = 10.0f;
            props.sizeMultiple      = 0.0f;
            props.sizeSingle        = 8;
            props.RotationType      = ParticleRotationType.PRT_Velocity;
            props.AffectedByGravity = true;

            ParticleEmitter emitter = new ParticleEmitter(rect, props, spawnFrequency);

            ParticleManager.AddEmitter(emitter);
        }
Exemplo n.º 6
0
        public static void SpawnRainDrop(Vector2f position, Vector2f velocity, ParticleProperties props)
        {
            CheckInitialized();

            Shape newShape = new RectangleShape(new Vector2f(props.sizeSingle, 5));
            //newShape.Rotation = 20.0f * (float)(Math.PI * Math.Atan(velocity.Y / velocity.X));
            Color newColor = props.col;

            newColor.A         = 100;
            newShape.FillColor = newColor;

            ShapeParticle particle = new ShapeParticle(newShape, props.lifeTime, position, velocity);

            particle.FrictionCoefficient = 1.0f - 0.01f * (float)RandomGenerator.Random.NextDouble();
            particle.AlphaChangeType     = PennerDoubleAnimation.EquationType.None;
            particle.AffectedByGravity   = props.AffectedByGravity;
            particle.RotationType        = props.RotationType;
            _particleList.Add(particle);
        }