partial void OnGoTouched(MonoTouch.Foundation.NSObject sender) { PlayerCache.Instance.AuthenticatedPlayer.NewMatch( // Match found (match) => { // Ensure it's a new match if (match.IsFirstTurn) { PlayerCache.Instance.AuthenticatedPlayer.SetMatch(match); mGameLauncher = new GameLauncher(this); // float diffi mGameLauncher.Launch(VersusToGameSegueId, GameMode.SCORE, GameDifficulty.EASY, new Filter()); } // else { // var appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate; // // if (match.IsEnded) { // // See the final score // Dialogs.ShowMatchEnded (); // } else { // if (match.IsPlayerTurn (PlayerCache.Instance.AuthenticatedPlayer.PlayerId)) { // // Player turn // LaunchGame (mode, match.Difficulty, match.Filter); // } else { // // TODO Other player turn: display last score? // Dialogs.ShowNotYourTurn (); // } // } // } }, // Cancel () => { // Nothing, controller is already dismissed }, // Error () => { // Display an error dialog? UIAlertView alert = new UIAlertView( "Une erreur est survenue", "Nous n'avons pas pu démarrer une nouvelle partie car une erreur est survenue..", null, "Ok"); alert.Show(); }, // Player quit () => { // Kill the game? Inform the player? } ); }
public override void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath) { VersusMatch match = matchs[indexPath.Item]; if (match.IsEnded == false && match.IsPlayerTurn(PlayerCache.Instance.AuthenticatedPlayer.PlayerId)) { PlayerCache.Instance.AuthenticatedPlayer.SetMatch(match); mGameLauncher = new GameLauncher(this); mGameLauncher.Launch("VersusToGame", GameMode.VERSUS, match.Difficulty, match.Filter); } }
/// <summary> /// Pop-up the difficulty chooser /// </summary> /// <param name="selectedMode">Selected mode.</param> private void DisplayDifficultyChooser(GameMode selectedMode) { // Display difficulty view if (_challengeViewController == null) { _challengeViewController = new CardChallengeViewController(); _challengeViewController.Hidden += HideChallengeCard; _challengeViewController.DifficultySelected += (GameMode mode, GameDifficulty difficulty) => { var appDelegate = (AppDelegate) UIApplication.SharedApplication.Delegate; Filter filter = null; // Remember to select Versus match parameters too if (mode == GameMode.VERSUS) { VersusMatch currentMatch = PlayerCache.Instance.AuthenticatedPlayer.CurrentMatch; currentMatch.Difficulty = difficulty; filter = currentMatch.Filter; // This is weird } _gameLauncher = new GameLauncher(this); _gameLauncher.Launch("MenuToGame", mode, difficulty, filter); }; } // Set mode _challengeViewController.SetMode(selectedMode); ShowChallengeCard(); }