Fixed debug code, cleaned up code
This commit is contained in:
parent
c843a2b0fe
commit
28d61db089
@ -237,8 +237,7 @@ namespace Parking
|
||||
{
|
||||
foreach (List<Spot> list in _spotMap)
|
||||
foreach (Spot spot1 in list)
|
||||
if (spot1.Reserved && spot1.ReservedPriority == driver.Priority && driver.Size == spot1.Size)
|
||||
{
|
||||
if (spot1.Reserved && spot1.ReservedPriority == driver.Priority && driver.Size == spot1.Size) {
|
||||
spot = spot1;
|
||||
return true;
|
||||
}
|
||||
@ -362,13 +361,15 @@ namespace Parking
|
||||
|
||||
if (spot.Size > newSize) {
|
||||
if (!spot.Perpendicular) {
|
||||
float newX = GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular, newSize, true) -
|
||||
float newX =
|
||||
GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular, newSize, true) -
|
||||
_spotHeights[(int) spot.Size] / 2.0f - 0.5f;
|
||||
newPosition = new Vector3(newX,
|
||||
newPosition.y, newPosition.z);
|
||||
}
|
||||
else {
|
||||
float newX = GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular, newSize, true) -
|
||||
float newX =
|
||||
GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular, newSize, true) -
|
||||
2.25f / 2.0f;
|
||||
if (spot.Lane == 0) {
|
||||
float xRelativeToRight = newX - Width / 2.0f - 2.25f / 2.0f;
|
||||
@ -397,7 +398,8 @@ namespace Parking
|
||||
else
|
||||
spotBorder = newPosition.y - thisSizeOffset;
|
||||
if (spot.Perpendicular) {
|
||||
float nextBorder = GetNextBorderVectical(newPosition, spot.Lane, spot.Perpendicular, newSize,
|
||||
float nextBorder = GetNextBorderVectical(newPosition, spot.Lane, spot.Perpendicular,
|
||||
newSize,
|
||||
!spot.AlignToTop);
|
||||
if (Math.Abs(spotBorder - nextBorder) < 5.5f)
|
||||
continue;
|
||||
@ -430,7 +432,8 @@ namespace Parking
|
||||
newPosition.x = nextBorderRight - _spotHeights[(int) newSize] - 0.5f;
|
||||
newPosition.y = position.y;
|
||||
foundByRemoval = true;
|
||||
}else
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -451,7 +454,8 @@ namespace Parking
|
||||
newPosition.x = nextBorderRight - _spotHeights[(int) newSize] - 0.5f;
|
||||
newPosition.y = position.y;
|
||||
foundByRemoval = true;
|
||||
}else
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -480,7 +484,7 @@ namespace Parking
|
||||
// Try to remove one spot next
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
|
||||
newPosition.x = newX;
|
||||
spot.Flipped = currentLaneSpots.FindIndex(spotPredicate => spotPredicate == spot) %
|
||||
2 == 0;
|
||||
@ -488,7 +492,6 @@ namespace Parking
|
||||
spot.Perpendicular = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
newPosition.x = nextBorderRight - _spotHeights[(int) newSize] / 2.0f - 0.5f;
|
||||
if (i == 0)
|
||||
@ -547,7 +550,7 @@ namespace Parking
|
||||
allBorders.Add(targetSpotPosition.y + sizeOffset);
|
||||
}
|
||||
|
||||
if(12.85 - 2.5/2.0f <= maxX && lane == 2 && up)
|
||||
if (12.85 - 2.5 / 2.0f <= maxX && lane == 2 && up)
|
||||
allBorders.Add(Height / 2.0f - 5);
|
||||
|
||||
if (allBorders.Count == 0)
|
||||
@ -592,7 +595,6 @@ namespace Parking
|
||||
return position.x + (right ? 1 : -1) * _spotHeights[(int) size] / 2.0f;
|
||||
if (right)
|
||||
return Width / 2.0f;
|
||||
else
|
||||
return -Width / 2.0f + 5.5f;
|
||||
}
|
||||
|
||||
@ -679,16 +681,18 @@ namespace Parking
|
||||
// ? 2.25f / 2.0f
|
||||
// : spotSizes[(int) spotMap[i][j].Size] / 2.0f);
|
||||
|
||||
if(spotMap[i][j].Size != Size.D)
|
||||
if (spotMap[i][j].Size != Size.D) {
|
||||
currentX += (i != 0 ? 1 : -1) *
|
||||
(spotMap[i][j].Perpendicular
|
||||
? 2.25f / 2.0f
|
||||
: spotSizes[(int) spotMap[i][j].Size] / 2.0f + (j != 0 ? 0.25f : 0));
|
||||
else
|
||||
}
|
||||
else {
|
||||
currentX += (i != 0 ? 1 : -1) *
|
||||
(spotMap[i][j].Perpendicular
|
||||
? 2.5f / 2.0f
|
||||
: spotSizes[(int) spotMap[i][j].Size] / 2.0f + (j != 0 ? 0.25f : 0));
|
||||
}
|
||||
|
||||
|
||||
spotMap[i][j].Flipped = flipped;
|
||||
@ -724,21 +728,20 @@ namespace Parking
|
||||
bool frontalParking = !(!parkingFromTop ^ flipped);
|
||||
spotMap[i][j].ParkingDirection = frontalParking ? ParkingPreference.Front : ParkingPreference.Back;
|
||||
|
||||
if(frontalParking)
|
||||
spotMap[i][j].GameObject.transform.localScale *= 0.5f;
|
||||
|
||||
spotMap[i][j].Lane = i;
|
||||
|
||||
if(spotMap[i][j].Size != Size.D)
|
||||
if (spotMap[i][j].Size != Size.D) {
|
||||
currentX += (i != 0 ? 1 : -1) *
|
||||
(spotMap[i][j].Perpendicular
|
||||
? 2.25f / 2.0f
|
||||
: spotSizes[(int) spotMap[i][j].Size] / 2.0f + 0.25f);
|
||||
else
|
||||
}
|
||||
else {
|
||||
currentX += (i != 0 ? 1 : -1) *
|
||||
(spotMap[i][j].Perpendicular
|
||||
? 2.5f / 2.0f
|
||||
: spotSizes[(int) spotMap[i][j].Size] / 2.0f + 0.25f);
|
||||
}
|
||||
|
||||
flipped = !flipped;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user