Exemple #1
0
        public void resolveCollision(CrusaderShield collider)
        {
            if (!collider.isAlive || GameScreen.deadAsteroids.Contains(this))
            {
                return;
            }

            float distance = (_position - collider.Position).Length();

            if (!(distance < radius + collider.radius))
            {
                return;
            }

            /*
             * // determine normal
             * Vector2 unitNormal = _position - collider.Position;
             * unitNormal.Normalize (); // normalize normal
             * // ensure asteroids do not stick together or orbit eachother
             * _position = collider.Position + ( ( radius + collider.radius ) * unitNormal );
             * // determine the initial velocity in direction of the normal
             * Vector2 velocityNormal = Vector2.Dot ( _initialVelocity, unitNormal ) * unitNormal;
             *
             * _velocity = _initialVelocity - ( 2 * velocityNormal );
             */


            GameScreen.deadAsteroids.Enqueue(this);
            GameScreen.currentNumAsteroids--;
            isAlive = false;
        }
Exemple #2
0
 public void resolveCollision(CrusaderShield collider)
 {
     if (boxCollider.Intersects(collider.boxCollider) && collider.isAlive)
     {
         collider.Hit();
         Player._currentActive = null;
         isAlive = false;
     }
 }