Beispiel #1
0
        public void TilesGen()
        {
            int[] nums = new int[shmebulok * shmebulok];

            for (int i = 0; i < shmebulok * shmebulok; i++)
            {
                nums[i] = i / 2 + 1;
            }

            for (int i = 0; i < 1000; i++)
            {
                int p1 = rnd.Next(shmebulok * shmebulok);
                int p2 = rnd.Next(shmebulok * shmebulok);

                int tmp = nums[p1];

                nums[p1] = nums[p2];
                nums[p2] = tmp;
            }

            buttons = new PictureBox[shmebulok, shmebulok];

            Size = new Size(shmebulok * 100 + 15, shmebulok * 100 + 50);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox          = false;
            this.StartPosition   = FormStartPosition.CenterScreen;

            for (int i = 0; i < shmebulok; i++)
            {
                for (int j = 0; j < shmebulok; j++)
                {
                    PictureBox nb = new PictureBox();
                    nb.Tag = nums[i * shmebulok + j];

                    //nb.Text = "*";
                    //nb.Font = new Font("Microsoft Sans Serif", 30F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(204)));

                    nb.Location = new Point(i * 100, j * 100);
                    nb.Size     = new Size(100, 100);

                    nb.BackgroundImage       = Properties.Resources.back;
                    nb.BackgroundImageLayout = ImageLayout.Zoom;

                    nb.Click += button1_Click;

                    nb.Parent = this;

                    buttons[i, j] = nb;

                    nb.BringToFront();
                }
            }

            pictureBox1.Size     = new Size(shmebulok * 100, shmebulok * 100);
            pictureBox1.Location = new Point(0, 0);

            progressBar1.Maximum  = shmebulok * shmebulok * 10;
            progressBar1.Width    = Size.Width;
            progressBar1.Location = new Point(0, Size.Height - 50);
            progressBar1.Value    = 0;
        }
Beispiel #2
0
        private void Pic_DoubleClick(object sender, EventArgs e, Itens item)
        {
            PictureBox pic = (PictureBox)sender;

            Substituto(pic.Top, pic.Left, pic.Height, pic.Width, pic.BackColor);

            if (item.Tipo1 == (byte)tipo.BracoEsquerdo)
            {
                personagem.Equipar(item);
                pic.SizeMode    = PictureBoxSizeMode.StretchImage;
                pic.BorderStyle = BorderStyle.FixedSingle;
                pic.BackColor   = Color.Transparent;
                pic.Height      = 50;
                pic.Width       = 60;
                pic.Top         = 146;
                pic.Left        = 184;
                Controls.Add(pic);
                pic.BringToFront();
            }
            else if (item.Tipo1 == (byte)tipo.BracoDireito)
            {
                pic.SizeMode    = PictureBoxSizeMode.StretchImage;
                pic.BorderStyle = BorderStyle.FixedSingle;
                pic.BackColor   = Color.Transparent;
                personagem.Equipar(item);
                pic.Height = 50;
                pic.Width  = 60;
                pic.Top    = 146;
                pic.Left   = 258;
                Controls.Add(pic);
                pic.BringToFront();
            }
            else if (item.Tipo1 == (byte)tipo.Peito)
            {
                pic.SizeMode    = PictureBoxSizeMode.StretchImage;
                pic.BorderStyle = BorderStyle.FixedSingle;
                pic.BackColor   = Color.Transparent;
                personagem.Equipar(item);
                pic.Height = 50;
                pic.Width  = 60;
                pic.Top    = 84;
                pic.Left   = 219;
                Controls.Add(pic);
                pic.BringToFront();
            }
            else if (item.Tipo1 == (byte)tipo.Capacete)
            {
                pic.SizeMode    = PictureBoxSizeMode.StretchImage;
                pic.BorderStyle = BorderStyle.FixedSingle;
                pic.BackColor   = Color.Transparent;
                personagem.Equipar(item);
                pic.Height = 50;
                pic.Width  = 60;
                pic.Top    = 26;
                pic.Left   = 219;
                Controls.Add(pic);
                pic.BringToFront();
            }
            else if (item.Tipo1 == (byte)tipo.Bota)
            {
                pic.SizeMode    = PictureBoxSizeMode.StretchImage;
                pic.BorderStyle = BorderStyle.FixedSingle;
                pic.BackColor   = Color.Transparent;
                personagem.Equipar(item);
                pic.Height = 50;
                pic.Width  = 60;
                pic.Top    = 204;
                pic.Left   = 223;
                Controls.Add(pic);
                pic.BringToFront();
            }
        }
Beispiel #3
0
        public Inventario(Personagem personagem)
        {
            InitializeComponent();
            this.personagem      = personagem;
            Ataque.Text          = personagem.Atk1.ToString();
            Defesa.Text          = personagem.Def1.ToString();
            VidaeVidaMaxima.Text = personagem.Vida1.ToString() + " / " + personagem.VidaMaxima1.ToString();
            Critical.Text        = personagem.ChanceCritico2.ToString();
            itens = personagem.itens1;
            if (personagem.MaoDireita1)
            {
                addPictureBox((short)bracodireito.Top, (short)bracodireito.Left,
                              (short)bracodireito.Height, (short)bracodireito.Width,
                              personagem.MaoDireitaEquipe1.url);
            }

            if (personagem.MaoEsquerda1)
            {
                addPictureBox((short)bracoesquerdo.Top, (short)bracoesquerdo.Left,
                              (short)bracoesquerdo.Height, (short)bracoesquerdo.Width,
                              personagem.MaoEsquerdaEquipe1.url);
            }

            if (personagem.Capacete1)
            {
                addPictureBox((short)capacete.Top, (short)capacete.Left,
                              (short)capacete.Height, (short)capacete.Width,
                              personagem.CapaceteEquipe1.url);
            }

            if (personagem.Bota1)
            {
                addPictureBox((short)bota.Top, (short)bota.Left,
                              (short)bota.Height, (short)bota.Width,
                              personagem.BotaEquipe1.url);
            }

            if (personagem.Armadura1)
            {
                addPictureBox((short)armor.Top, (short)armor.Left,
                              (short)armor.Height, (short)armor.Width,
                              personagem.ArmaduraEquipe1.url);
            }


            int acrescentatop  = 0;
            int acrescentaleft = 0;
            int i = 0;

            foreach (Itens item in itens)
            {
                Image      image = Image.FromFile(item.url);
                PictureBox pic   = new PictureBox();
                Label      label = new Label();
                pic.Image       = image;
                pic.Name        = item.nome;
                pic.Height      = 41;
                pic.Width       = 41;
                pic.BackColor   = (Color) new ColorConverter().ConvertFromInvariantString("#858ba1");
                pic.BorderStyle = BorderStyle.FixedSingle;
                pic.Cursor      = Cursors.Hand;
                pic.SizeMode    = PictureBoxSizeMode.StretchImage;
                label.Width     = 41;
                label.Height    = 41;
                label.BackColor = (Color) new ColorConverter().ConvertFromInvariantString("#858ba1");
                label.Text      = item.Gold1.ToString();
                Font font = new Font("Britannic Bold", 11.25F);
                label.Font      = font;
                label.ForeColor = Color.Gold;
                label.Top       = 118 + acrescentatop;
                label.Left      = 529;
                pic.Top         = 48 + acrescentatop;
                pic.Left        = 389 + acrescentaleft;
                acrescentaleft  = acrescentaleft + 41;
                if (acrescentaleft >= 410)
                {
                    acrescentatop  = acrescentatop + 41;
                    acrescentaleft = 41;
                    pic.Left       = 389;
                    pic.Top        = 48 + acrescentatop;
                }
                Controls.Add(label);
                this.Controls.Add(pic);
                pic.DoubleClick += (sender, EventArgs) =>
                {
                    Pic_DoubleClick(sender, EventArgs, item);
                };
                pic.BringToFront();

                i++;
                if (i == 36)
                {
                    break;
                }
            }
            while (i < 36)
            {
                PictureBox picVazia = new PictureBox();


                picVazia.Top         = 48 + acrescentatop;
                picVazia.Left        = 389 + acrescentaleft;
                picVazia.Height      = 41;
                picVazia.Width       = 41;
                picVazia.BackColor   = (Color) new ColorConverter().ConvertFromInvariantString("#858ba1");
                picVazia.SizeMode    = PictureBoxSizeMode.StretchImage;
                picVazia.BorderStyle = BorderStyle.FixedSingle;
                picVazia.Cursor      = Cursors.Hand;
                acrescentaleft       = acrescentaleft + 41;
                if (acrescentaleft >= 410)
                {
                    acrescentatop  = acrescentatop + 41;
                    acrescentaleft = 41;
                    picVazia.Left  = 389;
                    picVazia.Top   = 48 + acrescentatop;
                }
                Controls.Add(picVazia);
                picVazia.BringToFront();
                i++;
            }
        }
 public Form1()
 {
     InitializeComponent();
     // Создаём врагов на карте
     for (int i = 0; i < 10; i++)
     {
         PictureBox a = new PictureBox();
         a.Parent   = screen;
         a.Location = new Point(a.Location.X + 10 + 60 * i, a.Location.Y + 466);
         a.Size     = new Size(35, 35);
         a.Image    = Image.FromFile("enemy_r.png");
         a.Name     = "enemy1";
         a.BringToFront();
         enemy.Add(a);
         die.Add(false);
         i_e.Add(0);
         tmp_e.Add(true);
         count_e++;
     }
     for (int i = 0; i < 10; i++)
     {
         PictureBox a = new PictureBox();
         a.Parent   = screen;
         a.Location = new Point(a.Location.X + 30 + 60 * i, a.Location.Y + 256);
         a.Size     = new Size(35, 35);
         a.Image    = Image.FromFile("enemy_r.png");
         a.Name     = "enemy1";
         a.BringToFront();
         enemy.Add(a);
         die.Add(false);
         i_e.Add(0);
         tmp_e.Add(true);
         count_e++;
     }
     for (int i = 0; i < 4; i++)
     {
         PictureBox a = new PictureBox();
         a.Parent   = screen;
         a.Location = new Point(a.Location.X + 10 + 60 * i, a.Location.Y + 118);
         a.Size     = new Size(35, 35);
         a.Image    = Image.FromFile("enemy_r.png");
         a.Name     = "enemy1";
         a.BringToFront();
         enemy.Add(a);
         die.Add(false);
         i_e.Add(0);
         tmp_e.Add(true);
         count_e++;
     }
     for (int i = 0; i < 4; i++)
     {
         PictureBox a = new PictureBox();
         a.Parent   = screen;
         a.Location = new Point(a.Location.X + 444 + 60 * i, a.Location.Y + 118);
         a.Size     = new Size(35, 35);
         a.Image    = Image.FromFile("enemy_r.png");
         a.Name     = "enemy1";
         a.BringToFront();
         enemy.Add(a);
         die.Add(false);
         i_e.Add(0);
         tmp_e.Add(true);
         count_e++;
     }
     // Перемещаем игрока на первый план
     player.BringToFront();
     player_die = false;
     // Формируем список блоков для обработки
     blocks.Add(block); blocks.Add(b1); blocks.Add(b2); blocks.Add(b3); blocks.Add(b4); blocks.Add(b5); blocks.Add(b6);
     blocks.Add(b7); blocks.Add(b8); blocks.Add(b9); blocks.Add(b10); blocks.Add(b11); blocks.Add(b12); blocks.Add(b13);
     blocks.Add(b14); blocks.Add(b15); blocks.Add(b16); blocks.Add(b17); blocks.Add(b18); blocks.Add(b19); blocks.Add(b20);
     blocks.Add(b21);
     label2.Text = Convert.ToString(count_e);
 }