private void AttckTimer_Tick(object sender, EventArgs e)
        {
            WarshipLocation.X = Canvas.GetLeft(warship);
            WarshipLocation.Y = Canvas.GetTop(warship);

            if ((OneSec) % (20 - level) == 0 && !IsMonsterLevel)
            {
                Attack();
            }
            else if (IsMonsterLevel)
            {
                double left = Canvas.GetLeft(monster);
                if (left <= 0 || left >= size.Width - monster.Width + 10)
                {
                    increment *= -1;
                }
                Canvas.SetLeft(monster, left + increment);
                if (OneSec % 30 == 0)
                {
                    Bomb(left + 10);
                    Bomb(left + monster.Width - 10);
                }
            }
            OneSec++;
            for (int i = 0; i < Rocks.Count; i++)
            {
                CImage img = Rocks[i];
                //img.Angle = RockAngle;

                double x = Canvas.GetLeft(img);
                double y = Canvas.GetTop(img);
                x += 10 * Math.Sin(img.Angle * Math.PI / 180);
                y += 10 * Math.Cos(img.Angle * Math.PI / 180);
                Canvas.SetTop(img, y);
                Canvas.SetLeft(img, x);

                if (Canvas.GetTop(img) >= WarshipLocation.Y + 5)
                {
                    if (Canvas.GetLeft(img) + img.Width + 5 >= Canvas.GetLeft(warship) &&
                        Canvas.GetLeft(img) + (img.Width / 2) <= Canvas.GetLeft(warship) + warship.Width)
                    {
                        Rocks.Remove(img);
                        Boom(Canvas.GetTop(img), Canvas.GetLeft(img), "boom2");
                        mainCanvas.Children.Remove(img);
                        life.Value -= 20;
                        continue;
                    }
                }
                if (x <= 0 || x >= size.Width - 50)
                {
                    img.Angle = 360 - img.Angle;
                }
                if (Canvas.GetTop(img) >= size.Height - 50)
                {
                    Rocks.Remove(img);
                    mainCanvas.Children.Remove(img);
                }
            }
        }
        private void Shoooooot()
        {
            CImage stone = new CImage();

            stone.Source  = new BitmapImage(new Uri(@"img/target.png", UriKind.Relative));
            stone.Stretch = Stretch.Fill;
            stone.Angle   = GunAngle;
            stone.Width   = 20;
            Canvas.SetLeft(stone, Canvas.GetLeft(warship) + (warship.Width - stone.Width) / 2);
            Canvas.SetTop(stone, Canvas.GetTop(warship) - 20);
            mainCanvas.Children.Add(stone);
            Bults.Add(stone);
        }
        private void Attack()
        {
            CImage stone = new CImage();

            stone.Source  = new BitmapImage(new Uri(@"img/ston.png", UriKind.Relative));
            stone.Stretch = Stretch.Fill;
            stone.Width   = 40;
            Random ran = new Random();

            Canvas.SetLeft(stone, ran.Next(40, (int)(size.Width - 40)));
            stone.Angle = level > 1 ? ran.Next(-75, 75) : 0;
            Canvas.SetTop(stone, 1);
            mainCanvas.Children.Add(stone);
            Rocks.Add(stone);
        }
        private void Bomb(double left)
        {
            Random ran  = new Random();
            CImage bomb = new CImage();

            bomb.Source  = new BitmapImage(new Uri(@"img/bomb.png", UriKind.Relative));
            bomb.Stretch = Stretch.Fill;
            bomb.Angle   = ran.Next(-75, 75);
            bomb.Width   = 30;
            Canvas.SetLeft(bomb, left);
            Canvas.SetTop(bomb, Canvas.GetTop(monster) + monster.Height - 10);
            RotateTransform rt = new RotateTransform(bomb.Angle);

            bomb.RenderTransform = rt;
            mainCanvas.Children.Add(bomb);
            Rocks.Add(bomb);
        }
        private void BultsTimer_Tick(object sender, EventArgs e)
        {
            if (IsShoot && ShWait % 2 == 0)
            {
                Shoooooot();
                ShWait = 0;
            }
            ShWait++;
            for (int i = 0; i < Bults.Count; i++)
            {
                CImage img = Bults[i];
                //img.Angle = GunAngle;
                double x = Canvas.GetLeft(img);
                double y = Canvas.GetTop(img);
                x += 10 * Math.Sin(img.Angle * Math.PI / 180);
                y -= 10 * Math.Cos(img.Angle * Math.PI / 180);
                Canvas.SetTop(img, y);
                Canvas.SetLeft(img, x);

                Canvas.SetTop(img, Canvas.GetTop(img) - 10);
                for (int j = 0; j < Rocks.Count; j++)
                {
                    CImage r = Rocks[j];
                    if (Canvas.GetTop(img) - 5 <= Canvas.GetTop(r) + 20 &&
                        Canvas.GetTop(img) + 20 >= Canvas.GetTop(r))
                    {
                        if (Canvas.GetLeft(img) + img.Width / 2 >= Canvas.GetLeft(r) &&
                            Canvas.GetLeft(img) + img.Width / 2 <= Canvas.GetLeft(r) + r.Width)
                        {
                            Boom(Canvas.GetTop(r), Canvas.GetLeft(r), "boom");
                            Bults.Remove(img);
                            Rocks.Remove(r);
                            mainCanvas.Children.Remove(img);
                            mainCanvas.Children.Remove(r);
                            tb_score.Text = (++Scoure).ToString();
                        }
                    }
                }
                if (IsMonsterLevel)
                {
                    if ((Canvas.GetTop(img) - 10 <= Canvas.GetTop(monster) + monster.Height - 10) &&
                        (Canvas.GetTop(img) >= Canvas.GetTop(monster)) &&
                        Canvas.GetLeft(img) + img.Width >= Canvas.GetLeft(monster) &&
                        (Canvas.GetLeft(img) - img.Width <= Canvas.GetLeft(monster) + monster.Width))
                    {
                        Boom(Canvas.GetTop(img), Canvas.GetLeft(img), "boom2");
                        Bults.Remove(img); mainCanvas.Children.Remove(img);
                        tb_score.Text      = (Scoure += 5).ToString();
                        monsterLife.Value -= 1;
                    }
                }
                if (x <= -10 || x >= size.Width - 20)
                {
                    img.Angle = 360 - img.Angle;
                }

                if (Canvas.GetTop(img) <= 0)
                {
                    Bults.Remove(img);
                    mainCanvas.Children.Remove(img);
                }
            }
        }