protected void OnPlay_Success() { //ApiSession = Api.GetSession(); PlaySession = Api.GetPlaySession(); if (PlaySession == null) { OnPlay_Error(ResponseStatus.ERR_FORMATTING); } //init session data for all players PlaySession.InitSessionData(ApiSession.id, Dix.Id, Dix.Package); RaqnStorage.SaveJson <RaqnLicense>("cache/license.dat", local_license, false, Dix.Secret); ExpendEnergy(License.per_session); GameData.UpdateStatDelta("RAQN.TotalUses", 1); OnSync += () => { Api.LicenseCurrent(Dix.Id, (lic) => { local_license = lic; }); }; SyncJob(); if (OnPlay != null) { OnPlay(); } }
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 OnLicense_Success(RaqnLicense lic) { local_license = lic; if (local_license.IsDepleted()) { OnLicense_Error("LIC_DEPLETED"); } else if (local_license.IsExpired()) { OnLicense_Error("LIC_EXPIRED"); } else { if (OnLicenseOK != null) { OnLicenseOK(); } } }