Example #1
0
 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);
 }
Example #2
0
        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();
            }
        }