diff --git a/Assets/Scripts/InitialConfigurationGenerator.cs b/Assets/Scripts/InitialConfigurationGenerator.cs index fbb01f0..2591a8a 100644 --- a/Assets/Scripts/InitialConfigurationGenerator.cs +++ b/Assets/Scripts/InitialConfigurationGenerator.cs @@ -29,7 +29,7 @@ namespace Parking } var countsString = $"Małe: {counts[0]} Średnie: {counts[1]} Duże: {counts[2]} " + - $"Suma: {counts.Sum()}"; + $"Suma: {counts.Sum() + 1}"; ParkingManager.Instance.UpdateText(countsString); Debug.Log(countsString); @@ -104,33 +104,39 @@ namespace Parking } } - // for (var laneId = 3; laneId >= 0; laneId--) { - // if (spotCountsPerpendicular[laneId] != 0) { - // if (sizeIds[laneId] == 0) { - // // empty - // } - // else if (sizeIds[laneId] == 1) { - // // parallel only - // } - // else { - // spotsCreatedTemp[laneId, sizeIds[laneId] - 2] += spotCountsPerpendicular[laneId]; - // spotCountsPerpendicular[laneId] = 0; - // } - // } - // } int count = 0; for (var i = 0; i < spotsCreatedTemp.GetLength(0); i++) for (var j = 0; j < spotsCreatedTemp.GetLength(1); j++) - count += spotsCreatedTemp[i, j]; - - if(copyToArray) - for (var i = 0; i < spotsCreatedTemp.GetLength(0); i++) - for (var j = 0; j < spotsCreatedTemp.GetLength(1); j++) - spotsCreated[i, j] = spotsCreatedTemp[i, j]; + count += spotsCreatedTemp[i, j]; + if (!copyToArray) + return count; + + for (var laneId = 3; laneId >= 0; laneId--) { + if (spotCountsPerpendicular[laneId] != 0) { + if (sizeIds[laneId] == 0) { + // empty + } + else if (sizeIds[laneId] == 1) { + // parallel only + } + else { + spotsCreatedTemp[laneId, sizeIds[laneId] - 2] += spotCountsPerpendicular[laneId]; + count += spotCountsPerpendicular[laneId]; + spotCountsPerpendicular[laneId] = 0; + } + } + } + + + for (var i = 0; i < spotsCreatedTemp.GetLength(0); i++) + for (var j = 0; j < spotsCreatedTemp.GetLength(1); j++) + spotsCreated[i, j] = spotsCreatedTemp[i, j]; + + return count; }