예제 #1
0
        public GameCenterChallenge(Dictionary <string, object> dict)
        {
            if (dict.ContainsKey("issuingPlayerID"))
            {
                issuingPlayerID = dict["issuingPlayerID"] as string;
            }

            if (dict.ContainsKey("receivingPlayerID"))
            {
                receivingPlayerID = dict["receivingPlayerID"] as string;
            }

            if (dict.ContainsKey("state"))
            {
                var intState = int.Parse(dict["state"].ToString());
                state = (GameCenterChallengeState)intState;
            }

            // grab and convert the dates
            if (dict.ContainsKey("issueDate"))
            {
                var timeSinceEpoch = double.Parse(dict["issueDate"].ToString());
                var intermediate   = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                issueDate = intermediate.AddSeconds(timeSinceEpoch);
            }

            if (dict.ContainsKey("completionDate"))
            {
                var timeSinceEpoch = double.Parse(dict["completionDate"].ToString());
                var intermediate   = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                completionDate = intermediate.AddSeconds(timeSinceEpoch);
            }

            if (dict.ContainsKey("message"))
            {
                message = dict["message"] as string;
            }

            // do we have a score or an achievement?
            if (dict.ContainsKey("score"))
            {
                score = Json.decodeObject <GameCenterScore>(dict["score"]);
            }

            if (dict.ContainsKey("achievement"))
            {
                achievement = new GameCenterAchievement(dict["achievement"] as Dictionary <string, object>);
            }

            if (dict.ContainsKey("hash"))
            {
                hash = dict["hash"].ToString();
            }
        }
		public GameCenterChallenge( Dictionary<string,object> dict )
		{
			if( dict.ContainsKey( "issuingPlayerID" ) )
				issuingPlayerID = dict["issuingPlayerID"] as string;

			if( dict.ContainsKey( "receivingPlayerID" ) )
				receivingPlayerID = dict["receivingPlayerID"] as string;

			if( dict.ContainsKey( "state" ) )
			{
				var intState = int.Parse( dict["state"].ToString() );
				state = (GameCenterChallengeState)intState;
			}

			// grab and convert the dates
			if( dict.ContainsKey( "issueDate" ) )
			{
				var timeSinceEpoch = double.Parse( dict["issueDate"].ToString() );
				var intermediate = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc );
				issueDate = intermediate.AddSeconds( timeSinceEpoch );
			}

			if( dict.ContainsKey( "completionDate" ) )
			{
				var timeSinceEpoch = double.Parse( dict["completionDate"].ToString() );
				var intermediate = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc );
				completionDate = intermediate.AddSeconds( timeSinceEpoch );
			}

			if( dict.ContainsKey( "message" ) )
				message = dict["message"] as string;

			// do we have a score or an achievement?
			if( dict.ContainsKey( "score" ) )
				score = Json.decodeObject<GameCenterScore>( dict["score"] );

			if( dict.ContainsKey( "achievement" ) )
				achievement = new GameCenterAchievement( dict["achievement"] as Dictionary<string,object> );

			if( dict.ContainsKey( "hash" ) )
				hash = dict["hash"].ToString();
		}