Beispiel #1
0
        private void player_mouseclick(object sender, MouseEventArgs e)
        {
            if (flag == 1)
            {
                string[]   separators = { ",", ".", "!", "?", ";", ":", " " };
                PictureBox pb         = (PictureBox)sender;
                int        x          = int.Parse(((string)pb.Tag).Split(separators, StringSplitOptions.RemoveEmptyEntries)[0]);
                int        y          = int.Parse(((string)pb.Tag).Split(separators, StringSplitOptions.RemoveEmptyEntries)[1]);
                Boolean    b          = Horizontal.SelectedIndex == 1 ? true : false;
                Horizontal.Refresh();
                Point[] a;

                Ships ship = null;

                switch (SelectShip.Text)
                {
                case "ship2":

                    a    = ship2.get_point(x, y, b);
                    ship = new ship2(b, a);
                    Console.WriteLine(ship.Name);
                    break;

                case "ship3":
                    a    = ship3.get_point(x, y, b);
                    ship = new ship3(b, a);
                    break;

                case "ship4":
                    a    = ship4.get_point(x, y, b);
                    ship = new ship4(b, a);

                    break;

                case "ship6":
                    a    = ship6.get_point(x, y, b);
                    ship = new ship6(b, a);
                    break;
                }

                if (player.set_ship(ship))
                {
                    player.Ships.Add(ship);

                    SelectShip.Items.RemoveAt(SelectShip.SelectedIndex);
                    SelectShip.SelectedIndex = 0;
                    SelectShip.Refresh();
                    if (SelectShip.Items.Count == 1)
                    {
                        StartButton.Visible = true;
                        SelectShip.Visible  = false;
                        Horizontal.Visible  = false;
                    }
                }


                pic_color_ship(player);
            }
        }
Beispiel #2
0
        public void get_rendom_point()
        {
            Random a    = new Random();
            Ships  ship = null;

            do
            {
                Point   rendom_point   = new_point[a.Next(0, new_point.Count)];
                Boolean rendom_boolean = a.Next(0, 100) > 50 ? true : false;
                Point[] points         = ship2.get_point(rendom_point.X, rendom_point.Y, rendom_boolean);
                ship = new ship2(rendom_boolean, points);
            } while (!this.set_ship(ship));
            this.ships.Add(ship);
            ship = null;
            do
            {
                Point   rendom_point   = new_point[a.Next(0, new_point.Count)];
                Boolean rendom_boolean = a.Next(0, 100) > 50 ? true : false;
                Point[] points         = ship3.get_point(rendom_point.X, rendom_point.Y, rendom_boolean);
                ship = new ship3(rendom_boolean, points);
            } while (!this.set_ship(ship));
            this.ships.Add(ship);
            ship = null;
            do
            {
                Point   rendom_point   = new_point[a.Next(0, new_point.Count)];
                Boolean rendom_boolean = a.Next(0, 100) > 50 ? true : false;
                Point[] points         = ship6.get_point(rendom_point.X, rendom_point.Y, rendom_boolean);
                ship = new ship6(rendom_boolean, points);
            } while (!this.set_ship(ship));
            this.ships.Add(ship);
            ship = null;
            do
            {
                Point   rendom_point   = new_point[a.Next(0, new_point.Count)];
                Boolean rendom_boolean = a.Next(0, 100) > 50 ? true : false;
                Point[] points         = ship4.get_point(rendom_point.X, rendom_point.Y, rendom_boolean);
                ship = new ship4(rendom_boolean, points);
            } while (!this.set_ship(ship));
            this.ships.Add(ship);
        }