private void ChangeBallsDirectionOnInsert(GameObject newBall, Vector3 positionForFirstBall, Vector3 posForNewBall) { BListObject actual = balls.InitEnumerationFromRightBListObject(); BallObject ballObj = actual.value.GetComponent <BallScript>().ballObj; bool curveChange = false; ballObj.destination--; ballObj.destinationPosition = positionForFirstBall; ballObj.IncreaseSpeedLevel(); if (actual.value != newBall) { while ((actual = balls.PreviousBListObject()) != null && actual.value != newBall) { ballObj = actual.value.GetComponent <BallScript>().ballObj; ballObj.destination--; if (actual.rightNeighbour.value.GetComponent <BallScript>().ballObj.destination > ballObj.destination && !curveChange) { ballObj.destination++; curveChange = true; } else if (curveChange) { curveChange = false; } ballObj.destinationPosition = actual.rightNeighbour.value.transform.position; ballObj.IncreaseSpeedLevel(); } ballObj = actual.value.GetComponent <BallScript>().ballObj; ballObj.destination--; if (actual.rightNeighbour.value.GetComponent <BallScript>().ballObj.destination > ballObj.destination && !curveChange) { ballObj.destination++; curveChange = true; } ballObj.destinationPosition = posForNewBall; ballObj.IncreaseSpeedLevel(); } }