コード例 #1
0
    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));
        }
    }
コード例 #2
0
    public async void activateGameGrid()
    {
        currentHighlightedCell = placeHighlightedCell();

        await Task.Delay(1000);

        canFillGrid = true;
    }
コード例 #3
0
    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);
    }
コード例 #4
0
    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;
        }
    }