public void BeginDream()
        {
            TextureSetSystem.SetTextureSet(randomTextureSetFromDayNumber(GameSave.CurrentJournalSave.DayNumber));

            string dreamPath = GameSave.CurrentJournalSave.DayNumber == 1
                ? JournalLoader.Current.GetFirstDream()
                : JournalLoader.Current.GetDreamFromGraph(GameSave.CurrentJournalSave.LastGraphX,
                                                          GameSave.CurrentJournalSave.LastGraphY);

            _currentDreamPath = dreamPath;
            Dream dream = _serializer.Deserialize <Dream>(PathUtil.Combine(Application.streamingAssetsPath,
                                                                           dreamPath));

            BeginDream(dream);
        }
        public void EditLevel(string levelPath)
        {
            GameObject existingLevel = GameObject.Find("Level");

            if (existingLevel != null)
            {
                DestroyImmediate(existingLevel);
            }

            levelPath = PathUtil.Combine(Application.streamingAssetsPath, levelPath);

            if (Path.GetExtension(levelPath) == ".json")
            {
                Dream.Dream dream = _serializer.Deserialize <Dream.Dream>(levelPath);
                if (dream.Type == DreamType.Legacy)
                {
                    LoadLBD(dream);
                }

                if (!string.IsNullOrEmpty(dream.Level))
                {
                    string tmapPath = PathUtil.Combine(Application.streamingAssetsPath, dream.Level);
                    _levelObj = _levelLoader.LoadLevel(tmapPath);
                }
                else
                {
                    newLevel();
                }
            }
            else
            {
                _levelObj = _levelLoader.LoadLevel(levelPath);
            }
        }
        public void Load()
        {
            Debug.Log("Loading game settings...");

            // if we're loading over an existing settings object we want to deregister the old one
            if (Settings != null)
            {
                SettingsBindBroker.DeregisterData(Settings);
            }

            // check to see if the settings file exists
            if (File.Exists(SettingsPath))
            {
                Settings = _serializer.Deserialize <GameSettings>(SettingsPath);
            }
            else
            {
                // create the default settings
                Debug.Log("Settings.json not found, creating default settings");
                Settings = new GameSettings();
                Save();
            }

            // register the new settings object
            SettingsBindBroker.RegisterData(Settings);
        }
        public GameObject LoadLevel(string levelPath)
        {
            Level         level    = _serializer.Deserialize <Level>(levelPath);
            LevelEntities entities = level.ToScene(DreamSystem, SettingsSystem);

            OnLevelLoaded?.Invoke(entities);
            return(entities.gameObject);
        }
Beispiel #5
0
        private void importExistingJournal()
        {
            var journalPath =
                EditorUtility.OpenFilePanelWithFilters("Open journal JSON...", "", new[] { "Journal JSON file", "json" });

            if (!string.IsNullOrEmpty(journalPath))
            {
                _journal = _serializer.Deserialize <DreamJournal>(journalPath);
            }
        }
Beispiel #6
0
        public void LoadJournals()
        {
            var journalsPath = PathUtil.Combine(Application.streamingAssetsPath, PathToJournals);
            var journalFiles = Directory.GetFiles(journalsPath, "*.json");

            Journals = new List <DreamJournal>();
            foreach (var journalFile in journalFiles)
            {
                var journal = _serializer.Deserialize <DreamJournal>(journalFile);
                Journals.Add(journal);
            }
        }
        private void load()
        {
            List <CreditsSection> creditsSections =
                _serializer.Deserialize <List <CreditsSection> >(PathUtil.Combine(Application.streamingAssetsPath,
                                                                                  CREDITS_FILE_PATH));

            addObject(UITitleTextPrefab);

            foreach (var section in creditsSections)
            {
                createSection(section);
            }

            addObject(UIEndCapObject);
        }
Beispiel #8
0
        private void importExistingDream()
        {
            var dreamPath =
                EditorUtility.OpenFilePanelWithFilters("Open dream JSON...", "", new[] { "Dream JSON file", "json" });

            if (!string.IsNullOrEmpty(dreamPath))
            {
                _dream = _serializer.Deserialize <Dream.Dream>(dreamPath);
                _dreamEnvironmentFoldoutStates.Clear();
                foreach (var env in _dream.Environments)
                {
                    _dreamEnvironmentFoldoutStates.Add(false);
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Load the saved settings from the file.
        /// </summary>
        public static void LoadSettings()
        {
            Debug.Log("Loading game settings...");

            // check to see if the settings file exists
            if (File.Exists(SettingsPath))
            {
                CurrentSettings = _serializer.Deserialize <GameSettings>(SettingsPath);
            }
            else
            {
                // create the default settings
                Debug.Log("Settings.json not found, creating default settings");
                CurrentSettings = new GameSettings();
                SaveSettings(CurrentSettings);
            }
        }
 public void Load()
 {
     if (!File.Exists(_savedGamePath))
     {
         Debug.Log("Unable to find game save -- creating new one");
         Data = new GameSaveData();
         foreach (var journal in JournalLoader.Journals)
         {
             Data.Journal(journal);
         }
         Save();
     }
     else
     {
         Data = _serializer.Deserialize <GameSaveData>(_savedGamePath);
     }
 }
        public void LoadSchemes()
        {
            Debug.Log("Deserialising control schemes...");

            Schemes = new List <ControlScheme>();

            // if the directory doesn't exist, create it
            if (!Directory.Exists(_controlSchemesPath))
            {
                Directory.CreateDirectory(_controlSchemesPath);
            }

            // deserialize all of the control schemes in the path
            foreach (string file in Directory.GetFiles(_controlSchemesPath, "*.dat"))
            {
                Schemes.Add(_serializer.Deserialize <ControlScheme>(file));
            }
        }
Beispiel #12
0
    void Awake()
    {
        SerializationTest test = new SerializationTest()
        {
            Name   = "Testing serialization!!",
            Number = 3.141f
        };

        test.Strings.AddRange(new [] { "test 1", "test 2", "test 3" });

        ToriiSerializer serializer = new ToriiSerializer();
        //serializer.Serialize(test, "test.dat");

        SerializationTest test2 = serializer.Deserialize <SerializationTest>("test2.dat");

        Debug.Log(test2.Name);
        Debug.Log(test2.Number);
    }
Beispiel #13
0
        // deserialize control schemes from a given path
        private static List <ControlScheme> deserializeControlSchemes(string path)
        {
            List <ControlScheme> schemes = new List <ControlScheme>();

            // if the directory doesn't exist, create it
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            // deserialize all of the control schemes in the path
            foreach (string file in Directory.GetFiles(path, "*.dat"))
            {
                schemes.Add(_serializer.Deserialize <ControlScheme>(file));
            }

            return(schemes);
        }