Пример #1
0
    // Drop dots to refill the board
    public void DropDots()
    {
        // stops all dot movement and drop coroutines, for overlapping drop calls
        if (DropCoroutine != null)
        {
            StopCoroutine(DropCoroutine);
        }
        dotsToDrop  = 0;
        dotsDropped = 0;
        for (int i = 0; i < boardWidth; i++)
        {
            for (int k = 0; k < boardHeight; k++)
            {
                BoardSpace    curSpace = BoardArray[i][k];
                DotController curDot   = curSpace.GetCurrentDot();
                if (!curSpace.IsEmpty)
                {
                    curDot.StopMovement();
                }
            }
        }

        // find or spawn new dots to go into score board spaces
        for (int i = 0; i < boardWidth; i++)
        {
            for (int k = 0; k < boardHeight; k++)
            {
                BoardSpace    curSpace = BoardArray[i][k];
                DotController curDot   = curSpace.GetCurrentDot();
                if (curSpace.IsEmpty || curDot.FlaggedToDrop)
                {
                    curSpace.SetNewDot();
                }
            }
        }
        DropCoroutine = StartCoroutine(Drop());
    }