public void MoveUpWhiteTiles() { requiresSwap = false; bool hasWhiteTilesGoal = false; BringDownCagedWhite_Goal goal = null; for (int i = 0; i < config.goalArray.Length; i++) { if (config.goalArray[i] is BringDownWhite_Goal) { hasWhiteTilesGoal = true; } else if (config.goalArray[i] is BringDownCagedWhite_Goal) { hasWhiteTilesGoal = true; goal = config.goalArray[i] as BringDownCagedWhite_Goal; } } bool isCaged = false; if (hasWhiteTilesGoal) { BaseTile[] tiles = GameObject.FindObjectsOfType <BaseTile>(); foreach (BaseTile tile in tiles) { if (goal) { isCaged = goal.CheckForCage(tile); } if (tile.size == 6 && !isCaged) { tile.JumpUp(this); } } } }
void GenerateTiles(bool firstTime) { if (!firstTime || !config.hasSpecialTileSetup) { foreach (List <Cell> column in cellColumns) { foreach (Cell cell in column) { if (cell.tile == null) { CreateTile(cell); } } } } else { int amountOfCagedTiles = 0; int i = 0; for (i = 0; i < config.goalArray.Length; i++) { if (config.goalArray[i] is BringDownCagedWhite_Goal) { BringDownCagedWhite_Goal goal = config.goalArray[i] as BringDownCagedWhite_Goal; amountOfCagedTiles = goal.requiredAmount; } } List <int> randomColumnList = new List <int>(); for (i = 0; i < config.x_size; i++) { randomColumnList.Add(i); } int remove = config.x_size - amountOfCagedTiles; for (i = 0; i < remove; i++) { int random = Random.Range(0, config.x_size - i); randomColumnList.RemoveAt(random); } int columnCount = 0; foreach (List <Cell> column in cellColumns) { bool allowCagedTile = true; if (!randomColumnList.Contains(columnCount)) { allowCagedTile = false; } int randomRow = Random.Range(0, config.y_size); int rowCount = 0; foreach (Cell cell in column) { if (cell.tile == null && allowCagedTile && randomRow == rowCount) { CreateCageTile(cell); } else if (cell.tile == null) { CreateTile(cell); } rowCount++; } columnCount++; } } }