Added free space filling

This commit is contained in:
Dawid Pietrykowski 2022-09-05 00:27:58 +02:00
parent d5983e8d6c
commit 66558149ca

View File

@ -29,7 +29,7 @@ namespace Parking
} }
var countsString = $"Małe: {counts[0]} Średnie: {counts[1]} Duże: {counts[2]} " + var countsString = $"Małe: {counts[0]} Średnie: {counts[1]} Duże: {counts[2]} " +
$"Suma: {counts.Sum()}"; $"Suma: {counts.Sum() + 1}";
ParkingManager.Instance.UpdateText(countsString); ParkingManager.Instance.UpdateText(countsString);
Debug.Log(countsString); Debug.Log(countsString);
@ -104,20 +104,6 @@ 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; int count = 0;
@ -125,10 +111,30 @@ namespace Parking
for (var j = 0; j < spotsCreatedTemp.GetLength(1); j++) for (var j = 0; j < spotsCreatedTemp.GetLength(1); j++)
count += spotsCreatedTemp[i, j]; count += spotsCreatedTemp[i, j];
if(copyToArray)
for (var i = 0; i < spotsCreatedTemp.GetLength(0); i++) if (!copyToArray)
for (var j = 0; j < spotsCreatedTemp.GetLength(1); j++) return count;
spotsCreated[i, j] = spotsCreatedTemp[i, j];
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; return count;