コード例 #1
0
    //Save main info trial
    public static void MainObjInfo(GameObject obj) {
        string tagObj = obj.tag;
        if (tagObj == "Player" && CollectionObjs.trial_t == 0.0f)
        {
            info = new SubjTrialInfo.InfoTrial();
            info.ID = "Start Position Player";
            info.s_x = obj.transform.position.x;
            info.s_y = obj.transform.position.y;
            info.s_z = obj.transform.position.z;
            info.time = CollectionObjs.trial_t;
            CollectionObjs.trialInfo.Add(info);
        }
        else if (tagObj == "TreasureChest")
        {
            info = new SubjTrialInfo.InfoTrial();
            info.ID = "Start Position Treasure";
            info.s_x = obj.transform.position.x;
            info.s_y = obj.transform.position.y;
            info.s_z = obj.transform.position.z;
            info.time = CollectionObjs.trial_t;
            CollectionObjs.trialInfo.Add(info);
        }
        else if (tagObj == "Gem")
        {
            info = new SubjTrialInfo.InfoTrial();
            info.ID = "Gem" + count;
            info.s_x = obj.transform.position.x;
            info.s_y = obj.transform.position.y;
            info.s_z = obj.transform.position.z;
            info.time = CollectionObjs.collision_t;
            CollectionObjs.trialInfo.Add(info);
            count++;
        }
        else {
            info = new SubjTrialInfo.InfoTrial();
            info.ID = "Player"+playerCount;
            info.s_x = obj.transform.position.x;
            info.s_y = obj.transform.position.y;
            info.s_z = obj.transform.position.z;
            info.time = CollectionObjs.trial_t;
            CollectionObjs.trialInfo.Add(info);
            playerCount++;
        }

    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        //Timer
        trial_t += Time.deltaTime;
        if (score == menuscore)
        {
            treasure.SetActive(false);
            //Check if the user pressed the button
            checkbutton = OnButtonPression();
            if (checkbutton == true)
            {
                //if true saves the position and the time
                trial_position.Add(player.transform.position);
                collision_t.Add(trial_t);
                try
                {
                    isSaving = true;
                    SubjTrialInfo.InfoTrial infotrial;
                    foreach (Vector3 v in trial_position)
                    {
                        infotrial = new SubjTrialInfo.InfoTrial();
                        infotrial.ID = objnames[i];
                        infotrial.s_x = v.x;
                        infotrial.s_y = v.y;
                        infotrial.s_z = v.z;
                        if (i == 0)
                        {

                            infotrial.time = 0;
                        }
                        else {

                            infotrial.time = collision_t[i-1];

                        }

                        EndTrialInfo.Add(infotrial);
                        i++;
                    }
                    _data = SerializeObject(EndTrialInfo);
                    //Creates xml file with all the info of the trial
                    CreateXML();
                    Debug.Log("Data Saved");
                    PlayerInfo.PathMapping overallpath;
                    foreach (Vector3 v in PathIntegration.subpath)
                    {
                        overallpath = new PlayerInfo.PathMapping();
                        overallpath.s_x = v.x;
                        overallpath.s_y = v.y;
                        overallpath.s_z = v.z;
                        overallpath.r_x = PathIntegration.p_rotation[asd].x;
                        overallpath.r_y = PathIntegration.p_rotation[asd].y;
                        overallpath.r_z = PathIntegration.p_rotation[asd].z;
                        overallpath.t = PathIntegration.p_time[asd];
                        TrialPath.Add(overallpath);
                        asd++;
                    }
                    _data = SerializeObject(TrialPath);
                    //Creates xml file with all the info of the trial
                    CreateXML();
                    Debug.Log("Data Saved");
                }
                catch (System.Exception ex)
                {
                    Debug.LogError(ex.ToString());
                }
                finally
                {
                    isSaving = false;
                }
                //Loads next trial
                Application.LoadLevel(3);
            }
        }
    }