コード例 #1
0
        protected void AddExplosion(Vector2 explosionPos, int numberOfParticles, float size, float maxAge, GameTime gameTime)
        {
            Random randomizer = new Random();

            for (int i = 0; i < numberOfParticles; i++)
            {
                AddExplosionParticle(explosionPos, size, maxAge, gameTime, i);
            }

            float  rotation = (float)randomizer.Next(10);
            Matrix mat      = Matrix.CreateTranslation(-_explosion.explosionTexture.Width / 2, -_explosion.explosionTexture.Height / 2, 0) * Matrix.CreateRotationZ(rotation) * Matrix.CreateScale(size / (float)_explosion.explosionTexture.Width * 2.0f) * Matrix.CreateTranslation(explosionPos.X, explosionPos.Y, 0);

            bg.AddCrater(_explosion.explosionColorArray, mat);

            for (int i = 0; i < players.Length; i++)
            {
                players[i].Position.Y = bg.terrainContour[(int)players[i].Position.X];
            }
            bg.FlattenTerrainBelowPlayers(players);
            bg.CreateForeground();
        }