public static bool checkReachedLimit(Bubble bubble) { if (bubble.getPosition().y > verteces[3]) { return true; } return false; }
public Bubble(Bubble b) : base(b, new ModelBubble((ModelBubble)b.displayable)) { isPopped = false; isDropped = false; isConnected = false; currentRotation = Matrix.Identity; }
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 checkOutOfBounds(Bubble bubble) { if (bubble.getPosition().y < (verteces[2])) { return true; } return false; }
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; }
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); }
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; }
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(); } }
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); }
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]]); } } } }
public override bool Equals(Object obj) { Bubble p = (Bubble)obj; return(getPosition().Equals(p.getPosition())); }
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 GridSquare(Point p, Bubble b) { point = p; bubble = b; dimensions = new Dimension(b.dimensions); }
public Bubble(Bubble b) : base(b, new ModelBubble((ModelBubble)b.displayable)) { isPopped = false; }
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(); } }
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) ); }