private IEnumerator _explodeFilledCells(List <List <GridCell> > selectedCells, bool stop) { selectedCells.Reverse(); foreach (List <GridCell> cells in selectedCells) { foreach (GridCell cell in cells) { cell.select(false); } yield return(new WaitForSeconds(.025f)); } cellsToSelect.Clear(); totalSelectedCells.Clear(); if (!stop) { yield return(new WaitForSeconds(localFillTimeout)); currentHighlightedCell = placeHighlightedCell(); canFillGrid = true; } else { StartCoroutine(_showRestartLevelMenu(localFillTimeout)); } }
public async void activateGameGrid() { currentHighlightedCell = placeHighlightedCell(); await Task.Delay(1000); canFillGrid = true; }
private HighlightedCell placeHighlightedCell() { GridCell outplacedCell = grid.outplacedCell(); if (outplacedCell == null) { return(null); } HighlightedCell highlightedCell = swapCell(outplacedCell, highlightedCellPrefab); highlightedCell.setColor(filledCellColor, immediately: true); cellsToSelect.Add(highlightedCell); return(highlightedCell); }
private void Update() { if (!canFillGrid) { return; } if (Input.GetMouseButtonDown(0)) { fillActionStarted = true; } if (Input.GetMouseButton(0) && fillActionStarted) { elapsed += Time.deltaTime; if (elapsed >= localFillTimeout) { fillGrid(); elapsed = 0f; // slow down fillTimeout when first cells are opened if (totalSelectedCells.Count < 2) { localFillTimeout = .1f; } else { localFillTimeout = fillTimeout; } } } if (Input.GetMouseButtonUp(0) && fillActionStarted && totalSelectedCells.Count != 0) { elapsed = localFillTimeout; // checkout fever if (totalSelectedCells.Count != 0) { makeFever(); } // swap highlighted cell with default cell swapSelectedCellsToDefault(defaultCell => { defaultCell.setColor(filledCellColor, immediately: true); defaultCell.select(true); }); StartCoroutine(_pixelizeFilledCell(totalSelectedCells.ToList())); cellsToSelect.Clear(); totalSelectedCells.Clear(); // find next outplaced cell and update highlightedCell currentHighlightedCell = placeHighlightedCell(); if (currentHighlightedCell == null) { calculateProgress(); } fillActionStarted = false; } }