public static bool MoveBalls(BList balls, float safeDistance)
    {
        changeSpecialMoveToFalse = specialMove;
        playing = true;
        BListObject actualBall = balls.InitEnumerationFromLeftBListObject();

        if (actualBall != null)
        {
            do
            {
                if (!specialMove || actualBall.value.GetComponent <BallScript>().ballObj.specialMove)
                {
                    MoveBall(actualBall);
                }
            } while ((actualBall = balls.NextBListObject()) != null);
        }


        if (changeSpecialMoveToFalse)
        {
            changeSpecialMoveToFalse = false;
            specialMove = false;
            CheckBallsCorrectDestinations(balls);
            CheckBallsCorrectDistances(balls, GameManagerScript.spawningSafeDistance);
        }
        //CheckBallsCorrectDistances(balls, GameManagerScript.spawningSafeDistance);

        return(playing);
    }
    public List <Color> GetAllColorsOnBoard()
    {
        List <Color> colors = new List <Color>();

        if (balls != null)
        {
            BListObject actual = balls.InitEnumerationFromLeftBListObject();
            if (actual != null)
            {
                do
                {
                    Color color = actual.value.GetComponent <BallScript>().ballObj.color;
                    if (!colors.Contains(color))
                    {
                        colors.Add(color);
                    }
                } while ((actual = balls.NextBListObject()) != null);
            }
        }
        return(colors);
    }
    private void ClearSpeedLevels(BList balls)
    {
        BListObject ball = balls.InitEnumerationFromLeftBListObject();

        if (ball != null)
        {
            do
            {
                ball.value.GetComponent <BallScript>().ballObj.RestartSpeedLevel();
            } while ((ball = balls.NextBListObject()) != null);
        }
    }
    public static void CheckBallsCorrectDestinations(BList balls)
    {
        BListObject actualBall  = balls.InitEnumerationFromLeftBListObject();
        int         destination = -1;

        if (actualBall != null)
        {
            do
            {
                destination = actualBall.value.GetComponent <BallScript>().ballObj.destination;
                if (actualBall.rightNeighbour != null && actualBall.rightNeighbour.value.GetComponent <BallScript>().ballObj.destination < destination)
                {
                    actualBall.rightNeighbour.value.GetComponent <BallScript>().ballObj.destination = destination;
                }
            } while ((actualBall = balls.NextBListObject()) != null);
        }
    }
    public static void CheckBallsCorrectDistances(BList balls, float safeDistance)
    {
        BListObject actualBall = balls.InitEnumerationFromLeftBListObject();

        if (actualBall != null)
        {
            do
            {
                if (actualBall.leftNeighbour != null)
                {
                    CalculateLerpVector(actualBall.value.GetComponent <BallScript>().ballObj);
                    int prevSpeedLevel = actualBall.value.GetComponent <BallScript>().ballObj.actualSpeedLevel;
                    actualBall.value.GetComponent <BallScript>().ballObj.actualSpeedLevel = 2;

                    while (GetDistance(actualBall.value, actualBall.leftNeighbour.value) < safeDistance)
                    {
                        MoveBall(actualBall);
                    }
                    actualBall.value.GetComponent <BallScript>().ballObj.actualSpeedLevel = prevSpeedLevel;
                }
            } while ((actualBall = balls.NextBListObject()) != null);
        }
    }