示例#1
0
    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();
        }
    }
示例#2
0
    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);
    }
示例#3
0
    private void CreateCurrentFolder()
    {
        string uniquename = Guid.NewGuid().ToString();
        string path       = Path.Combine(UnityEngine.Application.persistentDataPath, uniquename);

        Directory.CreateDirectory(path);
        ReplUtils.AssignCurrentFolder(path);
    }
示例#4
0
 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);
 }
示例#5
0
 void Start()
 {
     Init();
     ResetMenus();
     if (IsReplayRun)
     {
         TriggerReplayMenu();
     }
     else
     {
         TriggerGeneralMenu();
         if (!ReplUtils.IsCreated_Folder())
         {
             CreateCurrentFolder();
         }
     }
 }
示例#6
0
    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++;
    }