Exemple #1
0
    public static UserDataTO create(string json, string userId)
    {
        UserDataTO userData = JsonUtility.FromJson <UserDataTO>(json);

        //Debug.Log (json);
        userData.UserId = userId;
        userData.OrganizeLevel();
        userData.OrganizeMonsters();

        return(userData);
    }
Exemple #2
0
 public void setUserData(UserDataTO userData)
 {
     if (usersData.ContainsKey(userData.UserId))
     {
         usersData[userData.UserId] = userData;
     }
     else
     {
         usersData.Add(userData.UserId, userData);
     }
 }
 void convertToVer_2()
 {
     for (int profileId = 0; profileId <= 4; profileId++)
     {
         UserDataTO userData = convertProfile_2(profileId);
         if (userData != null)
         {
             userData.Organize();
             UsersController.Instance.save(userData, false);
         }
     }
     SaveStatConnector.Instance.DataVersion = 2;
 }
Exemple #4
0
    public void save(UserDataTO userDataToSave, bool replace = false)
    {
        string userId = (string.IsNullOrEmpty(userDataToSave.UserId)) ? "guest" : userDataToSave.UserId;

        if (userDataToSave != null)
        {
            if (!dataToSave.ContainsKey(userId))
            {
                dataToSave.Add(userId, userDataToSave);
            }
            else if (replace)
            {
                dataToSave[userId] = userDataToSave;
            }
        }
    }
    UserDataTO convertProfile_2(int profileId)
    {
        UserDataTO userData = UsersController.Instance.userData(profileId);

        //UserDataTO userData = new UserDataTO ();
        userData.UserId = UsersController.LocalUserPrefix + profileId.ToString();

        userData.HighestOpenLevel = PlayerPrefs.GetInt(getPrefsKey_2(Keys_2.LevelOpenIndex, profileId), -1);
        userData.LastPlayingLevel = PlayerPrefs.GetInt(getPrefsKey_2(Keys_2.LastPlayingLevel, profileId), -1);

        if (userData.HighestOpenLevel == -1 && userData.LastPlayingLevel == -1)
        {
            return(null);
        }

        userData.LastLetterGroup         = PlayerPrefs.GetInt(getPrefsKey_2(Keys_2.LetterGroup, profileId), 1);
        userData.LastMonsterIndex        = PlayerPrefs.GetInt(getPrefsKey_2(Keys_2.LastMonsterIndex, profileId), 0);
        userData.LastPettingZoneTutorial = PlayerPrefs.GetInt(getPrefsKey_2(Keys_2.LastPettingZoneTutorial, profileId), -1);
        userData.Levels   = convertLevels_2(profileId);
        userData.Monsters = convertMonsters_2(profileId);

        return(userData);
    }
Exemple #6
0
 public void clearUserData()
 {
     setUserData(UserDataTO.create("{}", userData().UserId));
     save(userData(), true);
 }
Exemple #7
0
 void saveData(UserDataTO userData)
 {
     SaveStatConnector.Instance.StartSaveLocal(userData);
 }
Exemple #8
0
 public UserDataTO StartLoadLocal(string userId)
 {
     return(UserDataTO.create(PlayerPrefs.GetString(LocalStateKey(userId), "{}"), userId));
 }