Added perpendicular spot generation
This commit is contained in:
parent
d7218e6352
commit
d4a4bcbebe
@ -2932,7 +2932,7 @@ MonoBehaviour:
|
||||
mainPlanContainer: {fileID: 557435656}
|
||||
emergencyPlanContainer: {fileID: 632826360}
|
||||
reconfigurationToggle: {fileID: 441283505}
|
||||
defaultPath: /home/dawp/Projects/Commisions/Parking/Assets/Data/Tablica5_2022-09-09.csv
|
||||
defaultPath: /home/davp/Projects/Customers/Parking/Assets/Data/Tablica5.csv
|
||||
--- !u!1 &1347097428
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -840,36 +840,32 @@ namespace Parking
|
||||
}
|
||||
|
||||
// return false;
|
||||
|
||||
float lastLeftBorder = Width / 2.0f;
|
||||
spaceNeeded = 2.25f;
|
||||
// Try for perpendicular
|
||||
for (int i = _spotMap[0].Count - 1; i >= -1; i--) {
|
||||
for (int i = 0; i < _spotMap[0].Count; 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 rightBorder = _spotMap[0][i].RightBorder;
|
||||
if (lastLeftBorder - rightBorder >= spaceNeeded) {
|
||||
newPosition.x = (lastLeftBorder - (2.25f / 2.0f));
|
||||
if(newPosition.x < Width / 2.0f - 2.25f && newPosition.x > Width / 2.0f - 5.5f - 2.25f)
|
||||
continue;
|
||||
newPosition.y = (-Height / 2.0f) + SpotHeights[(int)(size)] / 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.Perpendicular = true;
|
||||
newSpot.GameObject = Instantiate(_spotPrefabs[(int)size],
|
||||
newPosition, Quaternion.Euler(0, 0, 90), mainPlanContainer);
|
||||
// TODO: Account for order
|
||||
newPosition, Quaternion.Euler(0, 0, 0), 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;
|
||||
lastLeftBorder = _spotMap[0][i].LeftBorder;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -928,8 +924,8 @@ namespace Parking
|
||||
private float GetNextBorderVectical(Vector3 position, int lane, bool perpendicular, Size size, bool up)
|
||||
{
|
||||
|
||||
float minX = position.x - (perpendicular ? 2.25f : SpotHeights[(int) size]);
|
||||
float maxX = position.x + (perpendicular ? 2.25f : SpotHeights[(int) size]);
|
||||
float minX = position.x - (perpendicular ? 2.25f : SpotHeights[(int) size]) - 2.25f/2.0f;
|
||||
float maxX = position.x + (perpendicular ? 2.25f : SpotHeights[(int) size]) + 2.25f/2.0f;
|
||||
|
||||
List<float> allBorders = new();
|
||||
List<Spot> targetLane = up ? _spotMap[lane + 1] : _spotMap[lane - 1];
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user