示例#1
0
        public void AddExplosion(Vector2 location, Vector2 momentum, ParticleConfig config)
        {
            Rectangle rect          = _explosionTileSheet.TileAt(0, 0);
            Vector2   pieceLocation = location - new Vector2(rect.Width / 2, rect.Height / 2);

            int piecesToGenerate = _rand.Next(config.MinPieceCount, config.MaxPieceCount + 1);

            GeneratePieces(pieceLocation, momentum, piecesToGenerate, config);

            int pointsToGenerate = _rand.Next(config.MinPointCount, config.MaxPointCount + 1);

            GeneratePoints(pieceLocation, momentum, pointsToGenerate, config);
        }
示例#2
0
        public void AddExplosion(Vector2 location, Vector2 momentum)
        {
            ParticleConfig config = new ParticleConfig
            {
                MinPointCount   = 15,
                MaxPointCount   = 20,
                MinPieceCount   = 2,
                MaxPieceCount   = 4,
                PieceSpeedScale = 6,
                Duration        = 90,
                InitialColor    = new Color(1, 3, 0, 0.5f),
                FinalColor      = new Color(1, 3, 0, 0)
            };

            AddExplosion(location, momentum, config);
        }
示例#3
0
        public void AddLargeExplosion(Vector2 location)
        {
            ParticleConfig config = new ParticleConfig
            {
                MinPointCount   = 15,
                MaxPointCount   = 20,
                MinPieceCount   = 4,
                MaxPieceCount   = 6,
                PieceSpeedScale = 30,
                Duration        = 90,
                InitialColor    = new Color(1, 3, 0, 0.5f),
                FinalColor      = new Color(1, 3, 0, 0)
            };

            AddExplosion(location, Vector2.Zero, config);
        }
示例#4
0
        private void GeneratePieces(Vector2 pieceLocation, Vector2 momentum, int piecesToGenerate, ParticleConfig config)
        {
            for (int i = 0; i < piecesToGenerate; i++)
            {
                Sprite s = _explosionTileSheet.SpriteAnimation();

                Particle p = new Particle(s, Vector2.Zero, ExplosionMaxSpeed, config.Duration, config.InitialColor, config.FinalColor);
                p.Location = pieceLocation;
                p.Velocity = RandomDirection(config.PieceSpeedScale) + momentum;

                _particles.Add(p);
            }
        }
示例#5
0
        private void GeneratePoints(Vector2 pointLocation, Vector2 momentum, int pointsToGenerate, ParticleConfig config)
        {
            int pointSpeedMin = (int)config.PieceSpeedScale * 2;
            int pointSpeedMax = (int)config.PieceSpeedScale * 3;

            for (int i = 0; i < pointsToGenerate; i++)
            {
                Sprite s = _particleTileSheet.SpriteAnimation();

                Particle p = new Particle(s, Vector2.Zero, ExplosionMaxSpeed, config.Duration, config.InitialColor, config.FinalColor);
                p.Location = pointLocation;

                int pointSpeed = _rand.Next(pointSpeedMin, pointSpeedMax);
                p.Velocity = RandomDirection(pointSpeed) + momentum;

                _particles.Add(p);
            }
        }