static public bool StartOfflinePlay() { if (PlaySession != null || local_login == null || local_license == null || local_license.energy <= local_license.per_session) { return(false); } if (ApiSession == null) { ApiSession = new RaqnApiSession(); ApiSession.logins.Add(local_login); } if (PlaySession == null) { PlaySession = new RaqnPlaySession(); PlaySession.dix = Dix.Id; PlaySession.license = local_license.id; RaqnPlayer _p = new RaqnPlayer(); _p.id = local_login.user.id; _p.nickname = local_login.user.profile.nickname; _p.avatar = local_login.user.profile.avatar; PlaySession.players.Add(_p); PlaySession.InitSessionData(ApiSession.id, Dix.Id, Dix.Package); ApiSession.play = PlaySession.id; } ExpendEnergy(License.per_session); RaqnStorage.SaveJson <RaqnLicense>("cache/license.dat", local_license, false, Dix.Secret); return(true); }
protected void Initialize() { Dix = DixInfo.Load(); try { GameData = RaqnData.LoadOrCreate <RaqnData>(Dix.Id + ".json", true); //GeneralStats = StatContainer.LoadOrDie("General"); } catch (Exception _ex) { Debug.LogException(_ex); Debug.LogError("Could not load DixData. Quitting app! (Exception :" + _ex.Message + ")"); RealQuit(); } Api = new RaqnApi(Dix.Id, Dix.Secret); Api.OnStartSuccess += OnLogin_Success; Api.OnStartError += OnLogin_Error; Api.OnLoginSuccess += OnLogin_Success; Api.OnLoginError += OnLogin_Error; Api.OnPlaySuccess += OnPlay_Success; Api.OnPlayError += OnPlay_Error; ApiSession = new RaqnApiSession(); local_login = RaqnStorage.LoadJson <RaqnLogin>("cache/login.dat", false, Dix.Secret); local_license = RaqnStorage.LoadJson <RaqnLicense>("cache/license.dat", false, Dix.Secret); }
protected void OnLogin_Success() { ApiSession = Api.GetSession(); if (ApiUser == null || ApiSession == null) { OnLogin_Error(ResponseStatus.ERR_FORMATTING); return; } RaqnTime.SetSyncDelta(ApiSession.started); local_login = ApiSession.logins[0]; RaqnStorage.SaveJson <RaqnLogin>("cache/login.dat", local_login, false, Dix.Secret); Api.LicenseCurrent(Dix.Id, (lic) => { OnLicense_Success(lic); }, (_err) => { OnLicense_Error(_err); }); if (OnLogin != null) { OnLogin(); } }