示例#1
0
 public void CreateParticle(float delta, ParticleConfig config)
 {
     if (!Enabled) return;
     _lastSpawn += delta;
     if (_lastSpawn <= SpawnRate * delta) return;
     if (_singleTexture) AllParticles.Add(new Particle(ParticleTextures[0], config));
     else AllParticles.Add(new Particle(ParticleTextures.GetRandom(), config));
     _lastSpawn = 0;
 }
示例#2
0
        public Particle(Texture2D texture, ParticleConfig config)
        {
            Config = config;
            Texture = texture;
            OriginalColor = config.Color;
            OriginalScale = config.Scale;
            OriginalTimeToLive = config.TimeToLive;
            Alive = true;

            if (Config.VelocityInterpolate)
                (_velocity = new Vector2Interpolator()).Start(Config.Velocity, Config.TargetVelocity, Config.TimeToLive);
            if (Config.ScaleInterpolate)
                (_scale = new FloatInterpolator()).Start(Config.Scale, Config.TargetScale, Config.TimeToLive, true);
            if (Config.RotationVelocityInterpolate)
                (_rotation = new FloatInterpolator()).Start(Config.RotationVelocity, Config.TargetRotationVelocity, Config.TimeToLive);
            if (Config.ColorInterpolate)
                (_color = new ColorInterpolator()).Start(Config.Color, Config.TargetColor, Config.TimeToLive);
            if (OnParticleCreated != null) OnParticleCreated.Invoke(this, GameEventArgs.Empty);
        }