49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using TMPro;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class DataImporter
|
||
|
{
|
||
|
public static List<Driver> Drivers = new List<Driver>();
|
||
|
|
||
|
public static void ReadFile(string path)
|
||
|
{
|
||
|
string fileData = System.IO.File.ReadAllText(path);
|
||
|
String[] lines = fileData.Split("\n"[0]);
|
||
|
int counter = 0;
|
||
|
foreach (string line in lines)
|
||
|
{
|
||
|
if (counter == 0)
|
||
|
{
|
||
|
counter++;
|
||
|
continue;
|
||
|
}
|
||
|
String[] lineData = (line.Trim()).Split(',');
|
||
|
ParkingPreference preference = (lineData[0] == "" ? ParkingPreference.Any : (lineData[0] == "P" ? ParkingPreference.Front : ParkingPreference.Back));
|
||
|
Size size;
|
||
|
switch (lineData[1])
|
||
|
{
|
||
|
case "Mały":
|
||
|
size = Size.A;
|
||
|
break;
|
||
|
case "Średni":
|
||
|
size = Size.B;
|
||
|
break;
|
||
|
case "Duży":
|
||
|
size = Size.C;
|
||
|
break;
|
||
|
case "Max":
|
||
|
size = Size.D;
|
||
|
break;
|
||
|
default:
|
||
|
size = Size.A;
|
||
|
break;
|
||
|
}
|
||
|
Drivers.Add(new(size, counter, preference));
|
||
|
// float.TryParse(lineData[0], x);
|
||
|
counter++;
|
||
|
}
|
||
|
}
|
||
|
}
|