Exemple #1
0
 public static bool checkWallCollision(Bubble bubble)
 {
     if (bubble.getPosition().x < (verteces[0] + 2) || bubble.getPosition().x > (verteces[1] - 2))
     {
         return(true);
     }
     return(false);
 }
 public static bool checkWallCollision(Bubble bubble)
 {
     if (bubble.getPosition().x < (verteces[0] + 2) || bubble.getPosition().x > (verteces[1]-2))
       {
     return true;
       }
       return false;
 }
 public static bool checkReachedLimit(Bubble bubble)
 {
     if (bubble.getPosition().y > verteces[3])
       {
     return true;
       }
       return false;
 }
 public static bool checkOutOfBounds(Bubble bubble)
 {
     if (bubble.getPosition().y < (verteces[2]))
       {
     return true;
       }
       return false;
 }
Exemple #5
0
 public static bool checkReachedLimit(Bubble bubble)
 {
     if (bubble.getPosition().y > verteces[3])
     {
         return(true);
     }
     return(false);
 }
Exemple #6
0
 public static bool checkOutOfBounds(Bubble bubble)
 {
     if (bubble.getPosition().y < (verteces[2]))
     {
         return(true);
     }
     return(false);
 }
 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;
 }
Exemple #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();
            }
        }
Exemple #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);
        }
Exemple #10
0
        public override bool Equals(Object obj)
        {
            Bubble p = (Bubble)obj;

            return(getPosition().Equals(p.getPosition()));
        }
Exemple #11
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));
 }
 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) );
 }
        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();
              }
        }