Пример #1
0
        private void DusmanPanel_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && !buttonRastgele.Enabled)
            {
                int w = BenPanel.Width / ReturnMasSize();
                int h = BenPanel.Height / ReturnMasSize();
                int x = e.X / w;
                int y = e.Y / h;

                if (GetEnemyValue(y, x) == 2)
                {
                    SetEnemyValue(y, x, 3);
                    EnemyShip--;
                    Explosion(x, y, GetEnemyLink());
                    DusmanPanel.Invalidate();
                    if (EnemyShip == 0)
                    {
                        Victory("Tebrikler Kazandiniz...:)");
                    }
                }
                else if (GetEnemyValue(y, x) == 0)
                {
                    EnemyTurn();
                    SetEnemyValue(y, x, 4);
                    DusmanPanel.Invalidate();
                }
            }
        }
Пример #2
0
        private void buttonHazir_Click(object sender, EventArgs e)
        {
            if (!(radioButton1.Enabled == false && radioButton2.Enabled == false && radioButton3.Enabled == false &&
                  radioButton4.Enabled == false))
            {
                MessageBox.Show("Lütfen tüm gemileri yerleştirin.", "Dikkat!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                BenPanel.Enabled       = false;
                buttonHazir.Enabled    = false;
                buttonHazir.Visible    = true;
                buttonTemizle.Enabled  = false;
                buttonRastgele.Enabled = false;
                buttonRestart.Enabled  = true;
                buttonRestart.Visible  = true;
                buttonRestart.Location = new Point(319, 317);


                Count1X = 0;
                Count2X = 0;
                Count3X = 0;
                Count4X = 0;
                int y, x, count = 10, size = 3;
                while (count > 0)
                {
                    Random r = new Random();
                    if (count < 10)
                    {
                        size = 2;
                    }
                    if (count < 8)
                    {
                        size = 1;
                    }
                    if (count < 5)
                    {
                        size = 0;
                    }
                    y = r.Next(0, 10);
                    x = r.Next(0, 10);
                    if (r.Next(0, 2) == 1)
                    {
                        ChangeVerctical();
                    }
                    if (CheckSq(x, y, size, GetEnemyLink()))
                    {
                        CreateShip(x, y, 2, size, GetEnemyLink());
                        count--;
                    }
                }

                DusmanPanel.Invalidate();
            }
        }
Пример #3
0
 private void DusmanPanel_MouseMove(object sender, MouseEventArgs e)
 {
     DusmanPanel.Invalidate();
 }