private void PopulateFileList(string folderpath) { List <string> filenames = ReplUtils.GetSaveFileNames(folderpath); if (folderpath != CurrentFolderPath) { RemoveFileIcons(); for (int i = 0; i < filenames.Count; i++) { GameObject file = Instantiate(FileIcon, ItemsWindow.transform); var textcomponent = file.GetComponentInChildren <TMP_Text>(); textcomponent.text += filenames[i]; file.GetComponentInChildren <Button>().onClick.AddListener(delegate { IsReplayRun = true; Time.timeScale = speed; ReplayComponent.LoadReplay(Path.Combine(folderpath, textcomponent.text)); }); FileItems.Add(file); } CurrentFolderPath = folderpath; } else { ShowFileIcons(); } }
public void LoadReplay(string name) { List <List <List <Vector3> > > data; ReplUtils.LoadSimmulation(name, out data, out ScoreList); PopulationComponent.SetDNA(data); SceneManager.LoadScene(SceneManager.GetActiveScene().name); }
private void CreateCurrentFolder() { string uniquename = Guid.NewGuid().ToString(); string path = Path.Combine(UnityEngine.Application.persistentDataPath, uniquename); Directory.CreateDirectory(path); ReplUtils.AssignCurrentFolder(path); }
private void OpenLoadTab() { Time.timeScale = 0f; if (FolderItems.Count == 0) { string[] folderpaths = ReplUtils.GetFolderNames(); PopulateFolderList(folderpaths); } else { ShowFolderIcons(); } SavePanel.SetActive(true); ResumeButton.gameObject.SetActive(true); LoadButton.gameObject.SetActive(false); }
void Start() { Init(); ResetMenus(); if (IsReplayRun) { TriggerReplayMenu(); } else { TriggerGeneralMenu(); if (!ReplUtils.IsCreated_Folder()) { CreateCurrentFolder(); } } }
IEnumerator Coordinate() { GeneticOperationsComponent.SetPopulationDNA(PopulationComponent.GetPopulationDNA()); List <List <List <Vector3> > > DnaFromNextGen = new List <List <List <Vector3> > >(); while (!ReadyToGo()) { yield return(null); } StartSimulation(); EvalComponent.SetHeadPositionY(PopulationComponent.GetHeadPositionY()); EvalComponent.SetFootPositionY(PopulationComponent.GetFootPositionY()); while (!EvalComponent.done) { yield return(new WaitForSeconds(0.5f)); } ReplUtils.SaveSimmulation(PopulationComponent.GetPopulationDNA(), EvalComponent.GetFitnessList(), simcounter); GeneticOperationsComponent.ComputeNextGeneration(EvalComponent.GetFitnessList(), out DnaFromNextGen); PopulationComponent.SetDNA(DnaFromNextGen); ResetState(); simcounter++; }