//public System.Collections.Generic.List<VirtualGoodLeaderBoardData> VirtualGoodList; //public VirtualGoodData participationVirtualGood { get; set; } public static LeaderBoardMetadata ParseFromDictionary(System.Collections.Generic.Dictionary <string, object> metadataDict) { LeaderBoardMetadata leaderBoardMetadata = new LeaderBoardMetadata(); if (metadataDict.ContainsKey("name")) { leaderBoardMetadata.Name = Convert.ToString(metadataDict["name"]); } if (metadataDict.ContainsKey("gamedata")) { leaderBoardMetadata.GameData = Convert.ToString(metadataDict["gamedata"]); } /* * if( metadataDict.ContainsKey( "virtualGoods" ) ) { * System.Collections.Generic.List<VirtualGoodLeaderBoardData> virtualGoodList = new System.Collections.Generic.List<VirtualGoodLeaderBoardData>(); * System.Collections.Generic.List<object> virtualGoodListObjects = metadataDict["virtualGoods"] as System.Collections.Generic.List<object>; * foreach( object virtualGoodObject in virtualGoodListObjects ) { * System.Collections.Generic.Dictionary<string,object> virtualGoodObjectDict = virtualGoodObject as System.Collections.Generic.Dictionary<string,object>; * VirtualGoodLeaderBoardData virtualGoodLeaderBoardData = VirtualGoodLeaderBoardData.ParseFromDictionary( virtualGoodObjectDict ); * virtualGoodList.Add( virtualGoodLeaderBoardData ); * } * leaderBoardMetadata.VirtualGoodList = virtualGoodList; * } */ /* * if( metadataDict.ContainsKey( "participationVirtualGood" ) && !String.IsNullOrEmpty(metadataDict["participationVirtualGood"].ToString())) { * VirtualGoodData virtualGood = new VirtualGoodData(); * System.Collections.Generic.Dictionary<string,object> virtualGoodDict = metadataDict["participationVirtualGood"] as System.Collections.Generic.Dictionary<string,object>; * if( virtualGoodDict.ContainsKey( "iconUrl" ) ) { * virtualGood.IconUrl = Convert.ToString( virtualGoodDict["iconUrl"]); * } * if( virtualGoodDict.ContainsKey( "description" ) ) { * virtualGood.Description = Convert.ToString( virtualGoodDict["description"] ); * } * if( virtualGoodDict.ContainsKey( "id" ) ) { * virtualGood.Id = Convert.ToString( virtualGoodDict["id"] ); * } * if( virtualGoodDict.ContainsKey( "goodId" ) ) { * virtualGood.GoodId = Convert.ToString( virtualGoodDict["goodId"] ); * } * virtualGood.Init(); * * leaderBoardMetadata.participationVirtualGood = virtualGood; * } */ return(leaderBoardMetadata); }
public override void Create(System.Collections.Generic.Dictionary <string, object> dataDict) { Debug.Log("IgniteLeaderBoard:Create"); base.Create(dataDict); if (dataDict.ContainsKey("currentUserId")) { this.CurrentUserId = Convert.ToString(dataDict["currentUserId"]); } if (dataDict.ContainsKey("rule")) { System.Collections.Generic.Dictionary <string, object> leaderBoardRuleDict = dataDict["rule"] as System.Collections.Generic.Dictionary <string, object>; this.Rule = LeaderBoardRuleData.ParseFromDictionary(leaderBoardRuleDict); } this.Leaders = new System.Collections.Generic.List <LeaderData>(); if (dataDict.ContainsKey("leaderList")) { System.Collections.Generic.Dictionary <string, object> leaderListDict = dataDict["leaderList"] as System.Collections.Generic.Dictionary <string, object>; if (leaderListDict.ContainsKey("leaders")) { System.Collections.Generic.List <object> leaderList = leaderListDict["leaders"] as System.Collections.Generic.List <object>; int position = 1; foreach (object leaderObject in leaderList) { System.Collections.Generic.Dictionary <string, object> leaderDict = leaderObject as System.Collections.Generic.Dictionary <string, object>; LeaderData leaderData = LeaderData.ParseFromDictionary(leaderDict); if (this.CurrentUserId == leaderData.Id) { leaderData.IsCurrentUser = true; } leaderData.Rank = position; this.Leaders.Add(leaderData); position++; } } } if (dataDict.ContainsKey("metadata")) { System.Collections.Generic.Dictionary <string, object> metadataDict = dataDict["metadata"] as System.Collections.Generic.Dictionary <string, object>; this.Metadata = LeaderBoardMetadata.ParseFromDictionary(metadataDict); } }