Esempio n. 1
0
    void HandleAMPSListenerInstanceFileDownloaded(object sender, AMPListenerEventArgs e)
    {
        eventsListener.FileDownloaded -= HandleAMPSListenerInstanceFileDownloaded;

        Debug.Log("Asset downloaded " + e.Result);
        TweaksSystemEventArgs res = new TweaksSystemEventArgs();

        if (e.Result == true)
        {
            PlayerPrefs.SetString(LAST_UPDATE, System.DateTime.UtcNow.ToBinary().ToString());
            PlayerPrefs.SetString(FILE_VERSION_KEY, AMPSBinding.GetVersionOfFile(GetPath(), e.FilenameDownloaded));
            this.LoadFromDisk();
            res.Error   = null;
            res.Message = "Tweaks System Downloaded and setted as new values";
            res.SaveIn  = TweaksResultSave.Disk;
            res.Result  = true;

            PlayerPrefs.Save();
        }
        else
        {
            res.Error   = e.Error;
            res.Message = "Error downloading " + e.FilenameDownloaded;
            res.SaveIn  = TweaksResultSave.NotSave;
            res.Result  = false;

            this.LoadFromDisk();
        }

        if (_onResult != null)
        {
            _onResult(res);
        }
    }
Esempio n. 2
0
    void HandleAMPSListenerInstanceAMPSManagerInit(object sender, AMPListenerEventArgs e)
    {
        eventsListener.AMPSManagerInit -= HandleAMPSListenerInstanceAMPSManagerInit;

        string serverFileVersion = AMPSBinding.GetVersionOfFile(GetPath(), FILE_NAME);

        Debug.Log("TWEAKS Version " + serverFileVersion);
        if (e.Result)
        {
            if (!PlayerPrefs.HasKey(FILE_VERSION_KEY))
            {
                eventsListener.FileDownloaded += HandleAMPSListenerInstanceFileDownloaded;
                AMPSBinding.DownloadAsset(GetPath(), FILE_NAME);
            }
            else if (Convert.ToSingle(serverFileVersion) > Convert.ToSingle(PlayerPrefs.GetString(FILE_VERSION_KEY)))
            {
                eventsListener.FileDownloaded += HandleAMPSListenerInstanceFileDownloaded;
                AMPSBinding.DownloadAsset(GetPath(), FILE_NAME);
            }
            else
            {
                Debug.Log("Update is not neccessary");
                TweaksSystemEventArgs args = new TweaksSystemEventArgs();
                args.Result  = true;
                args.Message = "Update is not neccessary, loaded default values";
                args.SaveIn  = TweaksResultSave.NotSave;

                this.LoadFromDisk();
            }
        }
        else
        {
            TweaksSystemEventArgs res = new TweaksSystemEventArgs();
            res.Error   = e.Error;
            res.Message = "Error downloading " + e.FilenameDownloaded;
            res.SaveIn  = TweaksResultSave.NotSave;
            res.Result  = false;
            if (_onResult != null)
            {
                _onResult(res);
            }

            this.LoadFromDisk();
        }
    }
Esempio n. 3
0
    public void SynchTweaks(System.Action <TweaksSystemEventArgs> onResult = null)
    {
        if (!this.IsNeededUpdate())
        {
            Debug.Log("Update is not neccessary");
            TweaksSystemEventArgs args = new TweaksSystemEventArgs();
            args.Result  = true;
            args.Message = "Update is not neccessary, loaded default values";
            args.SaveIn  = TweaksResultSave.NotSave;
            if (onResult != null)
            {
                onResult(args);
            }

            this.LoadFromDisk();

            return;
        }

        _onResult = onResult;
        eventsListener.AMPSManagerInit += HandleAMPSListenerInstanceAMPSManagerInit;
        AMPSBinding.InitDMOAssetManager(eventsListener.name, GetPath());
    }
	void HandleAMPSListenerInstanceFileDownloaded (object sender, AMPListenerEventArgs e)
	{
		eventsListener.FileDownloaded -= HandleAMPSListenerInstanceFileDownloaded;
		
		Debug.Log("Asset downloaded " + e.Result);
		TweaksSystemEventArgs res = new TweaksSystemEventArgs();
		if (e.Result == true)
		{
			PlayerPrefs.SetString(LAST_UPDATE, System.DateTime.UtcNow.ToBinary().ToString());
			PlayerPrefs.SetString(FILE_VERSION_KEY, AMPSBinding.GetVersionOfFile(GetPath(), e.FilenameDownloaded));
			this.LoadFromDisk();
			res.Error = null;
			res.Message = "Tweaks System Downloaded and setted as new values";
			res.SaveIn = TweaksResultSave.Disk;
			res.Result = true;
			
			PlayerPrefs.Save();
		}
		else
		{
			res.Error = e.Error;
			res.Message = "Error downloading " + e.FilenameDownloaded;
			res.SaveIn = TweaksResultSave.NotSave;
			res.Result = false;
			
			this.LoadFromDisk();
		}
		
		if (_onResult != null) 
		{	
			_onResult(res);
		}
	}
	void HandleAMPSListenerInstanceAMPSManagerInit (object sender, AMPListenerEventArgs e)
	{
		eventsListener.AMPSManagerInit -= HandleAMPSListenerInstanceAMPSManagerInit;
		
		string serverFileVersion = AMPSBinding.GetVersionOfFile(GetPath(), FILE_NAME);
		
		Debug.Log("TWEAKS Version " + serverFileVersion);
		if (e.Result)
		{
			if (!PlayerPrefs.HasKey(FILE_VERSION_KEY))
			{
				eventsListener.FileDownloaded += HandleAMPSListenerInstanceFileDownloaded;
				AMPSBinding.DownloadAsset(GetPath(), FILE_NAME);
			}
			else if (Convert.ToSingle(serverFileVersion) > Convert.ToSingle(PlayerPrefs.GetString(FILE_VERSION_KEY)))
			{
				eventsListener.FileDownloaded += HandleAMPSListenerInstanceFileDownloaded;
				AMPSBinding.DownloadAsset(GetPath(), FILE_NAME);
			}
			else
			{
				Debug.Log("Update is not neccessary");
				TweaksSystemEventArgs args = new TweaksSystemEventArgs();
				args.Result = true;
				args.Message = "Update is not neccessary, loaded default values";
				args.SaveIn = TweaksResultSave.NotSave;
			
				this.LoadFromDisk();
			}
		}
		else
		{
			TweaksSystemEventArgs res = new TweaksSystemEventArgs();
			res.Error = e.Error;
			res.Message = "Error downloading " + e.FilenameDownloaded;
			res.SaveIn = TweaksResultSave.NotSave;
			res.Result = false;
			if (_onResult != null) 
			{	
				_onResult(res);
			}
			
			this.LoadFromDisk();
		}
	}
	public void SynchTweaks(System.Action<TweaksSystemEventArgs> onResult = null)
	{
		if (!this.IsNeededUpdate())
		{
			Debug.Log("Update is not neccessary");
			TweaksSystemEventArgs args = new TweaksSystemEventArgs();
			args.Result = true;
			args.Message = "Update is not neccessary, loaded default values";
			args.SaveIn = TweaksResultSave.NotSave;
			if (onResult != null)
				onResult(args);
			
			this.LoadFromDisk();
			
			return;
		}
		
		_onResult = onResult;
		eventsListener.AMPSManagerInit += HandleAMPSListenerInstanceAMPSManagerInit;
		AMPSBinding.InitDMOAssetManager(eventsListener.name, GetPath());
	}