public override void Initialize()
        {
            _dataSerializationAdapter = new DefaultAppSettingsDataSerializationAdapter(m_adapterType);

            // choose where and how the data is stored
            switch (m_persistenceType)
            {
            case DataPersistenceType.PlayerPrefs:
                m_adapterType     = DataSerializationAdapterType.Concrete;
                m_dataPersistence = new DefaultPlayerPrefsPersistence(_dataSerializationAdapter.GetSerializableData() as IPlayerPrefsActions, m_encrypted);
                break;

            case DataPersistenceType.Local:
                var serializer = CreateDataSerializer();
                m_dataPersistence = new DefaultLocalPersistence(serializer, m_encrypted, SaveToPlayerPrefs);
                break;

            case DataPersistenceType.Remote:
            default:
                break;
            }

            // use the adapter to initialize
            _dataSerializationAdapter.Initialize(SaveDataPathFull, m_dataPersistence);
        }
        protected IDataSerializer CreateDataSerializer()
        {
            // choose what serializer you want to use
            IDataSerializer dataSerializer = null;

            switch (m_serializerType)
            {
            case DataSerializerType.JsonUtility:
                dataSerializer = new JsonDataSerializer();
                m_adapterType  = DataSerializationAdapterType.Concrete;
                break;

            case DataSerializerType.Odin:
                dataSerializer = new OdinDataSerializer(m_dataFormat);
                break;
            }

            return(dataSerializer);
        }
 public PlayerDataSerializationAdapter(DataSerializationAdapterType dataType = DataSerializationAdapterType.Generic) : base(dataType)
 {
 }
 public AppSettingsDataSerializationAdapter(DataSerializationAdapterType dataType = DataSerializationAdapterType.Generic) : base(dataType)
 {
 }
Beispiel #5
0
 protected override IDataSerializationAdapter CreateSerializationAdapterForPlayer(DataSerializationAdapterType adapterType)
 {
     return(new PlayerDataSerializationAdapter(m_adapterType));
 }
Beispiel #6
0
 protected override IDataSerializationAdapter CreateSerializationAdapterForGame(DataSerializationAdapterType adapterType)
 {
     return(new GameDataSerializationAdapter(m_adapterType));
 }
Beispiel #7
0
 protected override IDataSerializationAdapter CreateSerializationAdapterForAppSettings(DataSerializationAdapterType adapterType)
 {
     return(new AppSettingsDataSerializationAdapter(m_adapterType));
 }