コード例 #1
0
        private async void CreateGame()
        {
            var result = await Dialogs.PromptAsync("Spielname eingeben", okText : "Spiel erstellen", cancelText : "Abbrechen",
                                                   placeholder : "Spielname");

            if (result.Ok)
            {
                ShowLoading("Erstelle Spiel");

                try
                {
                    var game = await Service.CreateGame(result.Text);

                    PushViewModal(new GameLobbyView(game));
                }
                catch (FaultException)
                {
                    throw;
                }
                catch (Exception e) when(e is TimeoutException || e is CommunicationException)
                {
                    Dialogs.AlertNoConnection();
                }
                finally
                {
                    HideLoading();
                }
            }
        }
コード例 #2
0
        private async void TestIfAlreadyInGameAsync()
        {
            ShowLoading("Überprüfe Spielzustand");

            Game game = null;

            try
            {
                game = await Service.GetCurrentGame();
            }
            catch (FaultException)
            {
                throw;
            }
            catch (Exception e) when(e is TimeoutException || e is CommunicationException)
            {
                Dialogs.AlertNoConnection();
            }
            finally
            {
                HideLoading();
            }

            if (game != null)
            {
                if (game.IsInLobby())
                {
                    PushViewModal(new GameLobbyView(game));
                }
                else if (game.IsConfiguringBoard())
                {
                    var isCreator = game.ThisPlayerIsGameCreator();
                    if (isCreator && game.RunningGameState.BoardCreator == null ||
                        !isCreator && game.RunningGameState.BoardParticipant == null)
                    {
                        PushViewModal(new ConfigureBoardView(game));
                    }
                    else
                    {
                        PushViewModal(new InGameView(game));
                    }
                }
                else if (game.IsPlaying())
                {
                    PushViewModal(new InGameView(game));
                }
                else
                {
                    throw new Exception("Dieser Fall sollte niemals eintreten");
                }
            }
        }