コード例 #1
0
 public void Begin(int phaseNum, int sceneNum, bool vrEnabled, string configFile)
 {
     UnityEngine.XR.XRSettings.enabled = vrEnabled;
     PlayerPrefs.SetString(ConfigurationFileLoader.configFilePlayerPrefsString, configFile);
     SetPlayerPrefValues(phaseNum);
     ConfigurationFileLoader.Init();
     SceneManager.LoadScene(sceneNum);
 }
コード例 #2
0
        public static Stage LoadStageFromFile(string file_name)
        {
            //Create an empty stage that will be our result
            Stage result = new Stage();

            //Grab all the lines from the file
            var file_lines = ConfigurationFileLoader.LoadConfigurationFile(file_name);

            for (int i = 0; i < file_lines.Count; i++)
            {
                var this_line = file_lines[i].Trim();
                if (this_line.Equals("BEGIN STAGE"))
                {
                    var file_lines_to_use = file_lines.GetRange(i + 1, file_lines.Count - i - 1).ToList();

                    //Parse the rest of the lines of the file
                    if (file_lines_to_use.Count > 0)
                    {
                        //Create a root phase node
                        PhaseNode root = new PhaseNode()
                        {
                            Command = "root"
                        };

                        //Structure the list of commands
                        StructurePhases(file_lines_to_use, 0, root);

                        //Expand the phase node structure by instantiating each phase and putting them into a flat list
                        ExpandPhaseNodes(result.StageSegments, null, root);
                    }

                    //Break out of the loop. We are done.
                    break;
                }
                else
                {
                    var line_parts = this_line.Split(new char[] { ':' }, 2).ToList();
                    if (line_parts.Count >= 2)
                    {
                        var param_name = line_parts[0].Trim();
                        var param_val  = line_parts[1].Trim();

                        if (param_name.Equals("Stage Name"))
                        {
                            result.StageName = param_val;
                        }
                        else if (param_name.Equals("Stage Description"))
                        {
                            result.StageDescription = param_val;
                        }
                    }
                }
            }

            //Return the new stage
            return(result);
        }
        public void LoadLanguageDictionaries()
        {
            List <LanguageDictionary> result = new List <LanguageDictionary>();
            var all_dictionary_files         = Directory.GetFiles(ResourcesFolder + DictionaryPath);

            foreach (var f in all_dictionary_files)
            {
                //Get the file info for this file
                FileInfo f_info = new FileInfo(f);

                //Instantiate a new language dictionary object
                LanguageDictionary d = new LanguageDictionary();

                string        filename        = Path.GetFileNameWithoutExtension(f_info.Name);
                List <string> separated_parts = filename.Split(new char[] { '_' }).ToList();

                d.ForeignLanguageName = separated_parts[0].ToLower();
                if (separated_parts.Count >= 3)
                {
                    d.NativeLanguageName = separated_parts[2].ToLower();
                }
                else
                {
                    d.NativeLanguageName = "english";
                }

                if (separated_parts.Count >= 4)
                {
                    d.MetaData = separated_parts[3].ToLower();
                }

                //Load the dictionary file
                List <string> file_lines = ConfigurationFileLoader.LoadConfigurationFile(f);
                for (int i = 0; i < file_lines.Count; i++)
                {
                    string   this_line    = file_lines[i];
                    string[] split_string = this_line.Split(new char[] { '\t' }, 2);
                    string   key          = split_string[0].Trim();
                    string   value        = split_string[1].Trim();

                    d.DictionaryWordPairs.Add(new Tuple <string, string>(key, value));
                }

                result.Add(d);
            }

            //Set the class property with the result
            LanguageDictionaries = result;
        }
        public void LoadConfigurationFile()
        {
            //Load the configuration file
            List <string> file_lines = ConfigurationFileLoader.LoadConfigurationFile(ResourcesFolder + ConfigurationFileName);

            //Iterate through each line and parse out the data
            for (int i = 0; i < file_lines.Count; i++)
            {
                string   this_line    = file_lines[i];
                string[] split_string = this_line.Split(new char[] { ':' }, 2);
                string   key          = split_string[0].Trim();
                string   value        = split_string[1].Trim();

                if (key.Equals("Primary Save Path", StringComparison.InvariantCultureIgnoreCase))
                {
                    PrimarySavePath = value;
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Loads data from a previously created human subject.
        /// </summary>
        public static HumanSubject LoadHumanSubject(string username)
        {
            HumanSubject s = new HumanSubject();

            //Construct a file name to load
            string file_name = username + ".txt";

            //Construct a full path and file
            string fully_qualified_path = HumanAcceleratedLearningConfiguration.GetInstance().PrimarySavePath + file_name;

            //Check to see if the patient data file exists
            FileInfo info = new FileInfo(fully_qualified_path);

            //If the patient data file exists...
            if (info.Exists)
            {
                //Read the contents of the file
                List <string> lines = ConfigurationFileLoader.LoadFileLines(fully_qualified_path);

                //Read the user name
                s.UserName = lines[0].Trim();

                //Read the participant's start date
                double matlab_datenum = 0;
                bool   success        = Double.TryParse(lines[1], out matlab_datenum);
                if (success)
                {
                    s.StartDate = MathHelperMethods.ConvertMatlabDatenumToDateTime(matlab_datenum);
                }

                //Now read the order of the participant's segments
                for (int i = 2; i < lines.Count; i++)
                {
                    s.SegmentOrder.Add(lines[i].Trim());
                }
            }

            return(s);
        }