/// <summary>
    /// Start a new block while we have not surpassed the block limit we set. If we have surpassed our block limit,
    /// the experiment will end
    /// </summary>
    private void StartNextBlock()
    {
        // Debug.Log("Current Block number is: " + _currentBlockNumber);
        if (_currentBlockNumber < numberOfBlocks)
        {
            // Reset our _currentTaskNumber to 0 by calling the method ResetTaskNumber()
            ResetTaskNumber();
            _isBlockRunning = true;
            _currentBlockNumber++;
            sequenceGenerator.SetSequenceLength(_sequenceLength++);
            StartNextTask();
        }
        else
        {
            ShowMessage("THE END... Now please add your credit card number... for a... prize?");
            // Generating and saving a csv file with all the collected data
            List <string> csvLines = CSVTools.GenerateCSV(_data, _csvHeaders);
            foreach (string line in csvLines)
            {
                Debug.Log(line);
            }

            CSVTools.SaveCSV(csvLines, Application.dataPath + "/Data/" + GUID.Generate());
        }
    }
Пример #2
0
        public static void ProcessData(string verzeichnisMessdaten, string verzeichnisCSV)
        {
            var messwerte             = MessdatenReader.ReadMesswerte(verzeichnisMessdaten, "*.PRA");
            var messwerteProMesspunkt = MessdatenReader.MesswerteAufbereiten(messwerte);

            CSVTools.ExportToCSV(messwerteProMesspunkt, verzeichnisCSV);
        }
Пример #3
0
        private static void Csv2Bezier()
        {
            if (Selection.objects.Length == 0)
            {
                Debug.Log("请选择csv文件");
                return;
            }

            var data   = CSVTools.Read(AssetDatabase.GetAssetPath(Selection.objects[0]), Encoding.UTF8);
            var bezier = CreateInstance <BezierSpline>();

            for (int i = 0; i < data.Count; i++)
            {
                var p = new BezierPoint(new Vector3(
                                            Convert.ToFloat(data[i][0]),
                                            Convert.ToFloat(data[i][1]),
                                            Convert.ToFloat(data[i][2])
                                            ));
                p.HandleR = new Vector3(
                    Convert.ToFloat(data[i][3]),
                    Convert.ToFloat(data[i][4]),
                    Convert.ToFloat(data[i][5])
                    ) + p.Position;
                p.Percent = Convert.ToFloat(data[i][6]);
                bezier.Add(p);
            }
            var path = AssetDatabase.GetAssetPath(Selection.objects[0]);

            path = Path.ChangeExtension(path, "asset");
            AssetDatabase.CreateAsset(bezier, path);
            Debug.Log(path);
            AssetDatabase.Refresh();
        }
Пример #4
0
        public static void SaveLocalizationFile(string lang, Dictionary <string, string> values = null)
        {
            List <string[]> lines = new List <string[]>()
            {
                new string[] { "id", "value" }
            };

            if (values != null)
            {
                foreach (KeyValuePair <string, string> value in values)
                {
                    lines.Add(new string[] { value.Key, value.Value });
                }
            }
            CSVTools.Write(Localizator.Path.DatabaseRootPath + lang + ".csv", lines);

            SaveWorkspace();
        }
        public void LoadFiles()
        {
            _rootLines     = new List <string>();
            _languageLines = new Dictionary <string, string>();

            if (!File.Exists(Localizator.Path.DatabaseRootPath + "Root.csv") || !File.Exists(Localizator.Path.DatabaseRootPath + CurrentLang + ".csv"))
            {
                Close();
            }
            else
            {
                _rootLines = new List <string>(File.ReadAllLines(Localizator.Path.DatabaseRootPath + "Root.csv"));
                List <string[]> langLines = CSVTools.Read(Localizator.Path.DatabaseRootPath + CurrentLang + ".csv");

                _languageLines.Clear();
                for (int i = 1; i < langLines.Count; ++i)
                {
                    _languageLines.Add(langLines[i][0], langLines[i][1]);
                }
            }
        }
Пример #6
0
        private static void Bezier2Csv()
        {
            if (Selection.objects.Length == 0)
            {
                Debug.Log("请选择Bezier文件");
                return;
            }

            var bezier = Selection.objects[0] as BezierSpline;

            if (bezier != null)
            {
                var map = new List <IList <string> >();
                for (int i = 0; i < bezier.Count; i++)
                {
                    var p   = bezier[i];
                    var pd  = p.HandleR - p.Position;
                    var pt  = p.Percent;
                    var row = new string[]
                    {
                        p.Position.x.ToString(),
                        p.Position.y.ToString(),
                        p.Position.z.ToString(),
                        pd.x.ToString(),
                        pd.y.ToString(),
                        pd.z.ToString(),
                        pt.ToString(),
                    };
                    map.Add(row);
                }
                var path = Path.GetFullPath(AssetDatabase.GetAssetPath(Selection.objects[0]));
                path = Path.ChangeExtension(path, "csv");
                CSVTools.Write(path, Encoding.UTF8, map);
                Debug.Log(path);
                AssetDatabase.Refresh();
            }
        }
Пример #7
0
    // Update is called once per frame
    /// <summary>
    /// controls the game: checks if targets are met at the same time, starts new rounds and resets the game, computes the time, computes csv file
    /// </summary>
    void Update()
    {
        // Delay in loading
        // so save the delay to subtract from measurements
        if (start)
        {
            _helperTime2 = Time.realtimeSinceStartup;
            start        = false;
        }

        // if there is only supposed to be one round, do not go into the next if case, but in the one for the "last" round
        if (roundsToPlay == 1)
        {
            _toControlLoop = false;
        }

        // if both targets are met at the same time
        if (_blue && _orange && _toControlLoop)
        {
            //we compute the time needed for each round
            _helperTime  = _finalTime;
            Helper2Time  = _helperTime2;
            _finalTime   = Time.realtimeSinceStartup;
            _finalTime   = _finalTime - Helper2Time;
            _helperTime2 = _helperTime2 + _finalTime;
            Helper2Time  = _helperTime2;

            //as long as not all rounds are played
            if (_currentRound < roundsToPlay)
            {
                // we say that one round is finished
                Debug.Log("You made it through one round, you good Mauwuffen!");
                Debug.Log("You mastered the Labyrinth in " + _finalTime + " seconds!");

                // we also tell that to the applicant
                beginText.text = "You Made It Through Round " + _currentRound + "!";

                //we save the data from the data point of that round
                AddToList();

                // we reset the game in order to start a new round
                ResetGame();

                // we set _currentRound to the next round
                _currentRound++;

                //_toControlLoop is true as long as there is another round to play
                _toControlLoop = (_currentRound < roundsToPlay);
            }
        }
        // when both balls hit the target but there is not another round to play ("last" round)
        else if (_blue && _orange)
        {
            // we again compute the time needed to finish the game
            _helperTime  = _finalTime;
            Helper2Time  = _helperTime2;
            _finalTime   = Time.realtimeSinceStartup;
            _finalTime   = _finalTime - Helper2Time;
            _helperTime2 = _helperTime2 + _finalTime;
            Helper2Time  = _helperTime2;

            // there is no next round
            if (_currentRound == roundsToPlay)
            {
                // we say that the applicant is finished
                Debug.Log("You made it through one round, you good Mauwuffen!");
                Debug.Log("You mastered the Labyrinth in " + _finalTime + " seconds!");

                //we set _currentRound to next round so that the loop stops
                _currentRound++;

                // we save our datapoint data from the last round
                AddToList();

                // because there are no rounds left, we convert our whole data in csv file format
                _test = CSVTools.CreateCsv(_data, _ourHeader);

                // we show the data on the console for us
                foreach (string row in _test)
                {
                    Debug.Log(row);
                }

                // now we save our data in a csv file
                CSVTools.SaveData(_test, Application.dataPath + "/Data/" + GUID.Generate());
            }

            // we tell the participant that the Experiment ended and to end it with Key "O"
            beginText.text = "You did it! Press O to stop the Experiment!";

            if (Input.GetKeyDown(KeyCode.O))
            {
                UnityEditor.EditorApplication.isPlaying = false;
            }
        }
    }