Exemplo n.º 1
0
    private static void SyncProfile(bool sendProfile, Online.Profile.Data serverProfile, System.Action <bool> nextTask)
    {
        // check to see if local data is empty then ther are 2 states
        // 1- we are in first run
        // 2- we lost our cache files
        if (Username.IsNullOrEmpty())
        {
            // check to see if we are in first run
            if (serverProfile.datahash.IsNullOrEmpty())
            {
                data.info = serverProfile;
                RunFirstSission();
                SendProfileData(sendProfile, nextTask);
            }
            // we have data on server but we have lost data on local
            // so try to load from server to local
            else
            {
                data.info = serverProfile;
                Online.Userdata.Get((sucess, privateStr, publicStr) =>
                {
                    if (sucess)
                    {
                        data.privateData = JsonUtility.FromJson <ProfileData.PrivateData>(Utilities.DecompressString(privateStr, "{}"));
                        data.publicData  = JsonUtility.FromJson <ProfileData.PublicData>(Utilities.DecompressString(publicStr, "{}"));
                        SaveLocal();
                        nextTask(true);
                    }
                    else
                    {
                        nextTask(false);
                    }
                });
            }
        }
        // local data is not empty
        else
        {
            data.info = serverProfile;

            // check to see if player is marked as hacher?
            if (serverProfile.datahash == "shame")
            {
                PlayerPrefs.DeleteAll();
                PlayerPrefsEx.ClearData();
                data.privateData = new ProfileData.PrivateData();
                data.publicData  = new ProfileData.PublicData();
                StartSession();
                SaveLocal();
            }

            // finally just send data to server
            SendProfileData(sendProfile, nextTask);
        }
    }
Exemplo n.º 2
0
 public static void Reset()
 {
     Loading.Show();
     Online.Profile.SetNickname(string.Empty, successName =>
                                Online.Profile.SetStatus(string.Empty, successStatus =>
                                                         Online.Profile.SetAvatar(string.Empty, successAvatar =>
     {
         Application.Quit();
         PlayerPrefs.DeleteAll();
         PlayerPrefsEx.ClearData();
         data.privateData = new ProfileData.PrivateData();
         data.publicData  = new ProfileData.PublicData();
         data.avatar      = new ProfileData.AvatarData();
         data.info.avatar = JsonUtility.ToJson(data.avatar);
         StartSession();
         SaveLocal();
     })));
 }