Ejemplo n.º 1
0
    public UserCollectionAuxiliar GetUserCollectionFromJson()
    {
        Dictionary <string, int> quantityOfCardsUserHaveFromBDOnline = new Dictionary <string, int>();

        if (SaveLoadDirectoryExist() && FileExist(userCollectionFile))
        {
            string json = ReadStringFromJson(userCollectionFile);
            DefaultCollectionDataDBList collDbList = new DefaultCollectionDataDBList();
            JsonUtility.FromJsonOverwrite(json, collDbList);

            List <DefaultCollectionDataDB> dfCollection = new List <DefaultCollectionDataDB>();
            foreach (DefaultCollectionDataDB data in collDbList.dfCollection)
            {
                if (!quantityOfCardsUserHaveFromBDOnline.ContainsKey(data.ID))
                {
                    quantityOfCardsUserHaveFromBDOnline.Add(data.ID, data.Amount);
                }

                dfCollection.Add(data);
            }

            UserCollectionAuxiliar userCollectionAuxiliar = new UserCollectionAuxiliar(dfCollection, quantityOfCardsUserHaveFromBDOnline);

            if (debugOn)
            {
                Debug.Log("USER CARD COLLECTION LOADED FROM JSON");
            }

            return(userCollectionAuxiliar);
        }
        return(null);
    }
Ejemplo n.º 2
0
    public void SetUserCollectionToJson(List <DefaultCollectionDataDB> dfCollection)
    {
        DefaultCollectionDataDBList dfList = new DefaultCollectionDataDBList(dfCollection);

        CheckAndSave(CreateJsonStringFromObject(dfList), userCollectionFile);
    }