예제 #1
0
        public void RandomAdd(int t, GameField field)
        {
            Random random = new Random();
            int    x      = random.Next(field.X);
            int    y      = random.Next(field.Y);

            Table[x, y] = new GameElement(t);
            Table[x, y].SetCoordinates(x, y);
        }
예제 #2
0
 public void ClearField()
 {
     time = 0;
     for (int i = 0; i < X; i++)
     {
         for (int x = 0; x < Y; x++)
         {
             Table[i, x] = new GameElement(7);
             Table[i, x].SetCoordinates(i, x);
         }
     }
 }
예제 #3
0
        public GameElement[,] ReturnPattern()
        {
            GameElement[,] array = new GameElement[3, 3];
            switch (p)
            {
            //case 0://2x2
            //    array = new GameElement[2, 2];
            //    array[0, 0] = new GameElement(1);
            //    array[1, 1] = new GameElement(1);
            //    array[1, 0] = new GameElement(5);
            //    array[0, 1] = new GameElement(5);
            //    break;
            case 1:    //3x3
                array       = new GameElement[3, 3];
                array[0, 0] = new GameElement(7);
                array[0, 1] = new GameElement(1);
                array[0, 2] = new GameElement(5);
                array[1, 0] = new GameElement(1);
                array[1, 1] = new GameElement(9);
                array[1, 2] = new GameElement(1);
                array[2, 0] = new GameElement(5);
                array[2, 1] = new GameElement(1);
                array[2, 2] = new GameElement(7);
                break;

            case 2:    //3x3
                array       = new GameElement[3, 3];
                array[0, 0] = new GameElement(7);
                array[0, 1] = new GameElement(0);
                array[0, 2] = new GameElement(7);
                array[1, 1] = new GameElement(7);
                array[1, 1] = new GameElement(5);
                array[1, 2] = new GameElement(7);
                array[2, 0] = new GameElement(7);
                array[2, 1] = new GameElement(0);
                array[2, 2] = new GameElement(7);
                break;
                //case 3://2x2
                //    array = new GameElement[2, 2];
                //    array[0, 0] = new GameElement(7);
                //    array[0, 1] = new GameElement(1);
                //    array[1, 0] = new GameElement(1);
                //    array[1, 1] = new GameElement(7);
                //    break;
            }
            return(array);
        }
예제 #4
0
        public GameElement[] SearcherAll(int t)
        {
            GameElement[] array   = new GameElement[CountAll(t)];
            int           counter = 0;

            for (int x = 0; x < X; x++)
            {
                for (int y = 0; y < Y; y++)
                {
                    if (Table[x, y].type == new GameElement(t).type)
                    {
                        array[counter] = Table[x, y];
                    }
                }
            }
            return(array);
        }
예제 #5
0
        public void CreateField()
        {
            //Creating walls
            for (int i = 0; i < X; i++)
            {
                Table[i, 0]     = new GameElement(7);// 0 - #, 1 - @, 2 - •, 3 - /, 4 - \, 5 - ₴, 6 - +, 7 - ;8 - ■
                Table[i, Y - 1] = new GameElement(7);
                Table[i, 0].SetCoordinates(i, 0);
                Table[i, 0].SetCoordinates(i, Y - 1);
            }
            for (int i = 0; i < Y; i++)
            {
                Table[0, i]     = new GameElement(7);
                Table[X - 1, i] = new GameElement(7);
                Table[0, i].SetCoordinates(0, i);
                Table[X - 1, i].SetCoordinates(X - 1, i);
            }

            //RANDOM generator
            Random random  = new Random();
            int    tempint = 0;

            for (int i = 1; i < X - 1; i++)
            {
                for (int x = 1; x < Y - 1; x++)
                {
                    if (i > 2 || x > 2)
                    {
                        tempint = random.Next(1, 130);//add some ↑
                        if (tempint < 61)
                        {
                            Table[i, x] = new GameElement(7);
                        }
                        else if (tempint > 60 && tempint < 76)
                        {
                            Table[i, x] = new GameElement(0);
                        }
                        else if (tempint > 75 && tempint < 88)
                        {
                            Table[i, x] = new GameElement(1);
                        }
                        else if (tempint > 87 && tempint < 96)
                        {
                            Table[i, x] = new GameElement(5);
                        }
                        else if (tempint > 95 && tempint < 101)
                        {
                            Table[i, x] = new GameElement(9);
                        }
                        else if (tempint > 100 && tempint < 106)
                        {
                            Table[i, x] = new GameElement(10);
                        }
                        else if (tempint > 105 && tempint < 111)
                        {
                            Table[i, x] = new GameElement(11);
                        }
                        else if (tempint > 110 && tempint < 116)
                        {
                            Table[i, x] = new GameElement(12);
                        }
                        else if (tempint > 115 && tempint < 121)
                        {
                            Table[i, x] = new GameElement(13);
                        }
                        else if (tempint > 120 && tempint < 126)
                        {
                            Table[i, x] = new GameElement(6);
                        }
                        else if (tempint > 125)
                        {
                            Random rand = new Random();
                            while (true)
                            {
                                int tempX = rand.Next(0, X);
                                int tempY = rand.Next(0, Y);

                                if (Table[tempX, tempY] != null)
                                {
                                    if (Table[tempX, tempY].type == ' ')
                                    {
                                        linkedTP tempTP = new linkedTP(14);
                                        Table[i, x]         = tempTP;
                                        Table[tempX, tempY] = Table[i, x];
                                        Table[tempX, tempY].SetCoordinates(tempX, tempY);
                                        tempTP.X1 = tempX;
                                        tempTP.Y1 = tempY;
                                        break;
                                    }
                                }
                                else
                                {
                                    linkedTP tempTP = new linkedTP(14);
                                    Table[i, x]         = tempTP;
                                    Table[tempX, tempY] = Table[i, x];
                                    Table[tempX, tempY].SetCoordinates(tempX, tempY);
                                    tempTP.X1 = tempX;
                                    tempTP.Y1 = tempY;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        Table[i, x] = new GameElement(7);
                    }
                    Table[i, x].SetCoordinates(i, x);
                }
            }

            //PATTERN generator+fill with random if not patterned
            if (X > 5)//playzone is bigger than 3
            {
                Pattern pattern;
                GameElement[,] array;
                int c = 0;
                for (int i = X - 2 / 3; i > 0; i--)//count of pattern structs
                {
                    //for (int z = 2; z < (X - 2) * (X - 2); z++)//count of elements
                    //{
                    for (int x = (X - 2) % 3 + 1; x < X - 3; x++)
                    {
                        for (int y = (X - 2) % 3 + 1; y < X - 3; y++)
                        {
                            if (this.AreaIsClear(this, new[] { x, y }, new[] { x + 2, y + 2 }))
                            {
                                pattern = new Pattern(random.Next(1, 2));//3x3 structs
                                array   = pattern.ReturnPattern();
                                for (int l = x; l < x + 3; l++)
                                {
                                    for (int m = y; m < y + 3; m++)
                                    {
                                        Table[l, m] = array[l - x, m - y];
                                    }
                                }
                                c++;
                                if (c == i)
                                {
                                    goto Foo;
                                }
                            }
                        }
                    }
                    //}
                }
Foo:
                Nothing();
            }


            //Setting up ball
            ball1.SetCoordinates(1, 1);

            //Setting up layer table for selector
            selector = new Selector(8, this);
            selector.SetCoordinates(0, 0);
        }