public void HandleCollision(GameObject self, GameObject other, GameTime gameTime)
        {
            if (!(self is Car player))
            {
                throw new InvalidOperationException("Strategy is not applicaplbe for non player objects.");
            }

            // Collision to the course border
            if (other == null)
            {
                _borderCollisionStrategy.HandleCollision(player, null, gameTime);
            }
            else
            {
                _basicCollisionStrategy?.HandleCollision(player, other, gameTime);
            }

            SetCollisionPenality(player, other, gameTime);
        }
Exemple #2
0
 public override void HandleCollision(GameObject other, GameTime gameTime)
 {
     _collisionStrategy.HandleCollision(this, other, gameTime);
 }