Esempio n. 1
0
        private void Awake()
        {
            LoadedScenes = new List <SceneContextModel>();
            List <SceneContextModel> loadedData = SaveDataManager.LoadData <List <SceneContextModel> >(DataConsts.SCENE_DATA_FILE);

            if (loadedData != null ? loadedData.GroupBy(x => x.sceneName)
                .Where(g => g.Count() > 1)
                .Select(y => y.Key)
                .Count() > 0 : false)
            {
                throw new System.Exception(ErrorConsts.DUPLICATE_SCENE_MODEL);
            }

            LoadedScenes = loadedData ?? new List <SceneContextModel>();
        }
Esempio n. 2
0
        public void UpdateSceneData(SceneContextModel sceneModel)
        {
            var existingSceneData = LoadedScenes.Where(x => x.sceneName == sceneModel.sceneName)
                                    .FirstOrDefault();

            if (existingSceneData != null)
            {
                existingSceneData.boolStates = sceneModel.boolStates;
            }
            else
            {
                LoadedScenes.Add(sceneModel);
            }

            SaveDataManager.SaveData(LoadedScenes, DataConsts.SCENE_DATA_FILE);
        }
Esempio n. 3
0
        public void UpdateSceneData(SceneContextModel sceneModel)
        {
            var existingSceneData = LoadedScenes.Where(x => x.sceneName == sceneModel.sceneName)
                                    .FirstOrDefault();

            if (existingSceneData != null)
            {
                existingSceneData.boolStates     = new List <BoolStateModel>(sceneModel.boolStates);
                existingSceneData.quantityStates = new List <QuantityStateModel>(sceneModel.quantityStates);
            }
            else
            {
                LoadedScenes.Add(sceneModel);
            }

            SaveDataManager.SaveData(LoadedScenes, DataConsts.SCENE_DATA_FILE);

            Debug.Log($"Game saved to: {DataConsts.SCENE_DATA_FILE} in {Application.persistentDataPath}.");
        }