예제 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            MyShip = ButtonSupport.CreateShip(ShipCountANDLength[Stage], this);
            int y = 20;
            int x = 640;

            Button[,] Enemy = new Button[10, 10];
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Enemy[i, j]          = new Button();
                    Enemy[i, j].Size     = new Size(50, 50);
                    Enemy[i, j].Location = new Point(x, y);
                    Enemy[i, j].Name     = i.ToString();
                    Enemy[i, j].Click   += new System.EventHandler(this.ClickEnemyShips);
                    Enemy[i, j].TabStop  = false;
                    x += 50;
                    this.Controls.Add(Enemy[i, j]);
                }

                x  = 640;
                y += 50;
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool Trouble = false;

            Vertical = false;

            if (Stage < ShipCountANDLength.Length)
            {
                if (!MyField.IsItSuitable(MyShip))
                {
                    ButtonSupport.ResetShip(MyShip, this);
                    Trouble = true;
                    Refresh();
                    MessageBox.Show("Bir sorun var");
                }
            }

            if (!Trouble)
            {
                Stage++;

                if (Stage < ShipCountANDLength.Length)
                {
                    MyField.PositionTOsea(MyShip);
                    MyShip = ButtonSupport.CreateShip(ShipCountANDLength[Stage], this);
                }
                else if (Stage == ShipCountANDLength.Length)
                {
                    button1.Text    = "OYUNU BAŞLAT";
                    button3.Enabled = false;
                }
                else if (Stage == (ShipCountANDLength.Length + 1))
                {
                    button1.Enabled = false;
                    EnemyField.PickShips();
                    ButtonSupport.RemoveAllShips(this);
                    ButtonSupport.CreateANewButton(10, 10, 10, 20, this);
                    Refresh();
                }
            }
            Computer = new AI(MyField);
        }