コード例 #1
0
    public List <ItemData> ConvertToItemDataList(string ObjectData)
    {
        ItemDataList itemDataList = new SocialPlay.Data.ItemDataList();

        string parsedString = ParseString(ObjectData);

        if (parsedString == "[]")
        {
            return(new List <ItemData>());
        }

        JsonReader reader = new JsonReader(parsedString);

        reader.Read();
        if (reader.Token.ToString() == "ArrayStart")
        {
            while (reader.Token.ToString() != "ArrayEnd")
            {
                reader.Read();

                CreateItemData(itemDataList, reader);
            }
        }
        else
        {
            CreateItemData(itemDataList, reader);
        }

        List <ItemData> items = CloudGoods.itemDataConverter.ConvertItems(itemDataList);

        return(items);
    }
コード例 #2
0
    public GeneratedItems ConvertToGeneratedItems(string dataString)
    {
        string   parsedString = ParseString(dataString);
        JsonData dataArray    = LitJson.JsonMapper.ToObject(parsedString);

        GeneratedItems generatedItems = new GeneratedItems();

        if (!int.TryParse(dataArray["GenerationId"].ToString(), out generatedItems.GenerationID))
        {
            Debug.LogError("GenerationID was not valid");
            generatedItems.GenerationID = 0;
        }

        ItemDataList itemDataList = new SocialPlay.Data.ItemDataList();

        JsonData itemsData = dataArray["Items"];

        for (int i = 0; i < itemsData.Count; i++)
        {
            SocialPlay.Data.ItemData newItemData = new SocialPlay.Data.ItemData();
            newItemData.Amount          = int.Parse(itemsData[i]["Amount"].ToString());
            newItemData.ItemID          = int.Parse(itemsData[i]["ItemID"].ToString());
            newItemData.Detail          = itemsData[i]["Detail"].ToString();
            newItemData.Name            = itemsData[i]["Name"].ToString();
            newItemData.BaseItemEnergy  = int.Parse(itemsData[i]["BaseItemEnergy"].ToString());
            newItemData.Energy          = int.Parse(itemsData[i]["Energy"].ToString());
            newItemData.Type            = int.Parse(itemsData[i]["Type"].ToString());
            newItemData.Image           = itemsData[i]["Image"].ToString();
            newItemData.Quality         = int.Parse(itemsData[i]["Quality"].ToString());
            newItemData.BaseItemID      = int.Parse(itemsData[i]["BaseItemID"].ToString());
            newItemData.Description     = itemsData[i]["Description"].ToString();
            newItemData.Behaviours      = itemsData[i]["Behaviours"].ToString();
            newItemData.AssetBundleName = itemsData[i]["AssetBundleName"].ToString();
            //newItemData.Tags = itemsData[i]["tags"].ToString();

            itemDataList.Add(newItemData);
        }

        List <ItemData> items = CloudGoods.itemDataConverter.ConvertItems(itemDataList, generatedItems.GenerationID);

        generatedItems.generatedItems = items;

        return(generatedItems);
    }
コード例 #3
0
    public List<ItemData> ConvertToItemDataList(string ObjectData)
    {
        ItemDataList itemDataList = new SocialPlay.Data.ItemDataList();

        string parsedString = ParseString(ObjectData);

        if (parsedString == "[]")
            return new List<ItemData>();

        JsonReader reader = new JsonReader(parsedString);
        Debug.Log(parsedString);
        reader.Read();

        if (reader.Token.ToString() == "ArrayStart")
        {
            while (reader.Token.ToString() != "ArrayEnd")
            {
                reader.Read();

                if (reader.Token.ToString() == "ObjectStart")
                {
                    SocialPlay.Data.ItemData itemData = new SocialPlay.Data.ItemData();

                    while (reader.Token.ToString() != "ObjectEnd")
                    {
                        reader.Read();

                        if (reader.Token.ToString() == "PropertyName")
                        {
                            Debug.Log(reader.Value.ToString());
                            string propertyString = reader.Value.ToString();

                            reader.Read();

                            if (propertyString == "StackLocationID")
                            {
                                itemData.StackLocationID = new Guid(reader.Value.ToString());
                                Debug.Log(itemData.StackLocationID.ToString());
                            }
                            if (propertyString == "Amount")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Amount = tmpInt;
                            }
                            if (propertyString == "Detail")
                            {
                                itemData.Detail = reader.Value.ToString();
                            }
                            if (propertyString == "ItemID")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.ItemID = tmpInt;
                            }
                            if (propertyString == "Type")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Type = tmpInt;
                            }
                            if (propertyString == "Location")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Location = tmpInt;
                            }
                            if (propertyString == "BaseItemEnergy")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.BaseItemEnergy = tmpInt;
                            }
                            if (propertyString == "Energy")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Energy = tmpInt;
                            }
                            if (propertyString == "SellPrice")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.SellPrice = tmpInt;
                            }
                            if (propertyString == "Name")
                            {
                                itemData.Name = reader.Value.ToString();
                            }
                            if (propertyString == "Image")
                            {
                                itemData.Image = reader.Value.ToString();
                            }
                            if (propertyString == "Quality")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Quality = tmpInt;
                            }
                            if (propertyString == "Behaviours")
                            {
                                itemData.Behaviours = reader.Value.ToString();
                            }
                            if (propertyString == "BaseItemID")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.BaseItemID = tmpInt;
                            }
                            if (propertyString == "Description")
                            {
                                itemData.Description = reader.Value.ToString();
                            }
                            if (propertyString == "AssetBundleName")
                            {
                                itemData.AssetBundleName = reader.Value.ToString();
                            }
                            if (propertyString == "Tags")
                            {
                                itemData.Tags = reader.Value.ToString();
                            }
                        }
                    }

                    itemDataList.Add(itemData);
                }
            }
        }

        List<ItemData> items = ItemConversion.converter.ConvertItems(itemDataList);

        return items;
    }
コード例 #4
0
    public List <ItemData> ConvertToItemDataList(string ObjectData)
    {
        ItemDataList itemDataList = new SocialPlay.Data.ItemDataList();

        string parsedString = ParseString(ObjectData);

        if (parsedString == "[]")
        {
            return(new List <ItemData>());
        }

        JsonReader reader = new JsonReader(parsedString);

        Debug.Log(parsedString);
        reader.Read();

        if (reader.Token.ToString() == "ArrayStart")
        {
            while (reader.Token.ToString() != "ArrayEnd")
            {
                reader.Read();

                if (reader.Token.ToString() == "ObjectStart")
                {
                    SocialPlay.Data.ItemData itemData = new SocialPlay.Data.ItemData();

                    while (reader.Token.ToString() != "ObjectEnd")
                    {
                        reader.Read();

                        if (reader.Token.ToString() == "PropertyName")
                        {
                            Debug.Log(reader.Value.ToString());
                            string propertyString = reader.Value.ToString();

                            reader.Read();

                            if (propertyString == "StackLocationID")
                            {
                                itemData.StackLocationID = new Guid(reader.Value.ToString());
                                Debug.Log(itemData.StackLocationID.ToString());
                            }
                            if (propertyString == "Amount")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Amount = tmpInt;
                            }
                            if (propertyString == "Detail")
                            {
                                itemData.Detail = reader.Value.ToString();
                            }
                            if (propertyString == "ItemID")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.ItemID = tmpInt;
                            }
                            if (propertyString == "Type")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Type = tmpInt;
                            }
                            if (propertyString == "Location")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Location = tmpInt;
                            }
                            if (propertyString == "BaseItemEnergy")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.BaseItemEnergy = tmpInt;
                            }
                            if (propertyString == "Energy")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Energy = tmpInt;
                            }
                            if (propertyString == "SellPrice")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.SellPrice = tmpInt;
                            }
                            if (propertyString == "Name")
                            {
                                itemData.Name = reader.Value.ToString();
                            }
                            if (propertyString == "Image")
                            {
                                itemData.Image = reader.Value.ToString();
                            }
                            if (propertyString == "Quality")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.Quality = tmpInt;
                            }
                            if (propertyString == "Behaviours")
                            {
                                itemData.Behaviours = reader.Value.ToString();
                            }
                            if (propertyString == "BaseItemID")
                            {
                                int tmpInt = 0;
                                int.TryParse(reader.Value.ToString(), out tmpInt);

                                itemData.BaseItemID = tmpInt;
                            }
                            if (propertyString == "Description")
                            {
                                itemData.Description = reader.Value.ToString();
                            }
                            if (propertyString == "AssetBundleName")
                            {
                                itemData.AssetBundleName = reader.Value.ToString();
                            }
                            if (propertyString == "Tags")
                            {
                                itemData.Tags = reader.Value.ToString();
                            }
                        }
                    }

                    itemDataList.Add(itemData);
                }
            }
        }

        List <ItemData> items = ItemConversion.converter.ConvertItems(itemDataList);

        return(items);
    }