Example #1
0
        public void Poprawa(Blok B)
        {
            int n;

            for (int i = 0; i < k; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    n = j * 11 + i;
                    if (B.Tablica[n] == null)
                    {
                        Tablica[j][i] = 0;
                    }
                }
            }
        }
Example #2
0
 public BombMan()
 {
     R = new Plan()
     {
         N = 100,                  ///bloczki do niszczenia(max)
         P = 2                     ///potwory(max)
     };
     R.Plano();                    //stworzenie mapy
     B = new Blok();
     B.Bloczki(R);                 //zamiania planu na elementy graficzne
     for (int i = 0; i < B.d; i++) //wyswietlanie
     {
         if (B.Tablica[i] != null)
         {
             Controls.Add(B.Tablica[i]);
         }
     }
     InitializeComponent();
     player.Top  = 0;
     player.Left = 0;
 }
Example #3
0
        public Blok Bum(int Zasięg, Plan P, PictureBox bomba) //funkcja tworząca tablice zawierającą bombę płomienie i bloczki do zniszczenia
        {
            if (bomba == null)
            {
                return(null);
            }
            int x, y, n, wielki = 0, bu_x1 = -1, bu_y1 = -1, bu_x2 = -1, bu_y2 = -1, max_x1 = 0, max_x2 = 0, max_y1 = 0, max_y2 = 0;

            x = (bomba.Left + bomba.Right) / 2; //współrzędan x (prawo-lewo) UWAGA
            y = (bomba.Top + bomba.Bottom) / 2; //współrzędna y (góra-dół)
            x = x - (x % 30);
            y = y - (y % 30);
            x = x / 30;
            y = y / 30;
            n = y * 11 + x;
            for (int j = y - 1; j > y - Zasięg - 1 && j >= 0; j--)
            {
                if (P.Tablica[x][j] == 2)
                {
                    break;
                }

                wielki++; //wielkość tablicy
                max_y1++; //ile w góre
                if (P.Tablica[x][j] == 1)
                {
                    bu_y1 = max_y1;
                }
                if (P.Tablica[x][j] == 1)
                {
                    break;
                }
            }
            for (int j = y + 1; j < y + Zasięg + 1 && j < 11; j++)
            {
                if (P.Tablica[x][j] == 2)
                {
                    break;
                }

                wielki++;
                max_y2++; //ile w dół
                if (P.Tablica[x][j] == 1)
                {
                    bu_y2 = max_y2;
                }
                if (P.Tablica[x][j] == 1)
                {
                    break;
                }
            }
            for (int i = x + 1; i < x + Zasięg + 1 && i < 13; i++)
            {
                if (P.Tablica[i][y] == 2)
                {
                    break;
                }

                wielki++;
                max_x2++; //ile w prawo
                if (P.Tablica[i][y] == 1)
                {
                    bu_x2 = max_x2;
                }
                if (P.Tablica[i][y] == 1)
                {
                    break;
                }
            }
            for (int i = x - 1; i > x - Zasięg - 1 && i >= 0; i--)
            {
                if (P.Tablica[i][y] == 2)
                {
                    break;
                }

                wielki++;
                max_x1++; //ile w lewo
                if (P.Tablica[i][y] == 1)
                {
                    bu_x1 = max_x1;
                }
                if (P.Tablica[i][y] == 1)
                {
                    break;
                }
            }
            Blok dele = new Blok()
            {
                d = wielki + 1 //jeszcze jeden dla bomby
            };

            dele.Tablica = new PictureBox[dele.d];
            for (int i = 0; i < wielki + 2; i++)
            {
                if (i < max_y1) //płomień nad bombą
                {
                    dele.Tablica[i] = new PictureBox()
                    {
                        Image     = Properties.Resources.plonienpion,
                        Location  = new System.Drawing.Point(x * 30, (y - max_y1 + i) * 30),
                        Name      = "plomien" + i.ToString(),
                        Size      = new System.Drawing.Size(32, 32),
                        TabIndex  = i,
                        TabStop   = false,
                        Visible   = true,
                        SizeMode  = PictureBoxSizeMode.Zoom,
                        BackColor = System.Drawing.Color.Transparent
                    };
                    dele.Tablica[i].BringToFront();
                }
                if (i >= max_y1 && i < max_y1 + max_x1) //płomień po lewej
                {
                    dele.Tablica[i] = new PictureBox()
                    {
                        Image     = Properties.Resources.plonienpoziom,
                        Location  = new System.Drawing.Point((x - max_x1 + i - max_y1) * 30, y * 30),
                        Name      = "plomien" + i.ToString(),
                        Size      = new System.Drawing.Size(32, 32),
                        TabIndex  = i,
                        TabStop   = false,
                        Visible   = true,
                        SizeMode  = PictureBoxSizeMode.Zoom,
                        BackColor = System.Drawing.Color.Transparent
                    };
                    dele.Tablica[i].BringToFront();
                }
                if (i == max_y1 + max_x1) //bomba
                {
                    dele.Tablica[i] = bomba;
                }
                if (i <= max_x2 + max_x1 + max_y1 && i > max_y1 + max_x1) //płomień po prawej
                {
                    dele.Tablica[i] = new PictureBox()
                    {
                        Image     = Properties.Resources.plonienpoziom,
                        Location  = new System.Drawing.Point((x - max_y1 - max_x1 + i) * 30, y * 30),
                        Name      = "plomien" + i.ToString(),
                        Size      = new System.Drawing.Size(32, 32),
                        TabIndex  = i,
                        TabStop   = false,
                        Visible   = true,
                        SizeMode  = PictureBoxSizeMode.Zoom,
                        BackColor = System.Drawing.Color.Transparent
                    };
                    dele.Tablica[i].BringToFront();
                }
                if (i <= wielki && i > max_x2 + max_x1 + max_y1) //płomień pod bombą
                {
                    dele.Tablica[i] = new PictureBox()
                    {
                        Image     = Properties.Resources.plonienpion,
                        Location  = new System.Drawing.Point(x * 30, (y + i - (max_x2 + max_x1 + max_y1)) * 30),
                        Name      = "plomien" + i.ToString(),
                        Size      = new System.Drawing.Size(32, 32),
                        TabIndex  = i,
                        TabStop   = false,
                        Visible   = true,
                        SizeMode  = PictureBoxSizeMode.Zoom,
                        BackColor = System.Drawing.Color.Transparent
                    };
                    dele.Tablica[i].BringToFront();
                }
            }
            if (bu_y1 != -1) //kiedy bloczek do zniszczenia jest nad bombą
            {
                int l = x * 11 + y - bu_y1;
                if (dele.Tablica[0] != null)
                {
                    dele.Tablica[0].Dispose();                          ///bum bloczek nad bombą
                }
                dele.Tablica[0]      = Tablica[l];
                dele.Tablica[0].Name = "block" + 0.ToString();
                Tablica[l]           = null;
            }
            if (bu_x1 != -1) //kiedy bloczek do zniszczenia jest po lewej
            {
                int l = (x - bu_x1) * 11 + y;
                if (dele.Tablica[max_y1] != null)
                {
                    dele.Tablica[max_y1].Dispose();                               ///bum bloczek po lewej
                }
                dele.Tablica[max_y1]      = Tablica[l];
                dele.Tablica[max_y1].Name = "block" + max_y1.ToString();
                Tablica[l] = null;
            }
            if (bu_x2 != -1) //kiedy bloczek do zniszczenia jest po prawej
            {
                int l = (x + bu_x2) * 11 + y;
                if (dele.Tablica[max_y1 + max_x1 + max_x2] != null)
                {
                    dele.Tablica[max_y1 + max_x1 + max_x2].Dispose();                                                 ///bum bloczek po prawej
                }
                dele.Tablica[max_y1 + max_x1 + max_x2]      = Tablica[l];
                dele.Tablica[max_y1 + max_x1 + max_x2].Name = "block" + (max_y1 + max_x1 + max_x2).ToString();
                Tablica[l] = null;
            }
            if (bu_y2 != -1) //kiedy bloczek do zniszczenia jest pod bombą
            {
                int l = x * 11 + y + bu_y2;
                if (dele.Tablica[wielki] != null)
                {
                    dele.Tablica[wielki].Dispose();                               ///bum bloczek pod bombą
                }
                dele.Tablica[wielki]      = Tablica[l];
                dele.Tablica[wielki].Name = "block" + wielki.ToString();
                Tablica[l] = null;
            }
            return(dele);
        }
Example #4
0
        public int Bomba(PictureBox player, int ilosc_bomb, Blok A) //postawienie bomby
        {
            int x, y, n;

            x = (player.Top + player.Bottom) / 2; //współrzędna x (góra-dół)
            y = (player.Left + player.Right) / 2; //współrzędan y (prawo-lewo)
            x = x - (x % 30);
            y = y - (y % 30);
            n = (y * 11 / 30) + x / 30;
            if (ilosc_bomb == 0)
            {
                return(0);
            }
            if (A.Tablica[n] != null)
            {
                return(ilosc_bomb);
            }
            if (Tablica != null) //jeżeli kiedyś została postawiona bomba
            {
                for (int i = 0; i < d; i++)
                {
                    if (Tablica[i] != null && Tablica[i].Left == y && Tablica[i].Top == x)
                    {
                        return(ilosc_bomb);
                    }
                }
            }
            n = ilosc_bomb - 1;
            if (Tablica == null) //jeżeli nie została jeszcze postawiona bomba to nie ma tablicy
            {
                d       = ilosc_bomb;
                Tablica = new PictureBox[d];
            }
            if (d < ilosc_bomb) //jeżeli została zwiększona ilość bomb podczas działania programu przez bonus to zostaje zwiększona ilość elementów tablicy,w której są bomby
            {
                PictureBox[] B;
                B = new PictureBox[ilosc_bomb];
                for (int i = 0; i < d; i++)
                {
                    if (Tablica[i] != null)
                    {
                        B[i] = Tablica[i];
                    }
                }
                Tablica = B;
            }
            Tablica[n] = new PictureBox() //stworzenie bomby
            {
                Image     = Properties.Resources.bomba,
                Location  = new System.Drawing.Point(y, x),
                Name      = "bomb" + n.ToString(),
                Size      = new System.Drawing.Size(30, 30),
                TabIndex  = n,
                TabStop   = false,
                Visible   = true,
                SizeMode  = PictureBoxSizeMode.Zoom,
                BackColor = System.Drawing.Color.Transparent
            };
            Tablica[n].SendToBack(); //bomba pod graczem
            return(n);
        }