void SetShapesOfMatchingGroups() { bool[,] visited = new bool[BoardWidth, BoardHeight]; foreach (BoardObject boardObject in board) { Cube cube = boardObject as Cube; // If this object is not a cube, or visited before, we don't need to check it. if (cube == null || visited[cube.GridPosition.x, cube.GridPosition.y]) { continue; } visited[cube.GridPosition.x, cube.GridPosition.y] = true; List <Cube> matchingCubes = AlgoUtils.GetMatchingCubes(cube); // TODO: Change this part after adding new normal maps for bomb and disco ball shapes. if (matchingCubes.Count + 1 >= Constants.ROCKET_MATCH_COUNT) { foreach (Cube matchingCube in matchingCubes) { visited[matchingCube.GridPosition.x, matchingCube.GridPosition.y] = true; matchingCube.ShapeDrawer.SetShape(ShapeController.Shape.Rocket); } cube.ShapeDrawer.SetShape(ShapeController.Shape.Rocket); } else { cube.ShapeDrawer.SetShape(ShapeController.Shape.TearDrop); } } }
public void HandleOnClick() { List <Cube> matchingCubes = AlgoUtils.GetMatchingCubes(this); /* Note that matching cubes are not including this cube itself. * Therefore we need to add 1 one the count, * in order to get total number of cubes in this combination. */ int numTotalCubesInCombo = matchingCubes.Count + 1; if (numTotalCubesInCombo < Constants.MIN_MATCH_COUNT) { Wobble(); } else { foreach (Cube matchingCube in matchingCubes) { matchingCube.HandleOnHit(); } DestroySelf(); if (numTotalCubesInCombo >= Constants.DISCOBALL_MATCH_COUNT) { BoosterController.Instance.CreateDiscoBallAtPosition(GridPosition, transform.position , ColorChanger.CurrentColor); } else if (numTotalCubesInCombo >= Constants.BOMB_MATCH_COUNT) { BoosterController.Instance.CreateBombAtPosition(GridPosition, transform.position); } else if (numTotalCubesInCombo >= Constants.ROCKET_MATCH_COUNT) { BoosterController.Instance.CreateRocketAtPosition(GridPosition, transform.position); } } BoardController.Instance.OnClickHandled(); }