Пример #1
0
 public void OnObjectChanged(Observable observable)
 {
     try
     {
         Model.Save();
         Model.Commit();
     }
     catch (Exception e)
     {
         MonoLog.Log(MonoLogChannel.AppController, e);
     }
 }
Пример #2
0
        public AppController()
        {
            try
            {
                Model = AppModel.Load(AppModel.CONFIG_NAME);
            }
            catch (Exception e)
            {
                MonoLog.Log(MonoLogChannel.AppController, e);
                Model = new AppModel();
            }

            Model.AddObserver(this);

            _stateMachine = new StateMachine(this);
            _stateFlow    = new StateFlow(this, _stateMachine);
            _stateFlow.Add(new StateFlow.NextStatePair(typeof(AppInitializeState), typeof(AppReadyState)));

            LoadConfigs();
        }
Пример #3
0
        public static bool Load(AppModel model)
        {
            try
            {
//				Localization = LocalizationConfig.Load(model.Language);
//				Game = GameConfig.Default();//GameConfig.Load(GameConfig.FILE_NAME);
//				GameCenter = GameCenterConfig.Default();//GameCenterConfig.Load(GameCenterConfig.FILE_NAME);
//				Elements = ElementConfig.Default();
                Levels = LevelConfig.Default();
                Game   = GameConfig.Default();
            }
            catch (Exception e)
            {
                MonoLog.Log(MonoLogChannel.Exceptions, e);

                return(false);
            }

            return(true);
        }
Пример #4
0
        public static TConfig LoadFromResources(String name)
        {
            TSerializationPolicy serializer = new TSerializationPolicy();

            string path = Path.Combine(CONFIGS_FOLDER, name);

            path = path.Replace(Path.GetExtension(path), "");

            MonoLog.Log(MonoLogChannel.Core, "LoadFromResources: " + path);

            UnityEngine.Object textAsset = Resources.Load(path);

            MonoLog.Log(MonoLogChannel.Core, "textAssets: " + textAsset);
            MonoLog.Log(MonoLogChannel.Core, "textAssets: " + textAsset.GetType());

            TConfig config = serializer.RestoreFromString <TConfig>(((TextAsset)textAsset).text);

            config.OnRestored();

            return(config);
        }
Пример #5
0
        public static void ClosePopUp(UIPopUpController controller)
        {
            if (controller.Handler != null)
            {
                try
                {
                    controller.Handler.PopUpDidFinish(controller);
                }
                catch (Exception e)
                {
                    MonoLog.Log(MonoLogChannel.UI, e);
                }
            }

            if (PopUpClose != null)
            {
                PopUpClose(controller);
            }

            UnityEngine.Object.Destroy(controller.gameObject);
        }
Пример #6
0
        public void LoadConfigs()
        {
            if (!AppConfig.Load(AppModel.Instance))
            {
                AppConfig.LoadDefault(AppModel.Instance);
            }

                        #if UNITY_EDITOR
            if (AppConfig.RuntimeSaveConfig)
            {
                try
                {
                    AppConfig.Game.Save();
                    AppConfig.Levels.Save();
                }
                catch (Exception e)
                {
                    MonoLog.Log(MonoLogChannel.AppController, "Unable to save configs", e);
                }
            }
                        #endif
        }
Пример #7
0
        public void Save(string name)
        {
            String configFolderPath = Path.Combine(Application.persistentDataPath, CONFIGS_FOLDER);

                        #if UNITY_EDITOR
            configFolderPath = Path.Combine(Path.Combine(Application.dataPath, "Development"), CONFIGS_FOLDER);
                        #endif

            if (!Directory.Exists(configFolderPath))
            {
                Directory.CreateDirectory(configFolderPath);
            }

            TSerializationPolicy serializer = new TSerializationPolicy();

            String configFilePath = Path.Combine(configFolderPath, name);

            MonoLog.Log(MonoLogChannel.Configs, "Saving config " + configFilePath);

            using (Stream stream = File.Open(Path.Combine(configFolderPath, name), FileMode.Create, FileAccess.Write))
            {
                serializer.Store <TConfig>((TConfig)this, stream);
            }
        }
Пример #8
0
        public void LoadScene <T>(params object[] args)
        {
            MonoLog.Log(MonoLogChannel.UI, string.Format("Loading scene {0}", typeof(T)));

            UIManager.Load(typeof(T), args);
        }