Пример #1
0
    public static PPIDailyRewards Restore(string primaryKey, ref System.DateTime date, string filename = "rewards")
    {
        DictionaryFile file = GetFile(primaryKey, filename);

        if (file == null)
        {
            return(null);
        }

        file.Load();

        string json = file.GetString("rewards", "");

        if (string.IsNullOrEmpty(json) == true)
        {
            return(null);
        }

        if (System.DateTime.TryParse(file.GetString("date", ""), out date) == false)
        {
            date = CloudDateTime.UtcNow.Date;
        }

        return(Fix(JsonMapper.ToObject <PPIDailyRewards>(json)));
    }
Пример #2
0
    void LoadOutbox(DictionaryFile file)
    {
        bool resave = false;

        string messages = "";

        if (file.HasKey("outbox") == true)
        {
            messages = file.GetString("outbox", "");
        }
        else
        {
            string rootKey = "Player[" + m_PrimaryKey + "].CloudMailbox";
            messages = PlayerPrefs.GetString(rootKey + ".Outbox", "");

            PlayerPrefs.DeleteKey(rootKey + ".Outbox");

            resave = true;
        }

        //System.IO.File.WriteAllText("Outbox.json", messages);

        m_Outbox = ReconstructFromString(messages);
        m_Outbox = m_Outbox ?? new List <BaseMessage>();

        if (resave == true)
        {
            Save();
        }
    }
Пример #3
0
    void LoadInbox(DictionaryFile file)
    {
        bool resave = false;

        string messages = "";

        if (file.HasKey("inbox") == true)
        {
            messages = file.GetString("inbox", "");
        }
        else
        {
            string rootKey = "Player[" + m_PrimaryKey + "].CloudMailbox";
            messages = PlayerPrefs.GetString(rootKey + ".Inbox", "");

            PlayerPrefs.DeleteKey(rootKey + ".Inbox");

            resave = true;
        }

        m_LastMessageIndexFromProductInbox = file.GetInt("lastMessageIndexFromProductInbox", 0);

        //System.IO.File.WriteAllText("Inbox.json", messages);

        m_Inbox = ReconstructFromString(messages);
        m_Inbox = m_Inbox ?? new List <BaseMessage>();
        m_Inbox = CleanUpMailBox(m_Inbox);

        if (resave == true)
        {
            Save();
        }

        OnInboxChanged();
    }
Пример #4
0
    void Load()
    {
        DictionaryFile file = GetFile();

        if (file == null)
        {
            return;
        }

        file.Load();

        string json = file.GetString("active", "");

        m_Friends = JsonMapper.ToObject <List <FriendInfo> >(json);
        m_Friends = m_Friends ?? new List <FriendInfo>();

        // fixing old saves when we don't serialze m_PPIData...
        foreach (FriendInfo fi in m_Friends)
        {
            fi.PPIData = fi.PPIData ?? new PlayerPersistentInfoData();
        }

        // try to read from old cache first so we don't old lose pending list
        string rootKey = "Player[" + CloudUser.instance.primaryKey + "].FriendList";

        if (PlayerPrefs.HasKey(rootKey + ".PendingFriends") == true)
        {
            json = PlayerPrefs.GetString(rootKey + ".PendingFriends", "");
        }
        else
        {
            json = file.GetString("pendings", "");
        }
        m_PendingFriends = JsonMapper.ToObject <List <PendingFriendInfo> >(json);
        m_PendingFriends = m_PendingFriends ?? new List <PendingFriendInfo>();

        // get friend list from cloud
        RetriveFriendListFromCloud(true);
    }
Пример #5
0
 public string GetString(string key, string defVal)
 {
     return(m_File != null?m_File.GetString(key, defVal) : defVal);
 }