Exemplo n.º 1
0
 public static bool checkReachedLimit(Bubble bubble)
 {
     if (bubble.getPosition().y > verteces[3])
       {
     return true;
       }
       return false;
 }
Exemplo n.º 2
0
 public Bubble(Bubble b)
     : base(b, new ModelBubble((ModelBubble)b.displayable))
 {
     isPopped = false;
       isDropped = false;
       isConnected = false;
       currentRotation = Matrix.Identity;
 }
Exemplo n.º 3
0
 public static bool checkWallCollision(Bubble bubble)
 {
     if (bubble.getPosition().x < (verteces[0] + 2) || bubble.getPosition().x > (verteces[1]-2))
       {
     return true;
       }
       return false;
 }
Exemplo n.º 4
0
 public static bool checkOutOfBounds(Bubble bubble)
 {
     if (bubble.getPosition().y < (verteces[2]))
       {
     return true;
       }
       return false;
 }
Exemplo n.º 5
0
        public static Bubble createRandomBubble(Point p)
        {
            Bubble newBubble;
              if(random == null)
              {
            random = new Random();
              }
              int bColor = random.Next(1,7);
              newBubble = new Bubble(game, bubbleColors[bColor], new Point(p));

              return newBubble;
        }
Exemplo n.º 6
0
        public static Bubble createRandomBubble(Point p)
        {
            Bubble newBubble;

            if (random == null)
            {
                random = new Random();
            }
            int bColor = random.Next(1, 7);

            newBubble = new Bubble(game, bubbleColors[bColor], new Point(p));

            return(newBubble);
        }
Exemplo n.º 7
0
 public static bool checkColliding(Bubble b)
 {
     bool isColliding = false;
       for (int i = 0; i <= grid.GetUpperBound(0); i++)
       {
     for (int j = 0; j <= grid.GetUpperBound(1); j++)
     {
       if (grid[i, j].isColliding(b.getPosition()))
       {
     isColliding = true;
       }
     }
       }
       return isColliding;
 }
Exemplo n.º 8
0
        public static void snapToGrid(Bubble b)
        {
            bool       found = false;
            GridSquare best;

            best = grid[0, 0];
            for (int j = 0; j <= grid.GetUpperBound(1); j++)
            {
                for (int i = 0; i <= grid.GetUpperBound(0); i++)
                {
                    if (grid[i, j].enoughToSnap(b.getPosition()) && grid[i, j].bubble == null)
                    {
                        best  = grid[i, j];
                        found = true;
                        break;
                    }
                    else if (grid[i, j].bubble == null && getSnappingScore(b, grid[i, j]) < getSnappingScore(b, best))
                    {
                        best = grid[i, j];
                    }
                }
                if (found)
                {
                    break;
                }
            }

            b.setPosition(new Point(best.point));
            best.bubble = b;
            popped      = new List <Bubble>();
            stuckToWall = new List <Bubble>();
            checkPopping(best);
            if (popped.Count > 2)
            {
                popBubbles();
                droppingBubbles = new List <Bubble>();
                checkDropping(grid[0, 0]);
                checkDropping(grid[1, 0]);
                checkDropping(grid[2, 0]);
                checkDropping(grid[3, 0]);
                checkDropping(grid[4, 0]);
                checkDropping(grid[5, 0]);
                checkDropping(grid[6, 0]);
                checkDropping(grid[7, 0]);
                getRemainingBubbles();
                dropBubbles();
            }
        }
Exemplo n.º 9
0
        public static bool checkColliding(Bubble b)
        {
            bool isColliding = false;

            for (int i = 0; i <= grid.GetUpperBound(0); i++)
            {
                for (int j = 0; j <= grid.GetUpperBound(1); j++)
                {
                    if (grid[i, j].isColliding(b.getPosition()))
                    {
                        isColliding = true;
                    }
                }
            }
            return(isColliding);
        }
Exemplo n.º 10
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]]);
                    }
                }
            }
        }
Exemplo n.º 11
0
        public override bool Equals(Object obj)
        {
            Bubble p = (Bubble)obj;

            return(getPosition().Equals(p.getPosition()));
        }
Exemplo n.º 12
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));
 }
Exemplo n.º 13
0
 public GridSquare(Point p, Bubble b)
 {
     point = p;
       bubble = b;
       dimensions = new Dimension(b.dimensions);
 }
Exemplo n.º 14
0
 public Bubble(Bubble b)
     : base(b, new ModelBubble((ModelBubble)b.displayable))
 {
     isPopped = false;
 }
Exemplo n.º 15
0
 public GridSquare(Point p, Bubble b)
 {
     point      = p;
     bubble     = b;
     dimensions = new Dimension(b.dimensions);
 }
Exemplo n.º 16
0
        public static void snapToGrid(Bubble b)
        {
            bool found = false;
              GridSquare best;
              best = grid[0, 0];
              for (int j = 0; j <= grid.GetUpperBound(1); j++)
              {
            for (int i = 0; i <= grid.GetUpperBound(0); i++)
            {
              if (grid[i, j].enoughToSnap(b.getPosition()))
              {
            best = grid[i,j];

            found = true;
            break;
              }
              else if(grid[i,j].bubble !=null && getSnappingScore(b, grid[i,j]) < getSnappingScore(b, best))
              {
            best = grid[i, j];
              }
            }
            if (found)
            {
              break;
            }
              }

              b.setPosition(new Point(best.point));
              best.bubble = b;
              popped = new List<Bubble>();
              checkPopping(best);
              if (popped.Count > 2)
              {
            popBubbles();
              }
        }
Exemplo n.º 17
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) );
 }