Пример #1
0
        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);
        }
Пример #2
0
 public override void HandleCollision(GameObject other, GameTime gameTime)
 {
     _collisionStrategy.HandleCollision(this, other, gameTime);
 }