WIP Perpendicular spot regeneration

This commit is contained in:
Dawid Pietrykowski 2022-10-28 00:19:11 +02:00
parent 8f8635efb8
commit d7218e6352
4 changed files with 38 additions and 4 deletions

View File

@ -2932,7 +2932,7 @@ MonoBehaviour:
mainPlanContainer: {fileID: 557435656} mainPlanContainer: {fileID: 557435656}
emergencyPlanContainer: {fileID: 632826360} emergencyPlanContainer: {fileID: 632826360}
reconfigurationToggle: {fileID: 441283505} reconfigurationToggle: {fileID: 441283505}
defaultPath: /home/dawp/Projects/Commisions/Parking/Assets/Data/Tablica2.csv defaultPath: /home/dawp/Projects/Commisions/Parking/Assets/Data/Tablica5_2022-09-09.csv
--- !u!1 &1347097428 --- !u!1 &1347097428
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -735,7 +735,8 @@ namespace Parking
} }
if (spot.Lane == 0 && Width / 2.0f - newX < 5.5f + 0.5f + 2.25f) { float distToRightWall = Width / 2.0f - newX + SpotHeights[(int)newSize] / 2.0f;
if (spot.Lane == 0 && distToRightWall < 5.5f && (distToRightWall != 0)) {
// Try to remove one spot next // Try to remove one spot next
continue; continue;
} }
@ -838,6 +839,39 @@ namespace Parking
lastRightBorder = _spotMap[0][i].RightBorder; lastRightBorder = _spotMap[0][i].RightBorder;
} }
// return false;
spaceNeeded = 2.25f;
// Try for perpendicular
for (int i = _spotMap[0].Count - 1; i >= -1; i--) {
float leftBorder;
if (i >= 0) {
leftBorder = _spotMap[0][i].LeftBorder;
}
else
leftBorder = Width / 2.0f;
if (leftBorder - lastRightBorder >= spaceNeeded) {
newPosition.x = (lastRightBorder + 0.5f + SpotHeights[(int)size] / 2.0f);
newPosition.y = (-Height / 2.0f) + 2.25f / 2.0f;
float nextBorder = GetNextBorderVectical(newPosition, 0, true, size, true);
float spotBorder = -Height / 2.0f + SpotHeights[(int) size];
if(nextBorder - spotBorder < 5.5f)
continue;
Spot newSpot = new Spot(size, false);
//newPosition.x = (lastRightBorder + SpotHeights[(int)size] / 2.0f);
newSpot.Perpendicular = false;
newSpot.GameObject = Instantiate(_spotPrefabs[(int)size],
newPosition, Quaternion.Euler(0, 0, 90), mainPlanContainer);
_spotMap[0].Add(newSpot);
_spotMap[0].Sort((a, b) => Comparer<float>.Default.Compare(b.Position.x, a.Position.x));
return true;
}
if (i >= 0)
lastRightBorder = _spotMap[0][i].RightBorder;
}
return false; return false;
// newPosition.y = bottomBorder + SpotHeights[(int) newSize] / 2.0f; // newPosition.y = bottomBorder + SpotHeights[(int) newSize] / 2.0f;

View File

@ -2,7 +2,7 @@
"dependencies": { "dependencies": {
"com.unity.collab-proxy": "1.17.2", "com.unity.collab-proxy": "1.17.2",
"com.unity.feature.2d": "1.0.0", "com.unity.feature.2d": "1.0.0",
"com.unity.ide.rider": "3.0.15", "com.unity.ide.rider": "3.0.16",
"com.unity.ide.visualstudio": "2.0.16", "com.unity.ide.visualstudio": "2.0.16",
"com.unity.ide.vscode": "1.2.5", "com.unity.ide.vscode": "1.2.5",
"com.unity.test-framework": "1.1.31", "com.unity.test-framework": "1.1.31",

View File

@ -125,7 +125,7 @@
} }
}, },
"com.unity.ide.rider": { "com.unity.ide.rider": {
"version": "3.0.15", "version": "3.0.16",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": { "dependencies": {