Exemplo n.º 1
0
    public static SaveDataClass SaveDungeonStructure(GameObject _spawner)
    {
        var result = new SaveDataClass();

        result.amountOfRooms = _spawner.transform.childCount;

        for (int i = 0; i < _spawner.transform.childCount; i++)
        {
            GameObject child = _spawner.transform.GetChild(i).gameObject;
        }

        return(result);
    }
Exemplo n.º 2
0
    public void ConvertToJSON(SaveDataClass _saveData)
    {
        string fileName;

        if (saveName.text == "" || saveName.text == null)
        {
            fileName = "saveData" + DateTime.Now.ToString("dd-MM-yyyy") + ".JSON";
        }
        else
        {
            fileName = saveName.text + ".JSON";
        }
        System.IO.File.WriteAllText("Assets/Resources/LevelData/" + fileName, JsonUtility.ToJson(_saveData, false));
    }
Exemplo n.º 3
0
    public void ResetEdit()
    {
        if (saveDataClass != null)
        {
            saveDataClass = null;
        }
        var blocks = GameObject.FindGameObjectsWithTag("EditBlock");

        foreach (var block in blocks)
        {
            Destroy(block);
        }
        InitializeChara_Goal();
    }
Exemplo n.º 4
0
    //marks GameManager so it persists/is the only instance, load into the first scene of the game
    private void Awake()
    {
        //if this is the first (and only) instance, set up the game manager
        if (Instance == null)
        {
            //make it persistent
            Instance = this;
            DontDestroyOnLoad(gameObject);

            //checks if there's a file storing gameslot basic information and if not creates and saves a default one
            basePersistentFilePath = Application.persistentDataPath;
            string baseSaveSlotDataFileName = "baseSaveSlotDataFileName" + fileExtensionType;
            combinedBaseSaveSlotDataFilePath = Path.Combine(basePersistentFilePath, baseSaveSlotDataFileName);
            gamePlayedBefore = File.Exists(combinedBaseSaveSlotDataFilePath);

            if (gamePlayedBefore)
            {   //load the file storing the names of the save slots becuase we know it exists
                baseSaveSlotDataClassInstance = SaveGame.Load <BaseSaveSlotDataClass>(combinedBaseSaveSlotDataFilePath, new BaseSaveSlotDataClass());

                //load the file storing user control preferences because we know they've played before
                string controlsFileName = controlsFileNameMinusExtension + fileExtensionType;
                fullControlsFilePath = Path.Combine(basePersistentFilePath, controlsFileName);
                saveDataForGameControlsClassInstanceForSaving = SaveGame.Load <SaveDataForGameControlsClass>(fullControlsFilePath, new SaveDataForGameControlsClass());

                //user save data class doesn't get instatiated yet because we don't know what save slot they want to load
            }

            //game was never played before so it doesn't have a file for the save file names created yet
            else
            {
                //spawn and save a file to keep track of the save slot names, set to default "Empty" for all of them
                baseSaveSlotDataClassInstance = new BaseSaveSlotDataClass();
                SaveGameSlotNames();

                //spawn and save a file to store user control preferences, set to control defaults so the game knows how to interpret buttons to start
                saveDataForGameControlsClassInstanceForSaving = new SaveDataForGameControlsClass();
                SaveGameControls();

                //spawn a location for save data, the save slot number and name will come once the player actually hits New game
                saveDataClassInstanceForSaving = new SaveDataClass();
            }
        }
        //somehow another game manager already exists so destroy this one
        else
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 5
0
    public static SaveDataClass SaveDungeonStructure(GameObject _spawner)
    {
        var result = new SaveDataClass();

        result.amountOfRooms = _spawner.transform.childCount;
        result.cRoomNodes    = new CompressedRoomNode[result.amountOfRooms];

        for (int i = 0; i < _spawner.transform.childCount; i++)
        {
            Doors childDoors = _spawner.transform.GetChild(i).gameObject.GetComponent <Doors>();
            result.cRoomNodes[i] = new CompressedRoomNode(childDoors.nodeData.interriorType, new Vector2(childDoors.nodeData.worldPos.x, childDoors.nodeData.worldPos.z), childDoors.doorDirections);

            Debug.Log(_spawner.transform.childCount);
        }

        return(result);
    }
    public void UserStudyButtonPressed()
    {
        handsManager.beginUserStudyButton.interactable = false;
        EventSystem.current.SetSelectedGameObject(null);
        resting = false;
        if (USER_STUDY_TECHNIQUE == -1)
        {
            initializeUserStudy();
            return;
        }



        if (!handsManager.instructionPanel.activeSelf)
        {
            int        index = hologramIndex;
            GameObject manipulatableObject = manipulatableGameObjects [index];
            GameObject targetObject        = targetGameObjects [index];

            // if we just did a manipulation, save the state
            if (justManipulated)
            {
                if (USER_STUDY_TECHNIQUE_INDEX < NUM_TECHNIQUES)
                {
                    SaveData(manipulatableObject, targetObject, false);


                    SaveDataClass data = new SaveDataClass(this);
                    data.setTransforms(manipulatableObject, targetObject);
                    data.continueButtonPress = true;
                    SaveDataExtended(data);

                    hideHologramAtIndex(index);
                }
                if (++hologramIndex == hologramCount)
                {
                    justRested    = false;
                    doPractice    = true;
                    hologramIndex = 0;
                    USER_STUDY_TECHNIQUE_INDEX++;
                    reset = false;
                    if (USER_STUDY_TECHNIQUE_INDEX != NUM_TECHNIQUES)
                    {
                        USER_STUDY_TECHNIQUE = techniquesPermuted[USER_STUDY_TECHNIQUE_INDEX];
                    }
                }
                else
                {
                    resetAndShowHologramAtIndex(hologramIndex, true);
                }
            }

            else if (showPracticeDoneInstruction)
            {
                showPracticeDoneInstruction = false;
                disableTimedButton          = false;
                // we just had a practice stage, show instructions about timed stage entering
                instructionSequence = COMPLETE_PRACTICE_SEQUENCE;
                handsManager.instructionTitleText.text = handsManager.techniqueNames[USER_STUDY_TECHNIQUE] + " Technique: Final Practice";
                handsManager.counter = 0;
                timeToWait           = 5;
                handsManager.userStudyOrientationText.text = "Final Practice on Object";
                showInstructions();
                resetAndShowHologramAtIndex(hologramIndex, false);
                disableImages = false;
                //Maybe save data here
                //saves the practice data
                SaveData(manipulatableObject, targetObject, true);

                int           numFrames = NUM_PRACTICE_FRAMES + 1;
                SaveDataClass data      = new SaveDataClass(this);
                data.continueButtonPress = true;
                data.training            = true;
                data.trainingSection     = numFrames.ToString();
                SaveDataExtended(data);

                return;
            }



            if (USER_STUDY_TECHNIQUE_INDEX < NUM_TECHNIQUES)
            {
                /*for (int i = 0; i < NUM_TECHNIQUES; i++) {
                 *      if(i != USER_STUDY_TECHNIQUE) {
                 *              handsManager.techniqueButtons[i].interactable = false;
                 *              handsManager.techniqueButtons[i].enabled = true;
                 *      } else {
                 *              handsManager.techniqueButtons[i].interactable = true;
                 *              handsManager.techniqueButtons[i].enabled = false;
                 *              handsManager.setTechnique(i + 1);
                 *      }
                 * }*/

                if (doPractice && USER_STUDY_TECHNIQUE_INDEX != NUM_TECHNIQUES)
                {
                    //completed a section
                    if (USER_STUDY_TECHNIQUE_INDEX != 0 && !justRested && !reset)
                    {
                        justRested = true;
                        int left = NUM_TECHNIQUES - USER_STUDY_TECHNIQUE_INDEX;
                        instructionSequence = REST_SEQUENCE;
                        hideAllHolograms();
                        string word = " section";
                        if (left != 1)
                        {
                            word += "s";
                        }
                        disableTimedButton = false;
                        int lastTechnique = techniquesPermuted [USER_STUDY_TECHNIQUE_INDEX - 1];
                        handsManager.instructionTitleText.text = handsManager.techniqueNames[lastTechnique] + " Technique: Section Complete";
                        disableImages = true;
                        handsManager.instructionTexts[REST_SEQUENCE] = "You have completed section " + USER_STUDY_TECHNIQUE_INDEX + ". You have " + left + word
                                                                       + " left to complete.\nPlease say the following code to the study administrator:\n\n\n" + handsManager.codes[lastTechnique] + "\n\n\nPlease carefully remove the hololens and fill out the questionnaire for this section.";
                        handsManager.counter = 0;
                        timeToWait           = 30;
                        showInstructions();
                        justManipulated = false;
                        resting         = true;
                        int seq = USER_STUDY_TECHNIQUE * (NUM_PRACTICE_FRAMES + 1);
                        bufferVideo(seq);
                        return;
                    }



                    int trainingRoundNumber = practiceFrame + 1;
                    int section             = USER_STUDY_TECHNIQUE_INDEX + 1;
                    handsManager.menuText.text = "Section " + section + " of " + NUM_TECHNIQUES + ", Training Round " + trainingRoundNumber;
                    justManipulated            = false;

                    instructionSequence = USER_STUDY_TECHNIQUE * (NUM_PRACTICE_FRAMES + 1) + practiceFrame + 1;

                    resetAndShowHologramAtIndex(hologramIndex, false);

                    if (practiceFrame == NUM_PRACTICE_FRAMES)
                    {
                        doPractice                  = false;
                        disableTimedButton          = true;
                        showPracticeDoneInstruction = true;

                        SaveData(manipulatableObject, targetObject, true);

                        SaveDataClass data = new SaveDataClass(this);
                        data.continueButtonPress = true;
                        data.training            = true;
                        data.trainingSection     = NUM_PRACTICE_FRAMES.ToString();
                        SaveDataExtended(data);

                        practiceFrame = 0;
                        handsManager.userStudyOrientationText.text = "Practice Roll Rotation on Object";
                        handsManager.instructionTitleText.text     = handsManager.techniqueNames[USER_STUDY_TECHNIQUE] + " Technique: Roll Rotate Training";
                    }
                    else
                    {
                        if (practiceFrame == 0)
                        {
                            handsManager.instructionTitleText.text = handsManager.techniqueNames[USER_STUDY_TECHNIQUE] + " Technique: Training";
                            disableTimedButton = false;
                            disableImages      = false;
                        }
                        else
                        {
                            disableImages = false;
                            if (practiceFrame == 1)
                            {
                                handsManager.userStudyOrientationText.text = "Practice Resizing on Object";
                                handsManager.instructionTitleText.text     = handsManager.techniqueNames[USER_STUDY_TECHNIQUE] + " Technique: Resize Training";
                            }
                            else if (practiceFrame == 2)
                            {
                                handsManager.userStudyOrientationText.text = "Practice Pitch Rotation on Object";
                                handsManager.instructionTitleText.text     = handsManager.techniqueNames[USER_STUDY_TECHNIQUE] + " Technique: Pitch Rotate Training";
                            }
                            else if (practiceFrame == 3)
                            {
                                handsManager.userStudyOrientationText.text = "Practice Yaw Rotation on Object";
                                handsManager.instructionTitleText.text     = handsManager.techniqueNames[USER_STUDY_TECHNIQUE] + " Technique: Yaw Rotate Training";
                            }
                            SaveData(manipulatableObject, targetObject, true);

                            SaveDataClass data = new SaveDataClass(this);
                            data.continueButtonPress = true;
                            data.training            = true;
                            data.trainingSection     = practiceFrame.ToString();
                            SaveDataExtended(data);

                            disableTimedButton = true;
                        }
                        practiceFrame++;
                    }

                    //if its our first technique, we need to setup the practice hologram
                    // the if statement above wont go on the very first time
                    handsManager.counter = 0;
                    timeToWait           = 5;
                    showInstructions();
                }
                else
                {
                    handsManager.userStudyButtonText.text = "Perform Gesture Before Continuing";

                    // within data recording stage
                    RECORD_INFORMATION = true;

                    //only need to do this if we just had a practice stage
                    if (!justManipulated)
                    {
                        resetAndShowHologramAtIndex(hologramIndex, true);
                    }

                    justManipulated = true;
                }
            }
            else if (USER_STUDY_TECHNIQUE_INDEX == NUM_TECHNIQUES && justManipulated)
            {
                instructionSequence = REST_SEQUENCE;
                hideAllHolograms();
                disableTimedButton = false;
                int lastTechnique = techniquesPermuted [NUM_TECHNIQUES - 1];
                handsManager.instructionTitleText.text = handsManager.techniqueNames[lastTechnique] + " Technique: Section Complete";
                disableImages = true;
                handsManager.instructionTexts[REST_SEQUENCE] = "You have completed the final section.\nPlease say the following code to the study administrator:\n\n\n" + handsManager.codes[lastTechnique] + "\n\n\nPlease carefully remove the hololens and fill out the questionnaire for this section.";
                handsManager.counter = 0;
                timeToWait           = 30;
                showInstructions();
                justManipulated = false;

                IN_USER_STUDY = false;

                for (int i = 0; i < recordingStrings.Count; i++)
                {
                    UserStudyLogger.Instance.Record(recordingStrings [i], 1);
                }
                USER_STUDY_TECHNIQUE_INDEX++;
                resetAndShowHologramAtIndex(0, false);
            }
            else
            {
                finishUserStudy();
            }
        }
        else
        {
            if (USER_STUDY_TECHNIQUE_INDEX >= NUM_TECHNIQUES)
            {
                finishUserStudy();
                return;
            }
            // if we just showed instruction 0
            if (sequenceJustShown == 0)
            {
                doPractice = true;
                justRested = false;
            }

            hideInstructions();
            UserStudyButtonPressed();
        }
    }
 public void SaveDataExtended(SaveDataClass data)
 {
     /*string type = "N/A";
      * if (data.startButtonPress) {
      *      UnityEngine.Debug.Log("Event Type: startButtonPress");
      *      type = "startButtonPress";
      * }
      * if (data.continueButtonPress) {
      *      UnityEngine.Debug.Log("Event Type: continueButtonPress");
      *      type = "continueButtonPress";
      * }
      * if (data.beginningGesture) {
      *      UnityEngine.Debug.Log("Event Type: beginningGesture");
      *      type = "beginningGesture";
      * }
      * if (data.endingGesture) {
      *      UnityEngine.Debug.Log("Event Type: endingGesture");
      *      type = "endingGesture";
      * }
      * if (data.leftLost) {
      *      UnityEngine.Debug.Log("Event Type: leftLost");
      *      type = "leftLost";
      * }
      * if (data.rightLost) {
      *      UnityEngine.Debug.Log("Event Type: rightLost");
      *      type = "rightLost";
      * }
      * if (data.foundLeft) {
      *      UnityEngine.Debug.Log("Event Type: leftFound");
      *      type = "foundLeft";
      * }
      * if (data.foundRight) {
      *      UnityEngine.Debug.Log("Event Type: rightFound");
      *      type = "foundRight";
      * }
      * if (data.leftDown) {
      *      UnityEngine.Debug.Log("Event Type: leftDown");
      *      type = "leftDown";
      * }
      * if (data.rightDown) {
      *      UnityEngine.Debug.Log("Event Type: rightDown");
      *      type = "rightDown";
      * }
      * if (data.leftUp) {
      *      UnityEngine.Debug.Log("Event Type: leftUp");
      *      type = "leftUp";
      * }
      * if (data.rightUp) {
      *      UnityEngine.Debug.Log("Event Type: rightUp");
      *      type = "rightUp";
      * }
      * if (data.update) {
      *      type = "update";
      * }
      *
      * string rotationType = "N/A";
      *
      * if (data.inRotationGesture) {
      *      switch (handsManager.rotationType) {
      *              case TwoHandedRotationManager.pitchRotation:
      *                      rotationType = "pitchRotation";
      *                      break;
      *              case TwoHandedRotationManager.rollRotation:
      *              rotationType = "rollRotation";
      *                      break;
      *              case TwoHandedRotationManager.yawRotation:
      *              rotationType = "yawRotation";
      *                      break;
      *              case TwoHandedRotationManager.spindleRotation:
      *              rotationType = "spindleRotation";
      *                      break;
      *              case TwoHandedRotationManager.arcBallRotation:
      *              rotationType = "arcBallRotation";
      *                      break;
      *              case TwoHandedRotationManager.wireFrameRotation:
      *              rotationType = "wireFrameRotation";
      *                      break;
      *              default:
      *                      rotationType = "N/A";
      *                      break;
      *      }
      * }
      * else if(data.inResizeGesture)
      *      rotationType = "resizeGesture";
      *
      * string toRecord = "";
      *
      * toRecord = data.userID + ", " + data.section + ", " + data.technique + ", " + data.hologram + ", " + data.time + ", " + type + ", " + rotationType + ", ";
      * toRecord += data.leftHandPositionX + ", ";
      * toRecord += data.leftHandPositionY + ", " + data.leftHandPositionZ + ", " + data.rightHandPositionX + ", " + data.rightHandPositionY + ", " + data.rightHandPositionZ + ", " + data.rotationX + ", " + data.rotationY + ", " + data.rotationZ + ", ";
      * toRecord += data.targetRotationX + ", " + data.targetRotationY + ", " + data.targetRotationZ + ", " + data.angleBetweenRotations + ", " + data.localScale + ", " + data.targetLocalScale + ", " + data.training + ", " + data.trainingSection + ", " + handsManager.instructionPanel.activeSelf + ", " + sequenceJustShown;
      *
      * recordingStrings.Add (toRecord);
      *
      *
      * if (recordingStrings.Count == 100) {
      *      string[] strings = recordingStrings.ToArray ();
      * UserStudyLogger.Instance.Record (strings);
      *      recordingStrings.Clear ();
      * }*/
 }
Exemplo n.º 8
0
 public void ConvertToJSON(SaveDataClass _saveData)
 {
     JsonUtility.ToJson(_saveData);
 }
Exemplo n.º 9
0
 public void ReleaseSaveDataClass()
 {
     saveDataClass = null;
 }
Exemplo n.º 10
0
 public void Load()
 {
     saveDataClass = new SaveDataClass();
     if (!File.Exists(Application.persistentDataPath + "/save.json"))
     {
         var blockTransform = new BlockTransform[11]
         {
             new BlockTransform
             {
                 blockPosition = new Vector3(0, 0, 0),
                 blockRotation = Vector3.zero,
                 blockType     = "L"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(1, 0, 0),
                 blockRotation = Vector3.zero,
                 blockType     = "F"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(3, 0, 0),
                 blockRotation = Vector3.zero,
                 blockType     = "F"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(0, 0, 1),
                 blockRotation = Vector3.zero,
                 blockType     = "Obs"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(1, 0, 1),
                 blockRotation = Vector3.zero,
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(2, 0, 1),
                 blockRotation = Vector3.zero,
                 blockType     = "Obs"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(0, 0, 2),
                 blockRotation = Vector3.zero,
                 blockType     = "F"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(2, 0, 2),
                 blockRotation = Vector3.zero,
                 blockType     = "F"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(0, 0, 3),
                 blockRotation = Vector3.zero,
                 blockType     = "F"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(2, 0, 3),
                 blockRotation = Vector3.zero,
                 blockType     = "F"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(3, 0, 3),
                 blockRotation = new Vector3(0, 90, 0),
                 blockType     = "H"
             },
         };
         var stagePlacement = new StagePlacement[6];
         stagePlacement[0] = new StagePlacement
         {
             blockTransform = blockTransform,
             charaPosition  = new Vector3(3, 0.75f, 3),
             goalPosiotion  = new Vector3(0, 0, 3)
         };
         blockTransform = new BlockTransform[14]
         {
             new BlockTransform
             {
                 blockPosition = new Vector3(0, 0, 0),
                 blockRotation = new Vector3(0, 90, 0),
                 blockType     = "L"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(1, 0, 0),
                 blockRotation = Vector3.zero,
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(2, 0, 0),
                 blockRotation = Vector3.zero,
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(3, 0, 0),
                 blockRotation = Vector3.zero,
                 blockType     = "L"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(0, 0, 1),
                 blockRotation = new Vector3(0, 90, 0),
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(2, 0, 1),
                 blockRotation = Vector3.zero,
                 blockType     = "F"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(3, 0, 1),
                 blockRotation = new Vector3(0, 90, 0),
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(0, 0, 2),
                 blockRotation = new Vector3(0, 90, 0),
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(1, 0, 2),
                 blockRotation = Vector3.zero,
                 blockType     = "F"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(3, 0, 2),
                 blockRotation = new Vector3(0, 90, 0),
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(0, 0, 3),
                 blockRotation = new Vector3(0, 180, 0),
                 blockType     = "L"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(1, 0, 3),
                 blockRotation = Vector3.zero,
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(2, 0, 3),
                 blockRotation = Vector3.zero,
                 blockType     = "H"
             },
             new BlockTransform
             {
                 blockPosition = new Vector3(3, 0, 3),
                 blockRotation = new Vector3(0, -90, 0),
                 blockType     = "L"
             }
         };
         stagePlacement[1] = new StagePlacement
         {
             blockTransform = blockTransform,
             charaPosition  = new Vector3(0, 0.75f, 0),
             goalPosiotion  = new Vector3(2, 0, 3)
         };
         saveDataClass.saveData = stagePlacement;
         return;
     }
     using (var file = new FileStream(Application.persistentDataPath + "/save.json", FileMode.Open, FileAccess.Read))
     {
         byte[] bytes = new byte[file.Length];
         file.Read(bytes, 0, bytes.Length);
         var jsonString = System.Text.Encoding.UTF8.GetString(bytes);
         saveDataClass = JsonUtility.FromJson <SaveDataClass>(jsonString);
     }
 }