Esempio n. 1
0
    void Start()
    {
        firsttime = true;
        Invoke("FirstCheck", 0.4f);

        gs = GameObject.FindGameObjectWithTag("game_status").GetComponent <game_status>();
    }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     game_manager           = GameObject.FindObjectOfType <game_status>();
     cube_renderer          = this.GetComponentsInChildren <Renderer>()[1];
     cube_transform         = this.GetComponentsInChildren <Transform>()[0];
     pos                    = cube_transform.position;
     cube_color_transparent = cube_renderer.material.color;
     cube_color_visible     = cube_renderer.material.color;
 }
Esempio n. 3
0
 // рисует поле
 private void Show_Pole0(Graphics g, game_status status)
 {
     for (int row = 1; row <= amount_vert; row++)
     {
         for (int col = 1; col <= amount_horiz; col++)
         {
             this.Draw_a_cell(g, row, col, status);
         }
     }
 }
Esempio n. 4
0
        // рисует клетку (включая флаг в клетке и открытие всех свободных клеток по близости)
        private void Draw_a_cell(Graphics g, int row, int col, game_status status)
        {
            int x, y;// декартовы координаты левого верхнего угла клетки

            x = (col - 1) * cell_width + 1;
            y = (row - 1) * cell_length + 1;

            // если не открытые клетки - будут серые
            if (Pole[row, col] < 100)
            {
                g.FillRectangle(SystemBrushes.ControlDark, x - 1, y - 1, cell_width, cell_length);
            }

            // открытые или помеченные клетки
            if (Pole[row, col] >= 100)
            {
                // открываем клетку, открытые - светло-зелёные
                if (Pole[row, col] != 109)
                {
                    g.FillRectangle(Brushes.LawnGreen, x - 1, y - 1, cell_width, cell_length);
                }
                else
                {
                    // если в клетке была бомба, то на этой мине взрыв -> конец игры
                    g.FillRectangle(Brushes.Red, x - 1, y - 1, cell_width, cell_length);
                    status      = game_status.Endgame;
                    game_result = "ПОТРАЧЕНО";
                    label2.Text = game_result;
                    label1.Text = "Игра завершена";
                }
                // если в соседних клетках есть мины, указываем их количество
                if ((Pole[row, col] >= 101) && (Pole[row, col] <= 108))
                {
                    g.DrawString((Pole[row, col] - 100).ToString(), new Font("Tahoma", 15, System.Drawing.FontStyle.Regular), Brushes.DarkBlue, x + 5, y + 5);
                }
            }

            // в клетке поставлен флаг
            if (Pole[row, col] >= 200)
            {
                this.Draw_flag(g, x, y);
            }

            // рисуем границу клетки
            g.DrawRectangle(Pens.Black, x - 1, y - 1, cell_width, cell_length);

            // если игра завершена (status = 2), показываем мины
            if ((status == game_status.Endgame) && ((Pole[row, col] % 10) == 9))
            {
                this.Draw_bomb(g, x, y);
                //this.Draw_flag(g, x, y);
            }
        }
Esempio n. 5
0
 void Start()
 {
     next_zAngle    = zAngle + 120f;
     temp_mousePosX = Camera.main.ScreenToViewportPoint(Input.mousePosition).x;
     gs             = GameObject.FindGameObjectWithTag("game_status").GetComponent <game_status>();
     if (gs.is_selector_reverted)
     {
         renderer.sprite = revert;
     }
     else
     {
         renderer.sprite = normal;
     }
     angle = 0;
     Debug.Log("Sebep");
 }
Esempio n. 6
0
    //rotations ^ - 0, > - 1, v - 2, < - 3,

    // Use this for initialization
    void Start()
    {
        game_manager           = GameObject.FindObjectOfType <game_status>();
        cube_renderer          = this.GetComponentInChildren <Renderer> ();
        color_of_cube          = cube_renderer.material.color;
        color_of_transparent   = color_of_cube;
        color_of_transparent.a = 0;
        cube_transform         = this.GetComponentInChildren <Transform> ();
        current_pos            = cube_transform.position;
        if (this.tag == "player1")
        {
            player_nr   = 0;
            current_rot = 1;
        }
        if (this.tag == "player2")
        {
            player_nr   = 1;
            current_rot = 3;
        }
    }
Esempio n. 7
0
        private void Show_Pole(Graphics g, game_status status)
        {
            //System.Threading.Thread.Sleep(500);/*приостановить работу на секунду*/
            //await Task.Delay(5000);

            //задержка
            int i = 0;

            while (i < 150000000)
            {
                i++;
            }

            for (int row = 1; row <= amount_vert; row++)
            {
                for (int col = 1; col <= amount_horiz; col++)
                {
                    this.Draw_a_cell(g, row, col, status);
                }
            }
        }
Esempio n. 8
0
        // новая игра
        private void New_game()
        {
            int row, col, // индексы клетки
                n = 0,    // количество поставленных мин
                k;        // кол-во мин в соседних клетках

            // очистить поле
            for (row = 1; row <= amount_vert; row++)
            {
                for (col = 1; col <= amount_horiz; col++)
                {
                    Pole[row, col] = 0; //в каждой клетке мины нет
                }
            }
            // инициализация генератора случайных чисел через текущее время
            Random rnd = new Random();

            // расставим мины случайным образом
            do
            {
                row = rnd.Next(amount_vert) + 1;
                col = rnd.Next(amount_horiz) + 1;

                if (Pole[row, col] != 9)//если в этой клекте уже нет мины, то поставить
                {
                    Pole[row, col] = 9;
                    n++;
                }
            }while (n != amount_mines); //выполнять, пока не будет поставлено максимальное количество мин

            // для каждой клетки вычислим кол-во мин в соседних клетках
            for (row = 1; row <= amount_vert; row++)
            {
                for (col = 1; col <= amount_horiz; col++)
                {
                    if (Pole[row, col] != 9)//если в этой клетке нет мины, то в ней всё считается
                    {
                        k = 0;

                        for (int i = row - 1; i <= row + 1; i++)
                        {
                            for (int j = col - 1; j <= col + 1; j++)
                            {
                                if (Pole[i, j] == 9)
                                {
                                    k++;
                                }
                            }
                        }

                        /*if (Pole[row - 1, col - 1] == 9) k++;
                        *  if (Pole[row - 1, col] == 9) k++;
                        *  if (Pole[row - 1, col + 1] == 9) k++;
                        *  if (Pole[row, col - 1] == 9) k++;
                        *  if (Pole[row, col + 1] == 9) k++;
                        *  if (Pole[row + 1, col - 1] == 9) k++;
                        *  if (Pole[row + 1, col] == 9) k++;
                        *  if (Pole[row + 1, col + 1] == 9) k++;*/

                        Pole[row, col] = k;
                    }
                }
            }

            status      = game_status.Beginng; // начало игры
            label1.Text = "Щёлкайте по полю"; label2.Text = "";

            number_mines = 0;      // нет обнаруженных мин
            number_flags = 0;      // нет поставленных флагов
        }
Esempio n. 9
0
        // щелчок кнопкой в клетке игрового поля
        private void panel1_MouseClick(object sender, MouseEventArgs e)
        {
            // игра завершена -> вписать в метку об этом + сделать так, чтобы последующие щелчки ничего не делали
            if (status == game_status.Endgame)
            {
                label1.Text = "Игра завершена";
            }
            else
            {
                // первый щелчок -> начать игру
                if (status == game_status.Beginng)
                {
                    //New_game(); // новая игра
                    status      = game_status.Process;
                    label1.Text = "Игра началась";
                    label2.Text = "";
                }
                // преобразуем координаты мыши в индексы клетки поля, в которой был сделан щелчок; (e.X, e.Y) - координаты точки формы, в которой была нажата кнопка мыши;
                int row = e.Y / cell_length + 1, col = e.X / cell_width + 1;

                // координаты области вывода
                int x = (col - 1) * cell_width + 1, y = (row - 1) * cell_length + 1;

                // щелчок левой кнопки мыши
                if (e.Button == MouseButtons.Left)
                {
                    // открыта клетка, в которой есть мина
                    if (Pole[row, col] == 9)
                    {
                        Pole[row, col] += 100;

                        // игра закончена
                        status = game_status.Endgame;

                        // перерисовать форму
                        this.panel1.Invalidate();
                    }
                    else
                    if (Pole[row, col] < 9)
                    {
                        this.Open_cells(row, col);                        //если в клетке нет мины, заделать процесс открытия
                    }
                }

                // щелчок правой кнопки мыши
                if (e.Button == MouseButtons.Right)
                {
                    // в клетке не было флага/клетка не открыта, ставим его
                    if (Pole[row, col] <= 9)
                    {
                        number_flags += 1;

                        if (Pole[row, col] == 9)
                        {
                            number_mines += 1;
                        }

                        Pole[row, col] += 200;

                        if ((number_mines == amount_mines) && (number_flags == amount_mines))//если открыты все мины и поставлено столько же флагов, завершить игру
                        {
                            this.Draw_a_cell(g, row, col, status);
                            // игра закончена
                            status      = game_status.Endgame;
                            label1.Text = "Игра завершена";
                            game_result = "МОЁ УВАЖЕНИЕ";
                            label2.Text = game_result;

                            // перерисовываем все игровое поле ()
                            //this.Invalidate();
                            this.panel1.Invalidate();
                        }
                        else
                        {
                            // перерисовываем только клетку
                            this.Draw_a_cell(g, row, col, status);
                        }
                    }
                    else
                    // в клетке был поставлен флаг, повторный щелчок правой кнопки мыши убирает его и закрывает клетку
                    if (Pole[row, col] >= 200)
                    {
                        number_flags   -= 1;
                        Pole[row, col] -= 200;

                        // перерисовываем клетку
                        this.Draw_a_cell(g, row, col, status);
                    }
                }
            }
        }
Esempio n. 10
0
 void Start()
 {
     SetupHex();
     gs = GameObject.FindGameObjectWithTag("game_status").GetComponent <game_status>();
 }
Esempio n. 11
0
        private void UpdateMain()
        {

            MouseState mouse;

            mouse = Mouse.GetState();

            int x = 0;
            int y = 0;

            x = mouse.X; y = mouse.Y;

            //System.IO.File.WriteAllText(@"C:\Users\walkeb7\My Documents\Nonsense\Airline Game\log.txt", "mouse " + x + "," + y);
            //go button check
            if (mouse.LeftButton == ButtonState.Pressed)
            {
                    game_status = game_status.InGame;
            }

        }
Esempio n. 12
0
 void Start()
 {
     gs = GameObject.FindGameObjectWithTag("game_status").GetComponent <game_status>();
     InstantiatePiece();
     PickID();
 }