Fixed EV spot border, file read sizes, priority size check
This commit is contained in:
parent
4a36800cde
commit
c843a2b0fe
162
Assets/Data/Tablica5_2022-09-09.csv
Normal file
162
Assets/Data/Tablica5_2022-09-09.csv
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
Ranga stanowiska ,wybrany sposób parkowania,Klasyfikacja gabarytu ,od planwane,do planowane,od rzeczywiste,do rzeczywiste,czas miedzy sprawdzaniem miejsca
|
||||||
|
1,,Du¿y,13,16,12:59,16:01,60
|
||||||
|
1,T,Du¿y,13,16,13:05,16:10,60
|
||||||
|
1,P,Du¿y,13:30,16:30,13:31,16:35,60
|
||||||
|
1,P,Du¿y,14,17,13:57,17:01,60
|
||||||
|
1,,Du¿y,13,16,13:08,16:15,60
|
||||||
|
1,P,Du¿y,12:30,16:30,12:25,16:38,60
|
||||||
|
1,T,Du¿y,12:30,15:30,12:31,15:29,60
|
||||||
|
1,,Du¿y,13,15,12:56,14:58,60
|
||||||
|
1,,Du¿y,13,16,12:54,16:02,60
|
||||||
|
1,T,Du¿y,13:30,15:30,13:30,15:35,60
|
||||||
|
1,,Du¿y,14,16,13:56,15:58,60
|
||||||
|
1,P,Du¿y,12:30,17,12:27,16:59,60
|
||||||
|
1,P,Du¿y,13,16,12:55,15:58,60
|
||||||
|
1,,Du¿y,12:30,16,12:01,16:02,60
|
||||||
|
1,,Du¿y,13,15:30,12:56,15:43,60
|
||||||
|
2,,Du¿y,13,16,12:58,16:03,15
|
||||||
|
2,T,Du¿y,13:30,16:30,13:28,16:35,15
|
||||||
|
2,,Du¿y,14,17,14:04,16:58,15
|
||||||
|
2,T,Du¿y,12:30,16,12:31,16:40,15
|
||||||
|
2,P,Du¿y,13:30,15:30,13:27,15:31,15
|
||||||
|
2,P,Du¿y,13:30,16:30,13:19,16:32,15
|
||||||
|
2,P,Du¿y,13,16,12:58,16:04,15
|
||||||
|
2,T,Du¿y,13,15,13:08,15:05,15
|
||||||
|
2,T,Du¿y,13:30,15:30,13:28,15:32,15
|
||||||
|
2,P,Du¿y,12:30,16:30,12:34,16:41,15
|
||||||
|
2,,Du¿y,13:30,16:30,13:24,16:29,15
|
||||||
|
2,,Du¿y,12:30,15:30,12:28,15:35,15
|
||||||
|
2,,Du¿y,13,16,12:55,16:01,15
|
||||||
|
2,T,Du¿y,13,15,12:58,15:19,15
|
||||||
|
2,,Du¿y,13,17,12:55,17:01,15
|
||||||
|
2,P,Du¿y,13:30,15:30,13:27,15:32,15
|
||||||
|
2,,Du¿y,13:30,16:30,12:25,16:37,15
|
||||||
|
2,T,Du¿y,14,17,14:02,17:05,15
|
||||||
|
2,P,Du¿y,14,16,14:06,15:40,15
|
||||||
|
2,,Du¿y,12:30,15:30,12:34,15:38,15
|
||||||
|
2,T,Du¿y,13:30,16:30,13:29,16:39,15
|
||||||
|
2,,Du¿y,13,16,13:10,16:13,15
|
||||||
|
2,P,Du¿y,13,17,12:49,16:51,15
|
||||||
|
2,P,Du¿y,14,17,14:04,17:11,15
|
||||||
|
2,T,Du¿y,13,16,13:02,16:03,15
|
||||||
|
2,,Du¿y,13:30,15:30,13:31,15:39,15
|
||||||
|
2,,Du¿y,13,17,12:55,16:59,15
|
||||||
|
2,,Du¿y,12:30,16:30,12:38,16:45,15
|
||||||
|
2,P,Du¿y,13,16,12:45,16:10,15
|
||||||
|
2,T,Du¿y,12:30,15:30,12:09,15:40,15
|
||||||
|
2,,Du¿y,13:30,16:30,13:15,16:32,15
|
||||||
|
2,,Du¿y,13:30,16:30,13:38,16:43,15
|
||||||
|
2,,Du¿y,14,17,14:02,17:11,15
|
||||||
|
2,P,Du¿y,12:30,16:30,12:35,16:47,15
|
||||||
|
2,P,Du¿y,13,17,12:54,16:40,15
|
||||||
|
2,,Du¿y,13:30,15:30,13:32,15:37,15
|
||||||
|
2,,Du¿y,12:30,16:30,12:35,16:31,15
|
||||||
|
2,P,Du¿y,12:30,15:30,12:43,15:47,15
|
||||||
|
2,,Du¿y,13:30,17:30,13:36,17:30,15
|
||||||
|
2,T,Du¿y,13,16,12:55,16:11,15
|
||||||
|
2,P,Du¿y,12:30,16:30,12:39,16:44,15
|
||||||
|
2,T,Du¿y,14,17,14:08,17:14,15
|
||||||
|
2,,Du¿y,13:30,16,13:31,15:55,15
|
||||||
|
2,,Du¿y,12:30,16,12:26,15:57,15
|
||||||
|
2,,Du¿y,13,17,12:50,16:59,15
|
||||||
|
2,P,Du¿y,14:00,17:30,13:57,17:34,15
|
||||||
|
2,,Du¿y,13,16,12:57,16:01,15
|
||||||
|
2,,Du¿y,13:30,16:30,13:32,16:30,15
|
||||||
|
2,T,Du¿y,13,15:30,12:54,15:31,15
|
||||||
|
2,T,Du¿y,14,17,13:49,16:58,15
|
||||||
|
2,,Du¿y,13:30,17:30,13:30,17:28,15
|
||||||
|
2,P,Du¿y,12:30,16:30,12:25,16:32,15
|
||||||
|
2,T,Du¿y,13,17,13:04,17:01,15
|
||||||
|
2,,Du¿y,14,17,13:58,17:03,15
|
||||||
|
2,,Du¿y,12:30,16:30,12:29,16:10,15
|
||||||
|
2,,Du¿y,13:30,17:30,13:28,17:33,15
|
||||||
|
2,P,Du¿y,14,17,13:57,17:04,15
|
||||||
|
2,P,Du¿y,13,16,13:04,15:52,15
|
||||||
|
2,P,Du¿y,13:30,17,13:34,16:59,15
|
||||||
|
2,,Du¿y,13:30,16,13:25,15:49,15
|
||||||
|
2,T,Du¿y,13,17,13:04,17:01,15
|
||||||
|
2,,Du¿y,14,17,13:58,17:03,15
|
||||||
|
2,,Du¿y,12:30,16:30,12:29,16:10,15
|
||||||
|
2,,Du¿y,13:30,17:30,13:28,17:33,15
|
||||||
|
2,P,Du¿y,14,17,13:57,17:04,15
|
||||||
|
2,P,Du¿y,13,16,13:04,15:52,15
|
||||||
|
2,P,Du¿y,13:30,17,13:34,16:59,15
|
||||||
|
2,,Du¿y,13:30,16,13:25,15:49,15
|
||||||
|
2,P,Du¿y,14,17,13:57,17:04,15
|
||||||
|
2,P,Du¿y,13,16,13:04,15:52,15
|
||||||
|
2,P,Du¿y,13:30,17,13:34,16:59,15
|
||||||
|
2,,Du¿y,13:30,16,13:25,15:49,15
|
||||||
|
2,,Du¿y,13:30,16,13:25,15:49,15
|
||||||
|
2,P,Ma³y,13,16,13:03,15:56,15
|
||||||
|
2,,Œredni,13:30,16:30,13:28,16:34,15
|
||||||
|
2,,Œredni,8,12,7:53,12:01,15
|
||||||
|
2,,Ma³y,12:30,16:30,12:28,16:35,15
|
||||||
|
2,,Œredni,13,17,12:56,16:59,15
|
||||||
|
2,,Ma³y,7:30,12,7:24,11:58,15
|
||||||
|
2,,Ma³y,8,13,8:01,13:07,15
|
||||||
|
2,T,Œredni,8,13,8:10,13:12,15
|
||||||
|
2,P,Œredni,8,11,8:45,11:02,15
|
||||||
|
3,P,Œredni,8,10,7:53,10:01,15
|
||||||
|
3,,Ma³y,9,11,8:53,10:45,15
|
||||||
|
3,,Œredni,8,11,7:45,11:01,15
|
||||||
|
3,T,Ma³y,9,11,9:30,10:59,15
|
||||||
|
3,T,Œredni,9,11,9,11:10,15
|
||||||
|
3,,Ma³y,10,11,9:50,11:04,15
|
||||||
|
3,,Œredni,9,11,9:20,10:40,15
|
||||||
|
3,P,Œredni,9,11,9,11:15,15
|
||||||
|
3,,Œredni,9,11,8:45,11:23,15
|
||||||
|
3,P,Ma³y,9,11,9,10:57,15
|
||||||
|
3,,Œredni,10,11,9:50,10:45,15
|
||||||
|
3,T,Œredni,9,11,9:30,11:06,15
|
||||||
|
3,,Œredni,8,11,7:56,10:34,15
|
||||||
|
3,T,Ma³y,9,11,09:04,11:03,15
|
||||||
|
3,T,Œredni,8,13,7:50,12:10,15
|
||||||
|
3,,Œredni,7,13,6:40,13:02,15
|
||||||
|
3,,Ma³y,7,12,7:05,12:03,15
|
||||||
|
3,P,Ma³y,10,13,9:49,12:58,15
|
||||||
|
3,,Œredni,8,12,7:45,12:04,15
|
||||||
|
3,P,Œredni,9,13,9:23,12:58,15
|
||||||
|
3,,Ma³y,8,13,7:49,13:01,15
|
||||||
|
3,,Œredni,7:30,12:30,7:27,12:36,15
|
||||||
|
3,,Ma³y,8,13,8:10,12:50,15
|
||||||
|
3,P,Ma³y,7:30,13,7:53,12:37,15
|
||||||
|
3,,Œredni,8,13,7:53,13:01,15
|
||||||
|
3,P,Œredni,7:30,13,7:35,13:00,15
|
||||||
|
3,T,Œredni,8,12:30,7:53,12:40,15
|
||||||
|
3,,Ma³y,8,13,7:57,13:01,15
|
||||||
|
3,P,Ma³y,8,13,7:45,13:10,15
|
||||||
|
3,P,Ma³y,8,12:30,7:49,12:25,15
|
||||||
|
3,,Œredni,10,13,10:05,13:08,15
|
||||||
|
3,T,Œredni,7,12,7,12:10,15
|
||||||
|
3,P,Ma³y,8,13,8:05,12:55,15
|
||||||
|
3,,Ma³y,8,13,7:45,13:10,15
|
||||||
|
3,,Ma³y,8,13,7:50,12:58,15
|
||||||
|
3,T,Œredni,8,12,8:03,12:49,15
|
||||||
|
3,,Œredni,8,10,8,9:58,15
|
||||||
|
3,P,Ma³y,7:30,12:30,7:25,12:32,15
|
||||||
|
3,,Ma³y,8,12,8:02,12:05,15
|
||||||
|
3,P,Œredni,7:30,13,7:28,12:40,15
|
||||||
|
3,T,Œredni,7:30,12:30,7:15,12:17,15
|
||||||
|
3,,Ma³y,8,12:30,7:45,12:10,15
|
||||||
|
3,P,Œredni,7,13,6:58,13:02,15
|
||||||
|
3,,Œredni,8,12,7:57,11:58,15
|
||||||
|
3,P,Ma³y,8,13,8:05,13:10,15
|
||||||
|
3,,Œredni,8,12:30,8:01,12:34,15
|
||||||
|
3,T,Ma³y,8,13,7:47,13:01,15
|
||||||
|
3,,Ma³y,7,12,6:57,12,15
|
||||||
|
3,T,Œredni,7:30,12:30,7:15,12:17,15
|
||||||
|
3,,Ma³y,8,12:30,7:45,12:10,15
|
||||||
|
3,P,Œredni,7,13,6:58,13:02,15
|
||||||
|
3,,Œredni,8,12,7:57,11:58,15
|
||||||
|
3,P,Ma³y,8,13,8:05,13:10,15
|
||||||
|
3,,Œredni,8,12:30,8:01,12:34,15
|
||||||
|
3,T,Ma³y,8,13,7:47,13:01,15
|
||||||
|
3,,Ma³y,7,12,6:57,12,15
|
||||||
|
3,T,Ma³y,8,13,7:45,12:59,15
|
||||||
|
3,P,Œredni,8,13,8:02,12:47,15
|
||||||
|
3,P,Œredni,8:30,13,8:21,12:48,15
|
||||||
|
3,,Ma³y,9,13,9:02,13:04,15
|
||||||
|
3,T,Œredni,9,12:30,8:57,12:35,15
|
||||||
|
3,T,Ma³y,8,13,8:04,13:12,15
|
||||||
|
3,T,Ma³y,8,13,7:52,12:57,15
|
||||||
|
3,,Ma³y,8,13,7:50,12:59,15
|
|
7
Assets/Data/Tablica5_2022-09-09.csv.meta
Normal file
7
Assets/Data/Tablica5_2022-09-09.csv.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d898f1b97a383b664ab5c34cd5f983ad
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -2932,7 +2932,7 @@ MonoBehaviour:
|
|||||||
mainPlanContainer: {fileID: 557435656}
|
mainPlanContainer: {fileID: 557435656}
|
||||||
emergencyPlanContainer: {fileID: 632826360}
|
emergencyPlanContainer: {fileID: 632826360}
|
||||||
reconfigurationToggle: {fileID: 441283505}
|
reconfigurationToggle: {fileID: 441283505}
|
||||||
defaultPath: Assets/Data/Tablica3.csv
|
defaultPath: Assets/Data/Tablica5_2022-09-09.csv
|
||||||
--- !u!1 &1347097428
|
--- !u!1 &1347097428
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -15,7 +15,7 @@ namespace Parking
|
|||||||
{
|
{
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
return false;
|
return false;
|
||||||
string fileData = File.ReadAllText(path);
|
string fileData = File.ReadAllText(path);//Encoding.GetEncoding(28605));
|
||||||
string[] lines = fileData.Split("\n"[0]);
|
string[] lines = fileData.Split("\n"[0]);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
char separator = ',';
|
char separator = ',';
|
||||||
@ -38,11 +38,15 @@ namespace Parking
|
|||||||
: ParkingPreference.Back;
|
: ParkingPreference.Back;
|
||||||
Size size;
|
Size size;
|
||||||
string sizeString = lineData[2];
|
string sizeString = lineData[2];
|
||||||
if (sizeString == "Mały" || sizeString == "Ma" + (char)0xB3 + "y") {
|
List<int> chars = new();
|
||||||
|
foreach (char c in sizeString) {
|
||||||
|
chars.Add((int)c);
|
||||||
|
}
|
||||||
|
if (sizeString == "Mały" || sizeString == "Ma" + (char)0xB3 + "y" || (sizeString.Contains("Ma") && sizeString.Contains("y"))) {
|
||||||
size = Size.A;
|
size = Size.A;
|
||||||
}else if (sizeString == "Średni" || sizeString == (char)0xD7 + "redni") {
|
}else if (sizeString == "Średni" || sizeString == (char)0xD7 + "redni" || sizeString.Contains("redni")) {
|
||||||
size = Size.B;
|
size = Size.B;
|
||||||
}else if (sizeString == "Duży" || sizeString == "Du" + (char)0xBF + "y") {
|
}else if (sizeString == "Duży" || sizeString == "Du" + (char)0xBF + "y" || sizeString.Contains("Du")) {
|
||||||
size = Size.C;
|
size = Size.C;
|
||||||
}else if (sizeString == "Max") {
|
}else if (sizeString == "Max") {
|
||||||
size = Size.D;
|
size = Size.D;
|
||||||
|
@ -237,7 +237,8 @@ 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) {
|
if (spot1.Reserved && spot1.ReservedPriority == driver.Priority && driver.Size == spot1.Size)
|
||||||
|
{
|
||||||
spot = spot1;
|
spot = spot1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -338,186 +339,186 @@ namespace Parking
|
|||||||
private bool TryReconfigureSpotForSize(Size newSize)
|
private bool TryReconfigureSpotForSize(Size newSize)
|
||||||
{
|
{
|
||||||
foreach (List<Spot> currentLaneSpots in _spotMap)
|
foreach (List<Spot> currentLaneSpots in _spotMap)
|
||||||
for (int i = 0; i < currentLaneSpots.Count; i++) {
|
for (int i = 0; i < currentLaneSpots.Count; i++) {
|
||||||
Spot spot = currentLaneSpots[i];
|
Spot spot = currentLaneSpots[i];
|
||||||
if (!(spot.Free && spot.Size != Size.D)) // && !spot.Reserved))
|
if (!(spot.Free && spot.Size != Size.D)) // && !spot.Reserved))
|
||||||
continue;
|
continue;
|
||||||
if (GetSpotCountOfSize(Size.A) <= 2 && spot.Size == Size.A)
|
if (GetSpotCountOfSize(Size.A) <= 2 && spot.Size == Size.A)
|
||||||
continue;
|
continue;
|
||||||
if (GetSpotCountOfSize(Size.B) <= 2 && spot.Size == Size.B)
|
if (GetSpotCountOfSize(Size.B) <= 2 && spot.Size == Size.B)
|
||||||
continue;
|
continue;
|
||||||
if (spot.LastReconfiguration == _currentTime)
|
if (spot.LastReconfiguration == _currentTime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int size = (int) newSize;
|
int size = (int) newSize;
|
||||||
Vector3 position = spot.GameObject.transform.position;
|
Vector3 position = spot.GameObject.transform.position;
|
||||||
Quaternion rotation = spot.GameObject.transform.rotation;
|
Quaternion rotation = spot.GameObject.transform.rotation;
|
||||||
|
|
||||||
float diff = (_spotHeights[(int) spot.Size] - _spotHeights[size]) / 2.0f;
|
float diff = (_spotHeights[(int) spot.Size] - _spotHeights[size]) / 2.0f;
|
||||||
if (!spot.AlignToTop)
|
if (!spot.AlignToTop)
|
||||||
diff *= -1;
|
diff *= -1;
|
||||||
Vector3 offset = spot.Perpendicular ? new Vector3(0, diff, 0) : new Vector3(-diff, 0, 0);
|
Vector3 offset = spot.Perpendicular ? new Vector3(0, diff, 0) : new Vector3(-diff, 0, 0);
|
||||||
Vector3 newPosition = position + offset;
|
Vector3 newPosition = position + offset;
|
||||||
|
|
||||||
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 = GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular, newSize, true) -
|
||||||
_spotHeights[(int) spot.Size] / 2.0f - 0.5f;
|
_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 {
|
|
||||||
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;
|
|
||||||
xRelativeToRight -= (xRelativeToRight + 2.25f / 2.0f) % 2.25f;
|
|
||||||
newX = xRelativeToRight + Width / 2.0f;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float xRelativeToLeft = newX + Width / 2.0f;
|
float newX = GetNextBorderHorizontal(position, spot.Lane, spot.Perpendicular, newSize, true) -
|
||||||
xRelativeToLeft -= (xRelativeToLeft + 2.25f / 2.0f) % 2.25f;
|
2.25f / 2.0f;
|
||||||
newX = xRelativeToLeft - Width / 2.0f;
|
if (spot.Lane == 0) {
|
||||||
}
|
float xRelativeToRight = newX - Width / 2.0f - 2.25f / 2.0f;
|
||||||
|
xRelativeToRight -= (xRelativeToRight + 2.25f / 2.0f) % 2.25f;
|
||||||
|
newX = xRelativeToRight + Width / 2.0f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
float xRelativeToLeft = newX + Width / 2.0f;
|
||||||
|
xRelativeToLeft -= (xRelativeToLeft + 2.25f / 2.0f) % 2.25f;
|
||||||
|
newX = xRelativeToLeft - Width / 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
newPosition = new Vector3(newX,
|
newPosition = new Vector3(newX,
|
||||||
newPosition.y, newPosition.z);
|
newPosition.y, newPosition.z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (spot.Size < newSize) {
|
||||||
else if (spot.Size < newSize) {
|
float spotBorder;
|
||||||
float spotBorder;
|
float thisSizeOffset;
|
||||||
float thisSizeOffset;
|
if (spot.Perpendicular)
|
||||||
if (spot.Perpendicular)
|
thisSizeOffset = _spotHeights[size] / 2.0f;
|
||||||
thisSizeOffset = _spotHeights[size] / 2.0f;
|
else
|
||||||
else
|
thisSizeOffset = 2.25f / 2.0f;
|
||||||
thisSizeOffset = 2.25f / 2.0f;
|
if (!spot.AlignToTop)
|
||||||
if (!spot.AlignToTop)
|
spotBorder = newPosition.y + thisSizeOffset;
|
||||||
spotBorder = newPosition.y + thisSizeOffset;
|
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,
|
spot.Size,
|
||||||
spot.Size,
|
true);
|
||||||
true);
|
if (nextBorderRight - nextBorderLeft < _spotHeights[(int) newSize] + 1f) {
|
||||||
if (nextBorderRight - nextBorderLeft < _spotHeights[(int) newSize] + 1f) {
|
// Try perpendicular
|
||||||
// Try perpendicular
|
float bottomBorder = newPosition.y - 2.25f / 2.0f;
|
||||||
float bottomBorder = newPosition.y - 2.25f / 2.0f;
|
float topBorder = newPosition.y + 2.25f / 2.0f;
|
||||||
float topBorder = newPosition.y + 2.25f / 2.0f;
|
bool foundByRemoval = false;
|
||||||
bool foundByRemoval = false;
|
if (spot.AlignToTop) {
|
||||||
if (spot.AlignToTop) {
|
float newBottomBorder = topBorder - _spotHeights[size];
|
||||||
float newBottomBorder = topBorder - _spotHeights[size];
|
float newTopBorder = topBorder;
|
||||||
float newTopBorder = topBorder;
|
float nextBorder = GetNextBorderVectical(newPosition, spot.Lane, spot.Perpendicular,
|
||||||
float nextBorder = GetNextBorderVectical(newPosition, spot.Lane, spot.Perpendicular,
|
newSize,
|
||||||
newSize,
|
!spot.AlignToTop);
|
||||||
!spot.AlignToTop);
|
if (Math.Abs(nextBorder - newBottomBorder) < 5.5f) {
|
||||||
if (Math.Abs(nextBorder - newBottomBorder) < 5.5f) {
|
if (i < currentLaneSpots.Count - 1) {
|
||||||
if (i < currentLaneSpots.Count - 1) {
|
Spot nextSpot = currentLaneSpots[i + 1];
|
||||||
Spot nextSpot = currentLaneSpots[i + 1];
|
if (nextSpot.Free && !nextSpot.Reserved) {
|
||||||
if (nextSpot.Free && !nextSpot.Reserved) {
|
Destroy(nextSpot.GameObject);
|
||||||
Destroy(nextSpot.GameObject);
|
currentLaneSpots.RemoveAt(i + 1);
|
||||||
currentLaneSpots.RemoveAt(i + 1);
|
i--;
|
||||||
i--;
|
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;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
float newBottomBorder = bottomBorder;
|
||||||
|
float newTopBorder = bottomBorder + _spotHeights[size];
|
||||||
|
float nextBorder = GetNextBorderVectical(newPosition, spot.Lane, spot.Perpendicular,
|
||||||
|
newSize,
|
||||||
|
!spot.AlignToTop);
|
||||||
|
if (Math.Abs(newTopBorder - nextBorder) < 5.5f) {
|
||||||
|
if (i < currentLaneSpots.Count - 1) {
|
||||||
|
Spot nextSpot = currentLaneSpots[i + 1];
|
||||||
|
if (nextSpot.Free && !nextSpot.Reserved) {
|
||||||
|
Destroy(nextSpot.GameObject);
|
||||||
|
currentLaneSpots.RemoveAt(i + 1);
|
||||||
|
i--;
|
||||||
|
newPosition.x = nextBorderRight - _spotHeights[(int) newSize] - 0.5f;
|
||||||
|
newPosition.y = position.y;
|
||||||
|
foundByRemoval = true;
|
||||||
|
}else
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundByRemoval) {
|
||||||
|
|
||||||
|
newPosition.y = bottomBorder + _spotHeights[(int) newSize] / 2.0f;
|
||||||
|
float newX = nextBorderRight;
|
||||||
|
if (spot.Lane == 0) {
|
||||||
|
float xRelativeToRight = -(newX - Width / 2.0f);
|
||||||
|
xRelativeToRight -= (xRelativeToRight + 2.25f / 2.0f) % 2.25f;
|
||||||
|
xRelativeToRight += 2.25f;
|
||||||
|
xRelativeToRight = Math.Max(xRelativeToRight, 2.25f / 2.0f);
|
||||||
|
newX = -xRelativeToRight + Width / 2.0f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
float xRelativeToLeft = newX + Width / 2.0f;
|
||||||
|
xRelativeToLeft -= (xRelativeToLeft + 2.25f / 2.0f) % 2.25f;
|
||||||
|
newX = xRelativeToLeft - Width / 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (spot.Lane == 0 && Width / 2.0f - newX < 5.5f + 0.5f + 2.25f) {
|
||||||
|
// Try to remove one spot next
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
newPosition.x = newX;
|
||||||
|
spot.Flipped = currentLaneSpots.FindIndex(spotPredicate => spotPredicate == spot) %
|
||||||
|
2 == 0;
|
||||||
|
rotation *= Quaternion.Euler(0, 0, spot.Flipped ? 90 : -90);
|
||||||
|
spot.Perpendicular = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
float newBottomBorder = bottomBorder;
|
newPosition.x = nextBorderRight - _spotHeights[(int) newSize] / 2.0f - 0.5f;
|
||||||
float newTopBorder = bottomBorder + _spotHeights[size];
|
if (i == 0)
|
||||||
float nextBorder = GetNextBorderVectical(newPosition, spot.Lane, spot.Perpendicular,
|
newPosition.x += 0.5f;
|
||||||
newSize,
|
newPosition.y = position.y;
|
||||||
!spot.AlignToTop);
|
|
||||||
if (Math.Abs(newTopBorder - nextBorder) < 5.5f) {
|
// if (i < currentLaneSpots.Count - 1) {
|
||||||
if (i < currentLaneSpots.Count - 1) {
|
// Spot nextSpot = currentLaneSpots[i + 1];
|
||||||
Spot nextSpot = currentLaneSpots[i + 1];
|
// if (nextSpot.Free && !nextSpot.Reserved) {
|
||||||
if (nextSpot.Free && !nextSpot.Reserved) {
|
// Destroy(nextSpot.GameObject);
|
||||||
Destroy(nextSpot.GameObject);
|
// currentLaneSpots.RemoveAt(i + 1);
|
||||||
currentLaneSpots.RemoveAt(i + 1);
|
// i--;
|
||||||
i--;
|
// newPosition.x = nextBorderRight - _spotHeights[(int) newSize] - 0.5f;
|
||||||
newPosition.x = nextBorderRight - _spotHeights[(int) newSize] - 0.5f;
|
// newPosition.y = position.y;
|
||||||
newPosition.y = position.y;
|
// continue;
|
||||||
foundByRemoval = true;
|
// }
|
||||||
}else
|
// }
|
||||||
continue;
|
// newPosition.x = nextBorderRight - _spotHeights[(int) newSize] - 0.5f;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundByRemoval) {
|
|
||||||
|
|
||||||
newPosition.y = bottomBorder + _spotHeights[(int) newSize] / 2.0f;
|
|
||||||
float newX = nextBorderRight;
|
|
||||||
if (spot.Lane == 0) {
|
|
||||||
float xRelativeToRight = -(newX - Width / 2.0f);
|
|
||||||
xRelativeToRight -= (xRelativeToRight + 2.25f / 2.0f) % 2.25f;
|
|
||||||
xRelativeToRight += 2.25f;
|
|
||||||
xRelativeToRight = Math.Max(xRelativeToRight, 2.25f / 2.0f);
|
|
||||||
newX = -xRelativeToRight + Width / 2.0f;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
float xRelativeToLeft = newX + Width / 2.0f;
|
|
||||||
xRelativeToLeft -= (xRelativeToLeft + 2.25f / 2.0f) % 2.25f;
|
|
||||||
newX = xRelativeToLeft - Width / 2.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (spot.Lane == 0 && Width / 2.0f - newX < 5.5f + 0.5f + 2.25f) {
|
|
||||||
// Try to remove one spot next
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newPosition.x = newX;
|
|
||||||
spot.Flipped = currentLaneSpots.FindIndex(spotPredicate => spotPredicate == spot) %
|
|
||||||
2 == 0;
|
|
||||||
rotation *= Quaternion.Euler(0, 0, spot.Flipped ? 90 : -90);
|
|
||||||
spot.Perpendicular = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
newPosition.x = nextBorderRight - _spotHeights[(int) newSize] / 2.0f - 0.5f;
|
|
||||||
if (i == 0)
|
|
||||||
newPosition.x += 0.5f;
|
|
||||||
newPosition.y = position.y;
|
|
||||||
|
|
||||||
// if (i < currentLaneSpots.Count - 1) {
|
|
||||||
// Spot nextSpot = currentLaneSpots[i + 1];
|
|
||||||
// if (nextSpot.Free && !nextSpot.Reserved) {
|
|
||||||
// Destroy(nextSpot.GameObject);
|
|
||||||
// currentLaneSpots.RemoveAt(i + 1);
|
|
||||||
// i--;
|
|
||||||
// newPosition.x = nextBorderRight - _spotHeights[(int) newSize] - 0.5f;
|
|
||||||
// newPosition.y = position.y;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// newPosition.x = nextBorderRight - _spotHeights[(int) newSize] - 0.5f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Destroy(spot.GameObject);
|
Destroy(spot.GameObject);
|
||||||
spot.Size = (Size) size;
|
spot.Size = (Size) size;
|
||||||
spot.Reserved = false;
|
spot.Reserved = false;
|
||||||
spot.GameObject = Instantiate(_spotPrefabs[size],
|
spot.GameObject = Instantiate(_spotPrefabs[size],
|
||||||
newPosition, rotation, mainPlanContainer);
|
newPosition, rotation, mainPlanContainer);
|
||||||
spot.LastReconfiguration = _currentTime;
|
spot.LastReconfiguration = _currentTime;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -545,6 +546,9 @@ 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)
|
||||||
|
allBorders.Add(Height / 2.0f - 5);
|
||||||
|
|
||||||
if (allBorders.Count == 0)
|
if (allBorders.Count == 0)
|
||||||
return up ? Height / 2.0f : -Height / 2.0f;
|
return up ? Height / 2.0f : -Height / 2.0f;
|
||||||
@ -717,9 +721,12 @@ namespace Parking
|
|||||||
Quaternion.Euler(new Vector3(0, 0, (spotMap[i][j].Flipped ? 180 : 0) + 90));
|
Quaternion.Euler(new Vector3(0, 0, (spotMap[i][j].Flipped ? 180 : 0) + 90));
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user