Esempio n. 1
0
        public static void initGrid(float posX, float posY, float posZ)
        {
            score = 0;
            int   right = 0, down = 0;
            float increment = 2;
            float zSloap    = -1;

            grid = new GridSquare[8, 10];
            for (int j = 0; j <= grid.GetUpperBound(1); j++)
            {
                down--;
                zSloap += 0.5f;
                for (int i = 0; i <= grid.GetUpperBound(0); i++)
                {
                    right++;
                    if (down % 2 == 0)
                    {
                        grid[i, j]   = new GridSquare(new Point(posX + 1 + (right * 2), posY + (down * increment), posZ + zSloap));
                        grid[i, j].x = i;
                        grid[i, j].y = j;
                    }
                    else
                    {
                        grid[i, j]   = new GridSquare(new Point(posX + (right * 2), posY + (down * increment), posZ + zSloap));
                        grid[i, j].x = i;
                        grid[i, j].y = j;
                    }
                }
                right = 0;
            }
        }
Esempio n. 2
0
        public static GridSquare[,] resizeGrid(GridSquare[,] original, int cols, int rows)
        {
            var temp = new GridSquare[cols, rows - 1];

            for (int j = 0; j < rows - 1; j++)
            {
                for (int i = 0; i < cols; i++)
                {
                    temp[i, j] = original[i, j];
                    temp[i, j].moveDown();
                }
            }
            return(temp);
        }
Esempio n. 3
0
        private static void checkPopping(GridSquare tempGrid)
        {
            List <int[]> positions = new List <int[]>();

            if (tempGrid.y % 2 == 1)
            {
                positions.Add(new int[] { tempGrid.x, tempGrid.y - 1 });     //top left
                positions.Add(new int[] { tempGrid.x + 1, tempGrid.y - 1 }); //top right
                positions.Add(new int[] { tempGrid.x - 1, tempGrid.y });     //left
                positions.Add(new int[] { tempGrid.x + 1, tempGrid.y });     //right
                positions.Add(new int[] { tempGrid.x, tempGrid.y + 1 });     //bottom left
                positions.Add(new int[] { tempGrid.x + 1, tempGrid.y + 1 }); //bottom right
            }
            else
            {
                positions.Add(new int[] { tempGrid.x - 1, tempGrid.y - 1 }); //top left
                positions.Add(new int[] { tempGrid.x, tempGrid.y - 1 });     //top right
                positions.Add(new int[] { tempGrid.x - 1, tempGrid.y });     //left
                positions.Add(new int[] { tempGrid.x + 1, tempGrid.y });     //right
                positions.Add(new int[] { tempGrid.x - 1, tempGrid.y + 1 }); //bottom left
                positions.Add(new int[] { tempGrid.x, tempGrid.y + 1 });     //bottom right
            }

            for (int i = 0; i < positions.Count; i++)
            {
                if (positions[i][0] >= 0 && positions[i][0] <= grid.GetUpperBound(0) && positions[i][1] >= 0 && positions[i][1] <= grid.GetUpperBound(1))
                {
                    Bubble b = grid[positions[i][0], positions[i][1]].bubble;
                    if (b != null && b.getColor() == tempGrid.bubble.getColor() && !popped.Contains(b))
                    {
                        if (!popped.Contains(tempGrid.bubble))
                        {
                            popped.Add(tempGrid.bubble);
                        }
                        popped.Add(b);
                        checkPopping(grid[positions[i][0], positions[i][1]]);
                    }
                }
            }
        }
Esempio n. 4
0
 public static float getSnappingScore(Bubble b, GridSquare grid)
 {
     return(Math.Abs(b.getPosition().x - grid.point.x) + Math.Abs(b.getPosition().y - grid.point.y) + Math.Abs(b.getPosition().z - grid.point.z));
 }
Esempio n. 5
0
        public static void initGrid()
        {
            score = 0;
              int right = 0, down = 0;
              float increment = 20;
              float posX = 200;
              float posY = 20;
              grid = new GridSquare[8, 10];
              for (int j = 0; j <= grid.GetUpperBound(1); j++)
              {
            down++;
            for (int i = 0; i <= grid.GetUpperBound(0); i++)
            {
              right++;
              if (down % 2 == 0)
              {
            grid[i, j] = new GridSquare(new Point(posX + 10 + (right * 20), posY + (down * increment)));
            grid[i, j].x = i;
            grid[i, j].y = j;
              }
              else
              {
            grid[i, j] = new GridSquare(new Point(posX + (right * 20), posY + (down * increment)));
            grid[i, j].x = i;
            grid[i, j].y = j;
              }

            }
            right = 0;
              }
        }
Esempio n. 6
0
 public static float getSnappingScore(Bubble b, GridSquare grid)
 {
     return (Math.Abs(b.getPosition().x - grid.point.x) + Math.Abs(b.getPosition().y - grid.point.y) );
 }
Esempio n. 7
0
        private static void checkPopping(GridSquare tempGrid)
        {
            List<int[]> positions = new List<int[]>();
              if (tempGrid.y % 2 == 1)
              {
            positions.Add(new int[] { tempGrid.x, tempGrid.y - 1 });      //top left
            positions.Add(new int[] { tempGrid.x + 1, tempGrid.y - 1 });  //top right
            positions.Add(new int[] { tempGrid.x - 1, tempGrid.y });      //left
            positions.Add(new int[] { tempGrid.x + 1, tempGrid.y });      //right
            positions.Add(new int[] { tempGrid.x, tempGrid.y + 1 });      //bottom left
            positions.Add(new int[] { tempGrid.x + 1, tempGrid.y + 1 });      //bottom right
              }
              else
              {
            positions.Add(new int[] { tempGrid.x - 1, tempGrid.y - 1 });      //top left
            positions.Add(new int[] { tempGrid.x, tempGrid.y - 1 });  //top right
            positions.Add(new int[] { tempGrid.x - 1, tempGrid.y });      //left
            positions.Add(new int[] { tempGrid.x + 1, tempGrid.y });      //right
            positions.Add(new int[] { tempGrid.x - 1, tempGrid.y + 1 });      //bottom left
            positions.Add(new int[] { tempGrid.x, tempGrid.y + 1 });      //bottom right
              }

              for (int i = 0; i < positions.Count;i++ )
              {
            if(positions[i][0]>=0 && positions[i][0]<= grid.GetUpperBound(0) && positions[i][1]>=0 && positions[i][1]<=grid.GetUpperBound(1))
            {
              Bubble b = grid[positions[i][0], positions[i][1]].bubble;
              if( b != null && b.getColor()==tempGrid.bubble.getColor() && !popped.Contains(b))
              {
            if(!popped.Contains(tempGrid.bubble))
            {
              popped.Add(tempGrid.bubble);
            }
            popped.Add(b);
            checkPopping(grid[positions[i][0], positions[i][1]]);
              }
            }
              }
        }
Esempio n. 8
0
 public static GridSquare[,] resizeGrid(GridSquare[,] original, int cols, int rows)
 {
     var temp = new GridSquare[cols, rows-1];
       for (int j = 0; j < rows-1; j++)
       {
     for (int i = 0; i < cols; i++)
     {
       temp[i, j] = original[i, j];
       temp[i, j].moveDown();
     }
       }
       return temp;
 }
Esempio n. 9
0
        public static void initGrid(float posX, float posY, float posZ)
        {
            score = 0;
              int right = 0, down = 0;
              float increment = 2;
              float zSloap = -1;
              grid = new GridSquare[8, 10];
              for (int j = 0; j <= grid.GetUpperBound(1); j++)
              {
            down--;
            zSloap+=0.5f;
            for (int i = 0; i <= grid.GetUpperBound(0); i++)
            {
              right++;
              if (down % 2 == 0)
              {
            grid[i, j] = new GridSquare(new Point(posX + 1 + (right * 2), posY + (down * increment), posZ + zSloap));
            grid[i, j].x = i;
            grid[i, j].y = j;
              }
              else
              {
            grid[i, j] = new GridSquare(new Point(posX + (right * 2), posY + (down * increment), posZ + zSloap));
            grid[i, j].x = i;
            grid[i, j].y = j;
              }

            }
            right = 0;
              }
        }