Ejemplo n.º 1
0
        private void DrawDestroyingBalloons()
        {
            DrawingLib drawing     = new DrawingLib();
            int        timer_ticks = 0;

            tDestroy          = new Timer();
            tDestroy.Interval = 30;
            tDestroy.Tick    += new EventHandler((s, e) =>
            {
                //объявить битмап
                Bitmap bmp = new Bitmap(pictureBox1.Image);
                Graphics g = Graphics.FromImage(bmp);
                for (int i = 0; i < match_indexes.Count(); i++)
                {
                    g.FillPie(new SolidBrush(Color.FromArgb(128, 128, 255)), new Rectangle(new Point(match_indexes[i][0] * 42 + 1, match_indexes[i][1] * 42 + 61), new Size(41, 41)), 18 * timer_ticks, 18 * timer_ticks + 1);
                }
                //если бомбы есть - нарисовать
                if (explosion_indexes.Count >= 1)
                {
                    for (int i = 0; i < explosion_indexes.Count; i++)
                    {
                        g.DrawImage(drawing.draw_explosion(timer_ticks, Application.StartupPath.ToString() + "\\Resouses\\Explosion\\explosion" + timer_ticks + ".png"), new Point((explosion_indexes[i][0] - 1) * 42, (explosion_indexes[i][1] - 1) * 42 + 61));
                    }
                }
                pictureBox1.Image = bmp;//вывод на picturebox
                if (timer_ticks == 19)
                {
                    //нарисовать сетку
                    g.DrawImage(drawing.draw_grid(pictureBox1.Width, pictureBox1.Height), new Point(0, 60));
                    //очистить gameboard
                    for (int i = 0; i < match_indexes.Count(); i++)
                    {
                        gameboard[match_indexes[i][0], match_indexes[i][1]] = "";
                    }
                    explosion_indexes.Clear();
                    Timer t = s as Timer;
                    t.Dispose();
                    GameProcess game    = new GameProcess();
                    ballon_falling_span = game.define_falling_balloons(ref gameboard, difficulty);
                    DrawFallingBalloons();
                    tFall.Start();
                }
                else
                {
                    timer_ticks++;
                }
            }
                                                 );
            return;
        }
Ejemplo n.º 2
0
        public void GameBoardInitialization()
        {
            Bitmap   bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height);
            Graphics g   = Graphics.FromImage(bmp);

            g.Clear(Color.FromArgb(128, 128, 255));
            using (var image = new Bitmap(Application.StartupPath.ToString() + "\\Resouses\\Nametag.png"))
            {
                g.DrawImage(image, new Point(0, 0));
            }
            DrawingLib drawing = new DrawingLib();

            g.DrawImage(drawing.draw_grid(pictureBox1.Width, pictureBox1.Height), new Point(0, 60));
            pictureBox1.Image = bmp;
        }
Ejemplo n.º 3
0
        private void DrawSwapingBalloons()
        {
            //объявить битмап
            Bitmap   bmp = new Bitmap(pictureBox1.Image);
            Graphics g   = Graphics.FromImage(bmp);

            g.FillRectangle(new SolidBrush(Color.FromArgb(128, 128, 255)), new Rectangle(new Point(indexes[0][0] * 42 + 1, indexes[0][1] * 42 + 61), new Size(41, 41)));
            g.FillRectangle(new SolidBrush(Color.FromArgb(128, 128, 255)), new Rectangle(new Point(indexes[1][0] * 42 + 1, indexes[1][1] * 42 + 61), new Size(41, 41)));
            pictureBox1.Image = bmp;               //вывод на picturebox
            Bitmap generatedbmp = new Bitmap(bmp); //Сохнаняет текущую картинку
            int    timer_ticks  = 1;
            Timer  tSwap        = new Timer();

            tSwap.Interval = 15;
            tSwap.Tick    += new EventHandler((s, e) =>
            {
                bmp = new Bitmap(generatedbmp);
                g   = Graphics.FromImage(bmp);
                using (var image = new Bitmap(Application.StartupPath.ToString() + "\\Resouses\\" + gameboard[indexes[0][0], indexes[0][1]] + ".png"))
                {
                    g.DrawImage(image, new Point(indexes[0][0] * 42 + 6 * timer_ticks * (indexes[1][0] - indexes[0][0]) + 1, indexes[0][1] * 42 + 61 + 6 * timer_ticks * (indexes[1][1] - indexes[0][1])));
                }
                using (var image = new Bitmap(Application.StartupPath.ToString() + "\\Resouses\\" + gameboard[indexes[1][0], indexes[1][1]] + ".png"))
                {
                    g.DrawImage(image, new Point(indexes[1][0] * 42 + 6 * timer_ticks * (indexes[0][0] - indexes[1][0]) + 1, indexes[1][1] * 42 + 61 + 6 * timer_ticks * (indexes[0][1] - indexes[1][1])));
                }
                DrawingLib drawing = new DrawingLib();
                g.DrawImage(drawing.draw_grid(pictureBox1.Width, pictureBox1.Height), new Point(0, 60));
                pictureBox1.Image = bmp;//вывод на picturebox
                if (timer_ticks == 7)
                {
                    timer_ticks = 0;
                    if (mistake)
                    {
                        was_mistake = true;
                        mistake     = false;
                        DrawSwapingBalloons();
                        string bottle = gameboard[indexes[0][0], indexes[0][1]];
                        gameboard[indexes[0][0], indexes[0][1]] = gameboard[indexes[1][0], indexes[1][1]];
                        gameboard[indexes[1][0], indexes[1][1]] = bottle;
                    }
                    else
                    {
                        string bottle = gameboard[indexes[0][0], indexes[0][1]];
                        gameboard[indexes[0][0], indexes[0][1]] = gameboard[indexes[1][0], indexes[1][1]];
                        gameboard[indexes[1][0], indexes[1][1]] = bottle;
                        if (!was_mistake)
                        {
                            tDestroy.Start();
                        }
                        else
                        {
                            was_mistake = false;
                        }
                        indexes.Clear();
                    }
                    Timer t = s as Timer;
                    t.Dispose();
                }
                timer_ticks++;
            }
                                              );
            tSwap.Start();
        }