Beispiel #1
0
        //Shows Question Page
        public QuestionLayout(QuestionResponse QResponse, ContentPageController ViewController)
        {
            var question = QResponse.Question;
            var RoundNumber = QResponse.RoundNumber;

            var RoundLabel = new Label
            {
                Text = "Round " + RoundNumber,
                FontSize = 30,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = 150
            };
            var questionlabel = new Label
            {
                Text = question,
                FontSize = 20,
                HorizontalOptions = LayoutOptions.StartAndExpand
            };
            QuestionAnswer = new Entry
            {
                Placeholder = "Answer Here",
                VerticalOptions = LayoutOptions.Center,
                Keyboard = Keyboard.Text
            };
            button = new Button
            {
                Text = "Submit!",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Fill
            };
            QLayout = new StackLayout
            {
                Children =
                {
                    RoundLabel,
                    questionlabel,
                    QuestionAnswer,
                    button
                },
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };

            button.Clicked += async (sender, args) =>
            {
                ViewController.Invoke(() => button.IsEnabled = false);
                if (QuestionAnswer.Text != null)
                {
                    await GameManager.Answer(QuestionAnswer.Text);
                }
                else
                {
                    ViewController.Invoke(() =>
                        ViewController.DisplayAlert("Nothing in Answer", "Don't forget to answer before submitting.",
                            "OK").ConfigureAwait(false));
                }
                ViewController.Invoke(() => button.IsEnabled = true);
            };

            Display(ViewController);
        }
Beispiel #2
0
        public GameLobbyLayout(GameLobbyResponse GLResponse, ContentPageController ViewController)
        {
            var Players = GLResponse.Names;
            var Admin = GLResponse.Admin;

            var labelLarge = new Label
            {
                Text = "Waiting Room",
                FontSize = 30,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = 80
            };

            adminLabel = new Label
            {
                Text = "GameID = " + GLResponse.GameId,
                FontSize = 20,
                HorizontalOptions = LayoutOptions.Center
                //IsVisible = false,
            };

            startgamebutton = new Button
            {
                Text = "Start Game",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
                VerticalOptions = LayoutOptions.Fill,
                TranslationY = 2,
                HeightRequest = 55
                //IsVisible = false,
            };
            //view
            GLLayout = new StackLayout
            {
                Children =
                {
                    labelLarge
                    //adminLabel
                    //startgamebutton,
                    //entry,
                    //boxView,
                    //image 
                },
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
                //HeightRequest = 1500
            };
            //Show Start Game Button if Admin
            if (Admin)
            {
                GLLayout.Children.Insert(1, adminLabel);
                GLLayout.Children.Add(startgamebutton);
            }


            foreach (var p in GLResponse.Names)
            {
                GLLayout.Children.Add(new Label {Text = p, HorizontalOptions = LayoutOptions.Center, FontSize = 20});
            }

            startgamebutton.Clicked += async (sender, args) =>
            {
                ViewController.Invoke(() => startgamebutton.IsEnabled = false);
                if (GLResponse.Names.Length >= 3)
                {
                    startgamebutton.Text = "Starting Game";
                    await GameManager.StartGame();
                }
                else
                {
                    ViewController.Invoke(() =>
                        ViewController.DisplayAlert("Not Enough Players", "Need 3 or more players to start.", "OK")
                            .ConfigureAwait(false));
                }
                ViewController.Invoke(() => startgamebutton.IsEnabled = true);
            };

            Display(ViewController);
        }
Beispiel #3
0
        //Layout for game selection
        public GameSelectLayout(ContentPageController ViewController)
        {
            //GameID = "641b0eda";
            ViewController.NavDrawer.ShowLayoutMenu();
            var SelectGame = new Image
            {
                Source = "select_game.png"
            };
            var gamelabel = new Label
            {
                Text = "Enter Game Number:",
                FontSize = 20,
                HorizontalOptions = LayoutOptions.StartAndExpand
            };
            var GameNumberEntry = new Entry
            {
                //Placeholder = GameID,
                VerticalOptions = LayoutOptions.Center,
                Keyboard = Keyboard.Text,
                //HeightRequest = 75
                WidthRequest = 180
            };

            gamebutton = new Button
            {
                Text = "Play \u25B6",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
                HorizontalOptions = LayoutOptions.End,
                //VerticalOptions = LayoutOptions.Fill,
                WidthRequest = 120
                //HeightRequest = 50,
                //TranslationY= 15,
            };

            newgamebutton = new Button
            {
                Text = "Create New Game \u25B6",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
                VerticalOptions = LayoutOptions.Fill,
                TranslationY = 2,
                HeightRequest = 55
            };

            var RecentImage = new Image
            {
                Source = "recent_games.png"
            };

            InfoLabel = new Label
            {
                Text = "Gathering Recent Games...",
                FontSize = 20,
                HorizontalOptions = LayoutOptions.StartAndExpand
            };

            GSLayout = new StackLayout
            {
                Children =
                {
                    SelectGame,
                    gamelabel,
                    new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children =
                        {
                            GameNumberEntry,
                            gamebutton
                        }
                    },
                    newgamebutton,
                    RecentImage,
                    InfoLabel
                },
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };

            gamebutton.Clicked += async (sender, args) =>
            {
                ViewController.Invoke(() => gamebutton.IsEnabled = false);
                if (GameNumberEntry.Text != null)
                {
                    //Pass control on to Game from here on out
                    gamebutton.Text = "Joining";
                    //DEBUG
                    //await GameManager.JoinGame(this.GameID); 

                    //RELEASE
                    await GameManager.JoinGame(GameNumberEntry.Text);
                    ViewController.Invoke(() => gamebutton.IsEnabled = true);
                }
                else
                {
                    ViewController.Invoke(() =>
                        ViewController.DisplayAlert("Nothing in Answer",
                            "Don't forget to input answer before submitting.", "OK").ConfigureAwait(false));
                }
            };

            newgamebutton.Clicked += async (sender, args) =>
            {
                //Pass control on to Game from here on out
                ViewController.Invoke(() => newgamebutton.IsEnabled = false);
                await GameManager.CreateGame();
                ViewController.Invoke(() => newgamebutton.IsEnabled = false);
            };

            GameManager.GetActiveGames(this).ConfigureAwait(false);

            Display();
        }