Esempio n. 1
0
        public Grid(Graphics g, NewGame newGame, Font font, Font titleFont)
        {
            this.isOver = false;
            this.matrix = new Shape[5, 5];
            Random r = new Random();
            this.newGame = newGame;
            this.font = font;
            this.titleFont = titleFont;

            for (int i = 0; i < 5; ++i)
            {
                for (int j = 0; j < 5; j++)
                {

                    matrix[i, j] = new Shape(0);
                }
            }

            this.matrix[r.Next(5), r.Next(5)] = new Shape(r.Next(4) + 1);
            graphics = g;
            paintMatrix();
        }
Esempio n. 2
0
        public void goDown()
        {
            for (int z = 0; z < 5; ++z)
            {
                for (int i = 0; i < 5; ++i)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (j > 0)
                        {
                            if (matrix[i, j].Orientation == 0 && matrix[i, j - 1].Orientation != 0)
                            {

                                matrix[i, j] = new Shape(matrix[i, j - 1].Orientation);
                                matrix[i, j - 1] = new Shape(0);
                            }

                            if (matrix[i, j].Orientation == 3 && matrix[i, j - 1].Orientation == 1)
                            {
                                newGame.points += 2;
                                newGame.updatePoints();
                                matrix[i, j] = new Shape(5);
                                matrix[i, j - 1] = new Shape(0);

                            }

                            if (matrix[i, j].Orientation == 4 && matrix[i, j - 1].Orientation == 2)
                            {
                                newGame.points += 2;
                                newGame.updatePoints();
                                matrix[i, j] = new Shape(5);
                                matrix[i, j - 1] = new Shape(0);
                            }

                            if (matrix[i, j].Orientation == 5 && matrix[i, j - 1].Orientation == 5)
                            {
                                newGame.points += 4;

                                matrix[i, j] = new Shape(6);
                                matrix[i, j - 1] = new Shape(0);
                            }

                        }
                    }
                }

                paintMatrix();

            }
        }
Esempio n. 3
0
        public void newTriangle()
        {
            int count = 0;
            int crveni = 0;
            for (int i = 0; i < 5; ++i)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (matrix[i, j].Orientation == 0)
                        count++;

                    if (matrix[i, j].Orientation == 6)
                        crveni++;

                }
            }

            if (checkSQ())
            {

                this.newGame.Hide();

                HighScore highScore = new HighScore(font, titleFont, newGame.points);
                highScore.ShowDialog();

                newGame.Close();
            }

            if (count == 1)
            {

                newGame.Hide();
                HighScore highScore = new HighScore(font, titleFont, newGame.points);
                highScore.ShowDialog();
                newGame.Close();
                //MessageBox.Show("GAME OVER !");
            }

            Random r = new Random();
            int next = r.Next(count);
            int x = r.Next(4);
            for (int i = 0; i < 5; ++i)
            {
                for (int j = 0; j < 5; j++)
                {

                    if (matrix[i, j].Orientation == 0)
                    {
                        next--;
                        if (next == 0)
                        {
                            matrix[i, j] = new Shape(x + 1);

                        }
                    }
                }
            }
        }