private Position GetPositionInUpDirection()
        {
            int newLeft = this.Position.Left;
            int newTop = this.Position.Top - MoveStep;
            Position newPosition = new Position(newLeft, newTop);

            return newPosition;
        }
        public bool IsOverlapping(IGameObject gameObject)
        {
            IGameObject biggerObject;
            IGameObject smallerObject;

            if (this.Size.Width > gameObject.Size.Width)
            {
                biggerObject = this;
                smallerObject = gameObject;
            }
            else
            {
                biggerObject = gameObject;
                smallerObject = this;
            }

            var smallerObjectTopLeftCorner = new Position(smallerObject.Position.Left, smallerObject.Position.Top);
            var smallerObjectTopRightCorner = new Position(smallerObject.Position.Left + smallerObject.Size.Width, smallerObject.Position.Top);
            var smallerObjectBottomRightCorner = new Position(smallerObject.Position.Left + smallerObject.Size.Width, smallerObject.Position.Top + smallerObject.Size.Height);
            var smallerObjectBottomLeftCorner = new Position(smallerObject.Position.Left, smallerObject.Position.Top + smallerObject.Size.Height);

            var corners = new Position[]
            {
                smallerObjectTopLeftCorner,
                smallerObjectTopRightCorner,
                smallerObjectBottomRightCorner,
                smallerObjectBottomLeftCorner
            };

            var biggerObjectLeftBound = biggerObject.Position.Left;
            var biggerObjectRightBound = biggerObject.Position.Left + biggerObject.Size.Width;
            var biggerObjectTopBound = biggerObject.Position.Top;
            var biggerObjectBottomBound = biggerObject.Position.Top + biggerObject.Size.Height;

            foreach (var corner in corners)
            {
                if (biggerObjectLeftBound <= corner.Left && corner.Left <= biggerObjectRightBound &&
                    biggerObjectTopBound <= corner.Top && corner.Top <= biggerObjectBottomBound)
                {
                    return true;
                }
            }

            return false;
        }
 public MegaHadoukenGameObject(Position position, Size size)
     : base(position, size)
 {
 }
 public SpaceshipGameObject(Position position, Size size, IGameRenderer renderer)
     : base(position, size)
 {
     this.renderer = renderer;
 }
 public HadoukenGameObject(Position position, Size size)
     : base(position, size)
 {
     this.DefaultDirection = DirectionByDefault;
 }
        private Image CreateImageForCanvas(string path, Position position, Size size)
        {
            Image image = new Image();

            BitmapImage bitmap = new BitmapImage();
            bitmap.BeginInit();
            bitmap.UriSource = new Uri(path, UriKind.RelativeOrAbsolute);
            bitmap.EndInit();

            image.Source = bitmap;
            image.Width = size.Width;
            image.Height = size.Height;

            Canvas.SetLeft(image, position.Left);
            Canvas.SetTop(image, position.Top);

            return image;
        }
 private void AddToCanvas(string imagePath, Position position, Size size)
 {
     var image = this.CreateImageForCanvas(imagePath, position, size);
     this.canvas.Children.Add(image);
 }
        public void Stop()
        {
            this.gameWindow.KeyDown -= this.HandleMoveShipEvent;
            this.gameWindow.KeyDown -= this.HandleShipStartsFireEvent;
            this.gameWindow.KeyUp -= this.HandleShipStopsFireEvent;
            this.gameWindow.KeyDown += this.HandleRestartGameEvent;

            //Draw GameOver
            var gameOverPosition = new Position(this.GameoverLeft, this.GameoverTop);
            var gameOverSize = new Size(GameoverWidth, GameoverHeight);
            this.AddToCanvas(GameoverImagePath, gameOverPosition, gameOverSize);
        }
 public bool IsInBounds(Position possiiton)
 {
     return 0 <= possiiton.Left && possiiton.Left <= this.Width &&
            0 <= possiiton.Top && possiiton.Top <= this.Height;
 }
 public GameObject(Position position, Size size)
 {
     this.Position = position;
     this.Size = size;
     this.IsAlive = true;
 }