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