public override void OnCollision(Sprite other)
 {
     if (other.objectName == "Player")
     {
         //give health to player
         ((Player)other).health++;
         //create pickup pop effect
         Sprite pPop = new TimedObject(textures["Square"], new Vector2(transform.m7, transform.m8), new List <Sprite> {
             new ParticleSystem(textures["Square"], new Vector2(0, 0), "AsteroidPopParticles")
             {
                 color = Fade(RED, 0.7f), lifeTime = 1, scale = new Vector2(5, 5), minVelocity = new Vector2(-100, -100), maxVelocity = new Vector2(100, 100), particlePerEmit = 50, emitTime = 0, maxParticleCount = 50
             }
         }, "LifePickup")
         {
             waitTime = 1
         };
         NewObject(pPop);
         Destroy(this);
     }
 }
        public override void OnCollision(Sprite other)
        {
            if (other.objectName == "Missile")
            {
                player.score += 10 + 5 * (size - 1);
                Destroy(other);
                if (size != 1)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        //random rotation
                        int randomRot = random.Next(0, 360);

                        //random asteroid texture name
                        string asteroidTextureName = "Asteroid" + random.Next(1, 5);

                        //create asteroid
                        Asteroid a = new Asteroid(textures[asteroidTextureName], new Vector3(transform.m7, transform.m8, randomRot), "Asteroid")
                        {
                            Scale = (size - 1) * spawner.asteroidSizeModifier
                        };
                        a.size = size - 1;
                        float speed    = random.Next(spawner.minAsteroidSpeed, spawner.maxAsteroidSpeed); //random speed
                        float angleRad = (float)random.NextDouble() * 2;                                  //random angle
                        //apply speed and angle to velocity of new asteroid
                        a.collider.velocity.x = MathF.Cos(angleRad) * speed;
                        a.collider.velocity.y = MathF.Sin(angleRad) * speed;
                        a.spawner             = spawner;
                        a.player = player;
                        NewObject(a);
                    }
                }
                if (random.Next(0, 15) == 0)
                {
                    //create life pickup
                    Sprite lifePickup = new LifePickup(textures["Heart"], new Vector2(transform.m7, transform.m8), new List <Sprite> {
                        new ParticleSystem(textures["Square"], new Vector2(0, 0), "LifeParticles")
                        {
                            color = Fade(RED, 0.7f), lifeTime = 2, scale = new Vector2(5, 5), minVelocity = new Vector2(-10, -10), maxVelocity = new Vector2(10, -5)
                        }
                    }, "LifePickup")
                    {
                        Rotation = 0
                    };
                    lifePickup.collider.velocity = collider.velocity * 0.1f;
                    NewObject(lifePickup);
                }
                //create asteroid pop effect
                Sprite aPop = new TimedObject(textures["Square"], new Vector2(transform.m7, transform.m8), new List <Sprite> {
                    new ParticleSystem(textures["Square"], new Vector2(0, 0), "AsteroidPopParticles")
                    {
                        color = Fade(BROWN, 0.7f), lifeTime = 1, scale = new Vector2(5, 5), minVelocity = new Vector2(-100, -100), maxVelocity = new Vector2(100, 100), particlePerEmit = 50, emitTime = 0
                    }
                }, "AsteroidPop")
                {
                    waitTime = 1
                };
                NewObject(aPop);

                Destroy(this);
            }
            //damage player
            if (other.objectName == "Player")
            {
                //create asteroid pop effect
                ((Player)other).health--;
                Sprite aPop = new TimedObject(textures["Square"], new Vector2(transform.m7, transform.m8), new List <Sprite> {
                    new ParticleSystem(textures["Square"], new Vector2(0, 0), "AsteroidPopParticles")
                    {
                        color = Fade(BROWN, 0.7f), lifeTime = 1, scale = new Vector2(5, 5), minVelocity = new Vector2(-100, -100), maxVelocity = new Vector2(100, 100), particlePerEmit = 50, emitTime = 0
                    }
                }, "AsteroidPop")
                {
                    waitTime = 1
                };
                NewObject(aPop);

                //smaller RED and WHITE particle explosions for visualising the ship taking damage
                Sprite playerDamagePop1 = new TimedObject(textures["Square"], new Vector2(transform.m7, transform.m8), new List <Sprite> {
                    new ParticleSystem(textures["Square"], new Vector2(0, 0), "PlayerDamagePopParticles")
                    {
                        color = Fade(RED, 0.4f), lifeTime = 1, scale = new Vector2(5, 5), minVelocity = new Vector2(-100, -100), maxVelocity = new Vector2(100, 100), particlePerEmit = 25, emitTime = 0, maxParticleCount = 25
                    }
                }, "PlayerDamagePop")
                {
                    waitTime = 1
                };
                NewObject(playerDamagePop1);
                Sprite playerDamagePop2 = new TimedObject(textures["Square"], new Vector2(transform.m7, transform.m8), new List <Sprite> {
                    new ParticleSystem(textures["Square"], new Vector2(0, 0), "PlayerDamagePopParticles")
                    {
                        color = Fade(WHITE, 0.4f), lifeTime = 1, scale = new Vector2(5, 5), minVelocity = new Vector2(-100, -100), maxVelocity = new Vector2(100, 100), particlePerEmit = 25, emitTime = 0, maxParticleCount = 25
                    }
                }, "PlayerDamagePop")
                {
                    waitTime = 1
                };
                NewObject(playerDamagePop2);

                Destroy(this);
            }
        }