Ejemplo n.º 1
0
        public void AddExplosion(Vector2 location, Vector2 momentum)
        {
            Vector2 pieceLocation = location - new Vector2(pieceRectangles[0].Width / 2, pieceRectangles[0].Height / 2);
            int     pieces        = rand.Next(minPieceCount, maxPieceCount + 1);

            for (int x = 0; x < pieces; x++)
            {
                ExplosionParticles.Add(new Particle(pieceLocation, texture, pieceRectangles[rand.Next(0, pieceRectangles.Count)], randomDirection(pieceSpeedScale) + momentum, Vector2.Zero, explosionMaxSpeed, durationCount, initialColor, finalColor));
            }
            int points = rand.Next(minPointCount, maxPointCount + 1);

            for (int x = 0; x < points; x++)
            {
                ExplosionParticles.Add(new Particle(location, texture, pointRectangle, randomDirection((float)rand.Next(pointSpeedMin, pointSpeedMax)) + momentum, Vector2.Zero, explosionMaxSpeed, durationCount, initialColor, finalColor));
            }
            SoundManager.PlayExplosion();
        }
Ejemplo n.º 2
0
        private void checkShotToAsteroidCollisions()
        {
            foreach (Sprite shot in playerManager.PlayerShotManager.Shots)
            {
                foreach (Sprite asteroid in asteroidManager.Asteroids)
                {
                    if (shot.IsCircleColliding(
                            asteroid.Center,
                            asteroid.CollisionRadius))
                    {
                        if (shot.isRocket)
                        {
                            EffectManager.Effect("MeteroidExplode").Trigger(asteroid.Location);
                            asteroid.Location = offScreen;
                            SoundManager.PlayExplosion();
                        }
                        shot.Location = offScreen;

                        asteroid.Velocity += shotToAsteroidImpact;
                    }
                }
            }
        }