Ejemplo n.º 1
0
        async void SetupChallenge()
        {
            playChallengeButton.Hidden = true;
            if (!GKLocalPlayer.LocalPlayer.Authenticated)
            {
                return;
            }

            var challenges = await GKChallenge.LoadReceivedChallengesAsync();

            if (challenges != null)
            {
                foreach (var challenge in challenges)
                {
                    var c = challenge as GKScoreChallenge;
                    if (c != null)
                    {
                        SelectChallenge(c);
                        break;
                    }
                }
            }

            var listener = new PlayerListener();

            listener.DidReceiveChallengeAction = (player, challenge) => {
                if (player == GKLocalPlayer.LocalPlayer)
                {
                    var c = challenge as GKScoreChallenge;
                    if (c != null)
                    {
                        SelectChallenge(c);
                    }
                }
            };
            GKLocalPlayer.LocalPlayer.RegisterListener(listener);
        }
		async void SetupChallenge ()
		{
			playChallengeButton.Hidden = true;
			if (!GKLocalPlayer.LocalPlayer.Authenticated)
				return;

			var challenges = await GKChallenge.LoadReceivedChallengesAsync ();
			if (challenges != null) {
				foreach (var challenge in challenges) {
					var c = challenge as GKScoreChallenge;
					if (c != null) {
						SelectChallenge (c);
						break;
					}
				}
			}

			var listener = new PlayerListener ();
			listener.DidReceiveChallengeAction = (player, challenge) => {
				if (player == GKLocalPlayer.LocalPlayer) {
					var c = challenge as GKScoreChallenge;
					if (c != null)
						SelectChallenge (c);
				}
			};
			GKLocalPlayer.LocalPlayer.RegisterListener (listener);
		}