private LineClass createLine() { bool isFreeSpace = false; IntVector2 linePosition = new IntVector2(0, 0); do { isFreeSpace = true; linePosition = new IntVector2(Random.Range(0, gameArraySize.x), Random.Range(0, gameArraySize.y)); //Debug.Log ("test line position: " + linePosition.x + ", " + linePosition.y); foreach (LineClass thisLine in linesList) { if (thisLine.hitsLine(linePosition)) { //Debug.Log ("Point hits another line: " + linePosition.x + ", " + linePosition.y); isFreeSpace = false; } } } while (!isFreeSpace); LineClass tempLine = new LineClass(parent, linePosition, gameArraySize, texCircle, texLine, texDashed, blockPixelSize, screenSize); usedArray [linePosition.x, linePosition.y] = true; usedSpaces++; for (int i = 0; i < 40; ++i) { int directionValue = Random.Range(0, 4); IntVector2 directionPoint = tempLine.getDirectionPoint(directionValue); if (this.isValidMove(directionPoint, tempLine, true)) { if (tempLine.goDirection(directionValue, false)) { // fill in array of used spaces with normal and reverse usedArray [directionPoint.x, directionPoint.y] = true; usedSpaces++; IntVector2 directionPointReverse = tempLine.getReverse(directionPoint); usedArray [directionPointReverse.x, directionPointReverse.y] = true; usedSpaces++; } else { //Debug.Log ("Unable to do direction move here - " + i); //i--; i++; } } else { //Debug.Log ("Unable to move here - " + i); //i--; i++; } } return(tempLine); }