コード例 #1
0
ファイル: Wallet.cs プロジェクト: brizee/KnetikUnitySDK
 public override void Deserialize(KnetikJSONNode json)
 {
     ID = json ["id"].AsInt;
     Balance = json ["balance"].AsDouble;
     CurrencyName = json ["currency_name"].Value;
     CurrencyCode = json ["code"].Value;
 }
コード例 #2
0
ファイル: Downloadable.cs プロジェクト: knetikmedia/UnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize(json);

            Assets = new Dictionary<string, ItemAsset>();
            URLs = new Dictionary<string, string>();

            if (json ["assets"].AsArray != null)
            {
                foreach (KnetikJSONNode node in json["assets"].Children)
                {
                    string slug = node ["slug"].Value;
                    ItemAsset asset = new ItemAsset(Client);
                    asset.Deserialize(node ["asset"]);
                    Assets.Add(slug, asset);
                    URLs.Add(slug, asset.URL);
                }
            } else if (json ["urls"].AsArray != null)
            {
                foreach (KnetikJSONNode node in json["urls"].Children)
                {
                    URLs.Add(node["name"].Value, node["url"].Value);
                }
            }
        }
コード例 #3
0
ファイル: ItemAsset.cs プロジェクト: knetikmedia/UnitySDK
 public override void Deserialize(KnetikJSONNode json)
 {
     ID = json ["id"].AsInt;
     Description = json ["description"].Value;
     Type = json ["type"].Value;
     Path = json ["path"].Value;
     URL = json ["url"].Value;
 }
コード例 #4
0
        public override void Deserialize(KnetikJSONNode json)
        {
			if(json["item"] != null)
			{
	            ID = json ["inventory_id"].AsInt;
	            Item = Item.Parse(Client, json ["item"]);
	            UseCount = json ["use_count"].AsInt;
			}
        }
コード例 #5
0
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);

            Relationships = new Dictionary<String, UserHierarchy> ();
            foreach (KeyValuePair<string, KnetikJSONNode> kvp in (KnetikJSONClass)json) {
                UserHierarchy relationship = new UserHierarchy(Client);
                relationship.Deserialize(kvp.Value);
                Relationships.Add(kvp.Key, relationship);
            }
        }
コード例 #6
0
ファイル: CatalogSku.cs プロジェクト: knetikmedia/UnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);

            ID = json["id"].AsInt;
            Sku = json["sku"].Value;
            Price = json["price"].AsDouble;
            Description = json["description"].Value;
            Inventory = json["inventory"].AsInt;
            CatalogID = json["catalog_id"].AsInt;
            CurrencyCode = json ["code"].Value;
        }
コード例 #7
0
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);

            Achievements = new List<Achievement> ();
            foreach (KnetikJSONNode node in json["achievement"].Children) {
                Achievement achievement = (Achievement)Item.Parse(Client, node);
                Achievements.Add(achievement);
            }

            HasMore = json ["hasMore"].AsBool;
        }
コード例 #8
0
ファイル: ItemAsset.cs プロジェクト: brizee/KnetikUnitySDK
        public override void Deserialize (KnetikJSONNode json)
        {
            ID = json ["id"].AsInt;
            Description = json ["description"].Value;
            Type = json ["type"].Value;
            Path = json ["path"].Value;
            if(json["slug"] != null && json["slug"].Value != null)
            {
                slug = json["slug"].Value;
            }
			url = json ["url"].Value;
            if(!string.IsNullOrEmpty(json["item_id"].Value))
			    itemId = json ["item_id"].AsInt;

        }
コード例 #9
0
ファイル: StoreQuery.cs プロジェクト: knetikmedia/UnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);

            Items = new List<Item> ();
            foreach (KnetikJSONNode node in json.Children) {
                Item item = Item.Parse(Client, node);
                if (ItemTypes == null || ItemTypes.Contains(item.TypeHint)) {
                    Items.Add(item);
                }
            }

            // JSAPI doesn't return hasMore so we keep paging until we get
            // a page with less than PageSize items.
            HasMore = Items.Count >= PageIndex * PageSize;
        }
コード例 #10
0
ファイル: Achievement.cs プロジェクト: brizee/KnetikUnitySDK
        public override void Deserialize (KnetikJSONNode json)
        {
            base.Deserialize (json);

            Value = json["value"].AsInt;
            
            int unearnedAssetId = json ["unearned_asset_id"].AsInt;
            int earnedAssetId = json ["earned_asset_id"].AsInt;
            
            foreach (ItemAsset asset in Assets) {
                if (asset.ID == unearnedAssetId) {
                    UnearnedAsset = asset;
                } else if (asset.ID == earnedAssetId) {
                    EarnedAsset = asset;
                }
            }
        }
コード例 #11
0
ファイル: Game.cs プロジェクト: brizee/KnetikUnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);
            UserOptions.Clear ();
            foreach (KnetikJSONNode node in json["user_item_options"].Children) {
                UserOption option = new UserOption(Client, this);
                option.Deserialize(node);
                UserOptions[option.Key] = option;
            }

            GameOptions.Clear ();
            foreach (KnetikJSONNode node in json["item_options"].Children) {
                GameOption option = new GameOption(Client, this);
                option.Deserialize(node);
                GameOptions[option.Key] = option;
            }
        }
コード例 #12
0
ファイル: ItemAsset.cs プロジェクト: brizee/KnetikUnitySDK
		public void setSlug (KnetikJSONNode behaviors)
		{
			if (behaviors != null) {
				foreach (KnetikJSONNode node in behaviors.Children) {
					if(node["assets"] != null)
					{
						foreach (KnetikJSONNode asset in node["assets"].Children) {
							if(asset["asset_id"].AsInt ==ID)
							{
								slug=asset["slug"].Value;
							}

						}
					}

				}
			}
		}
コード例 #13
0
ファイル: Leaderboard.cs プロジェクト: brizee/KnetikUnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);

            MetricID = json ["metric_id"].AsInt;
            SortStyle = json ["sort_style"].Value;
            QualifyingValue = json["qualifying_value"].AsInt;
            Size = json["size"].AsInt;
            PlayerCount = json["player_count"].AsInt;
            Level = json["level"].Value;
            MetricName = json["metric_name"].Value;
            Entries = new List<LeaderboardEntry>();

            foreach (KnetikJSONNode node in json["leaderboard_data"].Children)
            {
                LeaderboardEntry entry = new LeaderboardEntry();
                entry.Deserialize(node);
                Entries.Add(entry);
            }
        }
コード例 #14
0
ファイル: Inventory.cs プロジェクト: brizee/KnetikUnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            items = new Dictionary<int, List<InventoryItem>>();

            if (json != null && json.Count > 0)
            {
                foreach (KnetikJSONNode node in json.Children)
                {
                    InventoryItem invItem = new InventoryItem(Client);
                    invItem.Deserialize(node);
                    if (invItem.Item.ID > 0)
                    {
                        if (!items.ContainsKey(invItem.Item.ID))
                        {
                            items.Add(invItem.Item.ID, new List<InventoryItem>());
                        }
                        items [invItem.Item.ID].Add(invItem);
                    }
                }
            }
        }
コード例 #15
0
ファイル: Behavior.cs プロジェクト: brizee/KnetikUnitySDK
        public static Behavior Parse(KnetikClient client, KnetikJSONNode json)
        {
            Behavior behavior;

            string typeHint = json ["type_hint"].Value;

            switch (typeHint)
            {
                case "consumable":
                    behavior = new Consumable(client);
                    break;
                case "downloadable":
                    behavior = new Downloadable(client);
                    break;
                default:
                    behavior = new Behavior(client);
                    break;
            }

            behavior.Deserialize(json);

            return behavior;
        }
コード例 #16
0
ファイル: Leaderboard.cs プロジェクト: brizee/KnetikUnitySDK
 public void Deserialize(KnetikJSONNode json)
 {
     UserID = json["user_id"].AsInt;
     DisplayName = json["display_name"].Value;
     AvatarURL = json["avatar_url"].Value;
     Score = json["score"].AsDouble;
     Date = DateTime.Parse(json["date"].Value);
 }
コード例 #17
0
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);
            ID = json ["id"].AsInt;
            Username = json ["username"].Value;
            DisplayName = json ["display_name"].Value;
            Email = json ["email"].Value;
            FirstName = json ["first_name"].Value;
            LastName = json ["last_name"].Value;
            FullName = json ["fullname"].Value;
            Language = json ["language"].Value;
            AvatarURL = json ["avatar_url"].Value;
            Gender = json ["gender"].Value;

            Descendants = new List<UserHierarchyNode>();
            if (json ["descendants"] != null && json ["descendants"].Count > 0)
            {
                foreach (KnetikJSONNode node in json["descendants"].Children)
                {
                    UserHierarchyNode descendant = new UserHierarchyNode(Client);
                    descendant.Deserialize(node);
                    Descendants.Add(descendant);
                }
            }
        }
コード例 #18
0
ファイル: Option.cs プロジェクト: brizee/KnetikUnitySDK
 public override void Deserialize (KnetikJSONNode json)
 {
     ID = json ["id"].AsInt;
     Key = json ["keye"].Value;
     Value = json ["value"].Value;
 }
コード例 #19
0
ファイル: UserInfo.cs プロジェクト: knetikmedia/UnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            ID = json ["id"].AsInt;
            Email = json ["email"].ToString ();
            Username = json ["username"].Value;
            FullName = json ["fullname"].Value;
            MobileNumber = json ["mobile_number"].Value;
            AvatarURL = json ["avatar_url"].Value;
            FirstName = json ["first_name"].Value;
            LastName = json ["last_name"].Value;
            Token = json ["token"].Value;
            Gender = json ["gender"].Value;
            Language = json ["lang"].Value;
            Country = json ["country"].Value;
            Age = json ["age"].AsInt;

            string dobRaw = json ["date_of_birth"].Value;
            if (dobRaw != null && dobRaw != "null") {
                DateOfBirth = DateTime.Parse(dobRaw);
            }

            Wallets = new List<Wallet> ();
            if (json ["wallet"] != null && json ["wallet"].Count > 0)
            {
                foreach (KnetikJSONNode node in json["wallet"].Children)
                {
                    Wallet wallet = new Wallet(Client);
                    wallet.Deserialize(node);
                    Wallets.Add(wallet);
                }
            }
            Inventory = new Inventory(Client);
            if (json ["inventory"] != null)
            {
                Inventory.Deserialize(json ["inventory"]);
            }

            // Reset the dirty tracker since we have clean data
            dirtyTracker.Reset ();
        }
コード例 #20
0
 public override KnetikJSONNode Remove(KnetikJSONNode aNode)
 {
     try
     {
         iterList = null;
         var item = m_Dict.Where(k => k.Value == aNode).First();
         m_Dict.Remove(item.Key);
         return aNode;
     }
     catch
     {
         return null;
     }
 }
コード例 #21
0
 public override void Add(string aKey, KnetikJSONNode aItem)
 {
     iterList = null;
     if (!string.IsNullOrEmpty(aKey))
     {
         if (m_Dict.ContainsKey(aKey))
             m_Dict[aKey] = aItem;
         else
             m_Dict.Add(aKey, aItem);
     }
     else
         m_Dict.Add(Guid.NewGuid().ToString(), aItem);
 }
コード例 #22
0
 public virtual void Add(KnetikJSONNode aItem)
 {
     Add("", aItem);
 }
コード例 #23
0
 public virtual void Add(string aKey, KnetikJSONNode aItem)
 {
 }
コード例 #24
0
 public virtual KnetikJSONNode Remove(KnetikJSONNode aNode)
 {
     return aNode;
 }
コード例 #25
0
ファイル: Consumable.cs プロジェクト: brizee/KnetikUnitySDK
 public override void Deserialize(KnetikJSONNode json)
 {
     base.Deserialize(json);
     MaxUse = json ["max_use"].AsInt;
 }
コード例 #26
0
ファイル: Item.cs プロジェクト: brizee/KnetikUnitySDK
 public static Item Parse(KnetikClient client, KnetikJSONNode json)
 {
     string typeHint = json["type_hint"];
     Item item;
     switch (typeHint) {
         case "game":
         item = new Game(client);
         break;
         case "physical_item":
         item = new PhysicalItem(client);
         break;
         case "virtual_item":
         item = new VirtualItem(client);
         break;
         case "entitlement":
         item = new Entitlement(client);
         break;
         case "subscription":
         item = new Subscription(client);
         break;
         case "achievement_item":
         item = new Achievement(client);
         break;
         case "leaderboard":
         item = new Leaderboard(client);
         break;
         default:
         item = new Item(client);
         break;
     }
     item.Deserialize(json);
     return item;
 }
コード例 #27
0
ファイル: Item.cs プロジェクト: brizee/KnetikUnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            if(json == null || json.ToString() == "\"null\"")
            {
                return;
            }

            if (json ["id"] != null && json ["id"] != "null")
            {
                ID = json ["id"].AsInt;
            }

            UniqueKey = json ["unique_key"].Value;
            TypeHint = json ["type_hint"].Value;
            Name = json ["name"].Value;
            ShortDescription = json ["short_description"].Value;
            LongDescription = json ["long_description"].Value;

            Assets.Clear ();
            if (json ["assets"] != null) {
                foreach (KnetikJSONNode node in json["assets"].Children) {
                    ItemAsset asset = new ItemAsset (Client);
                    asset.Deserialize (node);
                    if (json ["behaviors"] != null) {
                        asset.setSlug(json ["behaviors"]);
                    }

                    Assets.Add (asset);
                }
            }

            Skus.Clear ();
            if (json ["skus"] != null) {
                foreach (KnetikJSONNode node in json["skus"].Children) {
                    CatalogSku sku = new CatalogSku (Client, this);
                    sku.Deserialize (node);
                    Skus.Add (sku);
                }
            }

            Behaviors.Clear();
            if (json ["behaviors"] != null) {
                foreach (KnetikJSONNode node in json["behaviors"].Children) {
                    Behavior behavior = Behavior.Parse (Client, node);
                    Behaviors.Add (behavior.TypeHint, behavior);
                }
            }

            if (json ["deleted_at"] != null && json ["deleted_at"] != "null")
            {
                DeletedAt = new DateTime (json ["deleted_at"].AsInt);
            }

            if (json ["date_created"] != null && json ["date_created"] != "null")
            {
                DateCreated = new DateTime (json ["date_created"].AsInt);
            }

            if (json ["date_updated"] != null && json ["date_updated"] != "null")
            {
                DateUpdated = new DateTime (json ["date_updated"].AsInt);
            }
        }
コード例 #28
0
ファイル: KnetikModel.cs プロジェクト: brizee/KnetikUnitySDK
 public virtual void Deserialize(KnetikJSONNode json) {}
コード例 #29
0
ファイル: CartItem.cs プロジェクト: brizee/KnetikUnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);

            ID = json["id"].AsInt;
            TypeHint = json["type_hint"].Value;
            SystemPrice = json["system_price"].AsDouble;
            UnitPrice = json["unit_price"].AsDouble;
            TotalPrice = json["total_price"].AsDouble;
            SkuID = json["sku_id"].AsInt;
            Sku = json["sku"].Value;
            SkuDescription = json["sku_description"].Value;
            Inventory = json["inventory"].AsInt;
            CatalogID = json["catalog_id"].AsInt;
            ItemID = json["store_item_id"].AsInt;
            Name = json["name"].Value;
            Thumbnail = json["thumbnail"].Value;
            ErrorMessage = json["error_message"].Value;
            ErrorCode = json["error_code"].AsInt;
        }
コード例 #30
0
ファイル: Cart.cs プロジェクト: knetikmedia/UnitySDK
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize (json);

            var cartJson = json["cart"];
            SubTotal = cartJson["sub_total"].AsDouble;
            DiscountTotal = cartJson["discount_total"].AsDouble;
            GrandTotal = cartJson["grand_total"].AsDouble;
            Tax = cartJson["tax"].AsDouble;
            Status = cartJson["status"].Value;

            Items.Clear();
            foreach (var node in json["items"].Children) {
                var item = new CartItem(Client, this);
                item.Deserialize(node);
                Items.Add(item);
            }
        }