Added filepath panel

This commit is contained in:
Dawid Pietrykowski 2022-09-07 21:47:41 +02:00
parent 0fab824709
commit 3270cc0b10
4 changed files with 1232 additions and 10 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace Parking
{
@ -9,8 +10,10 @@ namespace Parking
{
public static List<Driver> Drivers = new();
public static void ReadFile(string path)
public static bool ReadFile(string path)
{
if (!File.Exists(path))
return false;
string fileData = File.ReadAllText(path);
string[] lines = fileData.Split("\n"[0]);
int counter = 0;
@ -70,6 +73,7 @@ namespace Parking
counter++;
}
return true;
}
}
}

View File

@ -21,6 +21,9 @@ namespace Parking
[SerializeField] private TextMeshProUGUI timeText;
[SerializeField] public TextMeshProUGUI countsText;
[SerializeField] public TextMeshProUGUI rejectedText;
[SerializeField] public TextMeshProUGUI pathText;
[SerializeField] public GameObject startPanel;
[SerializeField] public GameObject notFoundPanel;
[SerializeField] public GameObject spotPrefabA;
[SerializeField] public GameObject spotPrefabB;
[SerializeField] public GameObject spotPrefabC;
@ -49,13 +52,26 @@ namespace Parking
private void Start()
{
_spotPrefabs = new List<GameObject> {spotPrefabA, spotPrefabB, spotPrefabC, spotPrefabD};
}
public void ReadDataButtonClick()
{
if (!DataImporter.ReadFile(pathText.text.Replace("\u200B", ""))) {
notFoundPanel.SetActive(true);
return;
}
InitiateManager();
startPanel.SetActive(false);
}
private void InitiateManager()
{
timeText.text = _currentTime.ToString();
rejectedText.text = $"Małe: {_rejectedDrivers[0]} Średnie: {_rejectedDrivers[1]} " +
$"Duże: {_rejectedDrivers[2]}";
GenerateEmergencyPlan();
DataImporter.ReadFile("Assets/Data/Tablica4.csv");
InitialConfigurationGenerator generator = new();
_initialSolution = generator.FindSolution();
ArrangeSpots(_initialSolution);

File diff suppressed because one or more lines are too long