Fixed debug code, cleaned up code
This commit is contained in:
parent
c843a2b0fe
commit
28d61db089
@ -78,7 +78,7 @@ namespace Parking
|
|||||||
}
|
}
|
||||||
|
|
||||||
dateText.text = path.Substring(path.Length - 1 - 4 - 9, 10);
|
dateText.text = path.Substring(path.Length - 1 - 4 - 9, 10);
|
||||||
|
|
||||||
InitiateManager();
|
InitiateManager();
|
||||||
startPanel.SetActive(false);
|
startPanel.SetActive(false);
|
||||||
}
|
}
|
||||||
@ -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,13 +398,14 @@ 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;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float nextBorderLeft = GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular,
|
float nextBorderLeft = GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular,
|
||||||
spot.Size,
|
spot.Size,
|
||||||
false);
|
false);
|
||||||
float nextBorderRight = GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular,
|
float nextBorderRight = GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular,
|
||||||
@ -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,11 +454,12 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundByRemoval) {
|
if (!foundByRemoval) {
|
||||||
@ -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 {
|
||||||
@ -546,8 +549,8 @@ namespace Parking
|
|||||||
else
|
else
|
||||||
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)
|
||||||
@ -574,7 +577,7 @@ namespace Parking
|
|||||||
else
|
else
|
||||||
allBorders.Add(spotPosition.x + sizeOffset);
|
allBorders.Add(spotPosition.x + sizeOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
allBorders.Sort();
|
allBorders.Sort();
|
||||||
if (right) {
|
if (right) {
|
||||||
foreach (float adjacentBorder in allBorders)
|
foreach (float adjacentBorder in allBorders)
|
||||||
@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -678,19 +680,21 @@ namespace Parking
|
|||||||
// (spotMap[i][j].Perpendicular
|
// (spotMap[i][j].Perpendicular
|
||||||
// ? 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;
|
||||||
bool alignTop = i % 2 != 0;
|
bool alignTop = i % 2 != 0;
|
||||||
spotMap[i][j].GameObject = Instantiate(prefabs[(int) spotMap[i][j].Size], mainPlanContainer);
|
spotMap[i][j].GameObject = Instantiate(prefabs[(int) spotMap[i][j].Size], mainPlanContainer);
|
||||||
@ -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