// Return: Position of next crossing RoadUnit CreateRoad(Vector3 crossingPoint, GameDefine.Direction direction, float length, bool correctRoad) { // Add path to listRoadActive // Add block to listBlock bool onRoad = true; RoadUnit newRoad = GetRoad(); BlockUnit unit = MainObjControl.Instant.blockCtrl.GetEntryBlock(crossingPoint, direction, correctRoad, onRoad); newRoad.Set(crossingPoint, direction, length); newRoad.block = unit; unit.road = newRoad; // Randomly generate a diamond on the wrong road if (!correctRoad && Random.value < 0.5) { newRoad.extraBlocks.Add(MainObjControl.Instant.blockCtrl.GetExtraBlock(crossingPoint, direction)); } activeRoads.Add(newRoad); activeBlocks.Add(unit); return(newRoad); }