Beispiel #1
0
        public DialogueLayout(DialogueResponse DResponse, ContentPageController ViewController)
        {
            var labelLarge = new Label
            {
                Text = "Message From Server",
                FontSize = 25,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = 55
            };

            var DialogueLabel = new Label
            {
                Text = DResponse.Dialogue,
                FontSize = 30,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = 110
            };

            dialoguebutton = new Button
            {
                Text = "Ok",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
                VerticalOptions = LayoutOptions.Fill,
                //TranslationY = 2,
                HeightRequest = 55
                //IsVisible = false,
            };
            // The View
            DiaLayout = new StackLayout
            {
                Children =
                {
                    labelLarge,
                    DialogueLabel,
                    dialoguebutton
                },
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };


            dialoguebutton.Clicked += (sender, args) =>
            {
                ViewController.Invoke(() => dialoguebutton.IsEnabled = false);
                // return to previous sceen
                Display(ViewController, StoredContent);
                ViewController.Invoke(() => dialoguebutton.IsEnabled = false);
            };

            StoredContent = ViewController.View.Content;
            Display(ViewController);
        }
Beispiel #2
0
        //Home Screen
        public HomeLayout(ContentPageController ViewController, bool bypassLogIn)
        {
            HLayout = new StackLayout
            {
                BackgroundColor = Color.FromHex("1393c3"),
                Children =
                {
                    new Image
                    {
                        Source = "unsafespaceslogo.png"
                    },
                    new Label
                    {
                        Text = "#nooneissafe",
                        FontSize = 20,
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions = LayoutOptions.Start,
                        HeightRequest = 25
                    },
                    new Image
                    {
                        Source = "shocked_smile.png"
                    }
                }
            };
            StartButton = new Button
            {
                Text = "Play \u25B6",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
                HorizontalOptions = LayoutOptions.Center,
                //VerticalOptions = LayoutOptions.Fill,
                WidthRequest = 120
            };
            HLayout.Children.Add(StartButton);

            StartButton.Clicked += (sender, args) =>
            {
                ViewController.Invoke(() => StartButton.Text = "Loading \u25B6");
                StartButton.IsEnabled = false;
                if (bypassLogIn)
                {
                    var GSlayout = new GameSelectLayout(ViewController);
                }
                else
                {
                    ViewController.Invoke(() => ViewController.View.Content = ViewController.LogIn.LILayout);
                }
                StartButton.IsEnabled = true;
            };
            Display(ViewController);
        }
Beispiel #3
0
 internal void Display(ContentPageController ViewController)
 {
     ViewController.Invoke(() => GameManager.ViewController.View.Content = GLLayout);
 }
Beispiel #4
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 #5
0
 internal void Display(ContentPageController ViewController)
 {
     ViewController.Invoke(() => { ViewController.View.Content = QLayout; });
 }
Beispiel #6
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 #7
0
        // Voting Page
        public VoteLayout(VoteResponse VResponse, ContentPageController ViewController)
        {
            var inputs = VResponse.PlayerAnswers;
            var RoundNumber = VResponse.RoundNumber;

            var RoundLabel = new Label
            {
                Text = "Round " + RoundNumber,
                FontSize = 30,
                HorizontalOptions = LayoutOptions.Center
                //HeightRequest = 150
            };

            var AnswerImage = new Image
            {
                Source = "answer_now.png"
            };

            listview = new ListView
            {
                ItemsSource = inputs,
                HeightRequest = 30,
                ItemTemplate = new DataTemplate(() =>
                {
                    var textlabel = new Label
                    {
                        TextColor = Color.FromRgb(31, 174, 206)
                    };

                    var cell = new ViewCell
                    {
                        View = new StackLayout
                        {
                            Children =
                            {
                                textlabel
                            }
                        }
                    };

                    textlabel.SetBinding(Label.TextProperty, "Answer");

                    /*
                    TextCell cell = new TextCell();
                    cell.SetBinding(TextCell.TextProperty, "Answer");
                    */
                    return cell;
                })
                //RowHeight = 150,
            };

            VLayout = new StackLayout
            {
                Children =
                {
                    RoundLabel,
                    AnswerImage,
                    listview
                },
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };

            listview.ItemSelected += async (sender, args) =>
            {
                ViewController.Invoke(() => listview.IsEnabled = false);
                // GameManager.ViewController.Invoke(() => GameManager.CurrentGame.CurrentVoteChoice = ((PlayerInput)args.SelectedItem).PlayerID);

                var item = args.SelectedItem as PlayerAnswer;
                await GameManager.Vote(item.PlayerId);
                ViewController.Invoke(() => listview.IsEnabled = true);
                ViewController.Invoke(() => ((ListView) sender).SelectedItem = null);
            };

            Display(ViewController);
        }
Beispiel #8
0
        //Shows Results Page
        public ResultsLayout(ResultsResponse RResponse, ContentPageController ViewController)
        {
            var Input = RResponse.PlayerInputs;
            var PlayerGames = RResponse.PlayerGames;
            var roundnumber = RResponse.RoundNumber;
            var Admin = RResponse.Admin;


            var RoundLabel = new Label
            {
                Text = "Round " + roundnumber,
                FontSize = 35,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = 55
            };

            var ResultsImage = new Image
            {
                Source = "results.png"
            };

            nextRoundButton = new Button
            {
                Text = "Next Round",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
                VerticalOptions = LayoutOptions.Fill,
                //TranslationY = 2,
                HeightRequest = 55
                //IsVisible = false,
            };

            ResLayout = new StackLayout
            {
                Children =
                {
                    RoundLabel,
                    ResultsImage
                },
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };

            foreach (var p in Input)
            {
                ResLayout.Children.Add(new Label
                {
                    Text = p.Name + ": " + p.Score,
                    HorizontalOptions = LayoutOptions.Center,
                    FontSize = 15
                });
            }

            if (Admin)
            {
                ResLayout.Children.Add(nextRoundButton);
            }

            var TotalScoreImage = new Image
            {
                Source = "total_score.png"
            };
            ResLayout.Children.Add(TotalScoreImage);

            //order players by points, then display
            foreach (var p in PlayerGames.OrderByDescending(pg => pg.Points).ToArray())
            {
                ResLayout.Children.Add(new Label
                {
                    Text = p.Name + ": " + p.Points,
                    HorizontalOptions = LayoutOptions.Center,
                    FontSize = 15
                });
            }

            var VoteStatsImage = new Image
            {
                Source = "statistics.png"
            };
            ResLayout.Children.Add(VoteStatsImage);

            foreach (var p in Input)
            {
                ResLayout.Children.Add(new Label
                {
                    Text = p.Name + "'s Answer:   " + p.Answer,
                    FontSize = 15,
                    HorizontalOptions = LayoutOptions.Center
                });

                var tempInputs = Input.Where(pi => pi.Vote == p.PlayerId).Select(pi => pi.Name);
                var whoVoted = string.Join(", ", tempInputs);


                ResLayout.Children.Add(new Label
                {
                    Text = "Votes: " + whoVoted,
                    HorizontalOptions = LayoutOptions.Center,
                    FontSize = 10,
                    HeightRequest = 40
                });
            }


            nextRoundButton.Clicked += async (sender, args) =>
            {
                ViewController.Invoke(() => nextRoundButton.IsEnabled = false);
                //nextRoundButon.Text = "starting next round";
                await GameManager.NewRound();
                ViewController.Invoke(() => nextRoundButton.IsEnabled = false);
            };


            Display(ViewController);
        }
Beispiel #9
0
 internal void Display(ContentPageController ViewController, View StoredContent)
 {
     ViewController.Invoke(() => { ViewController.View.Content = StoredContent; });
 }
Beispiel #10
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();
        }
Beispiel #11
0
        public EndOfGameLayout(EndOfGameResponse EOGResponse, ContentPageController ViewController)
        {
            var Input = EOGResponse.PlayerInputs;
            var PlayerGames = EOGResponse.PlayerGames;

            var labelLarge = new Label
            {
                Text = "Final Results",
                FontSize = 30,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = 55
            };

            EndButton = new Button
            {
                Text = "End Game",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof (Button)),
                VerticalOptions = LayoutOptions.Fill,
                //TranslationY = 2,
                HeightRequest = 55
                //IsVisible = false,
            };

            EOGLayout = new StackLayout
            {
                Children =
                {
                    labelLarge
                },
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };
            // Show Final Points
            foreach (var p in PlayerGames.OrderByDescending(pg => pg.Points).ToArray())
            {
                EOGLayout.Children.Add(new Label
                {
                    Text = p.Name + ": " + p.Points,
                    HorizontalOptions = LayoutOptions.Center,
                    FontSize = 15
                });
            }

            EOGLayout.Children.Add(EndButton);

            var TotalLabel = new Label
            {
                Text = "Round 15 Results",
                FontSize = 30,
                HorizontalOptions = LayoutOptions.Center,
                HeightRequest = 55
            };
            EOGLayout.Children.Add(TotalLabel);

            //order players by points, then display
            foreach (var p in Input)
            {
                EOGLayout.Children.Add(new Label
                {
                    Text = p.Name + ": " + p.Score,
                    HorizontalOptions = LayoutOptions.Center,
                    FontSize = 15
                });
            }

            var VoteStatsImage = new Image
            {
                Source = "statistics.png"
            };
            EOGLayout.Children.Add(VoteStatsImage);

            //Show who voted for what
            foreach (var p in Input)
            {
                EOGLayout.Children.Add(new Label
                {
                    Text = p.Name + "'s Answer:   " + p.Answer,
                    FontSize = 15,
                    HorizontalOptions = LayoutOptions.Center
                });

                var tempInputs = Input.Where(pi => pi.Vote == p.PlayerId).Select(pi => pi.Name);
                var whoVoted = string.Join(", ", tempInputs);


                EOGLayout.Children.Add(new Label
                {
                    Text = "Votes: " + whoVoted,
                    HorizontalOptions = LayoutOptions.Center,
                    FontSize = 10,
                    HeightRequest = 40
                });
            }


            EndButton.Clicked += (sender, args) =>
            {
                ViewController.Invoke(() => EndButton.IsEnabled = false);
                //nextRoundButon.Text = "starting next round";
                GameManager.EndGame();
                ViewController.Invoke(() => EndButton.IsEnabled = false);
            };


            Display(ViewController);
        }
Beispiel #12
0
        public NavigationDrawer()
        {
            Title = "Lee Game";
            ViewController = new ContentPageController(this);
            string[] temp = {"Refresh Game", "Switch Games", "How To Play", "Logout"};

            listView = GetListView(temp);


            MasterPage = new ContentPage
            {
                Title = "Options",
                Content = listView,
                Icon = "hamburger.png",
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };

            Master = MasterPage;

            MasterPage.IsVisible = false;
            //menu buttons & handlers
            listView.ItemTapped += async (sender, e) =>
            {
                switch (e.Item.ToString())
                {
                    case "Refresh Game":
                        if (InGame) await GameManager.RefreshGame().ConfigureAwait(false); //.ConfigureAwait(false);
                        ViewController.Invoke(() => IsPresented = false);
                        break;
                    case "Switch Games":
                        var GameSelect = new GameSelectLayout(ViewController);
                        ViewController.Invoke(() => IsPresented = false);
                        break;
                    case "Logout":
                        ViewController.LogInManager.LogOut();
                        ViewController.Invoke(() => IsPresented = false);
                        break;
                    case "How To Play":
                        ViewController.Invoke(() => ((ListView) sender).SelectedItem = null);
                        var OkButton = new Button
                        {
                            Text = "Back To Menu",
                            FontSize = 15,
                            HorizontalOptions = LayoutOptions.Center,
                            HeightRequest = 50
                        };
                        var tempstack = new StackLayout
                        {
                            Children =
                            {
                                /*
                                new Label
                                {
                                     Text = "How To Play",
                                     FontSize = 30,
                                     HorizontalOptions = LayoutOptions.Center,
                                     HeightRequest = 50,
                                },
                                */
                                new Image
                                {
                                    Source = "how_to_play.png"
                                },
                                new Label
                                {
                                    Text = HowToPlayOne,
                                    FontSize = 18,
                                    HorizontalOptions = LayoutOptions.Center
                                },
                                new Label
                                {
                                    Text = HowToPlayTwo,
                                    FontSize = 18,
                                    HorizontalOptions = LayoutOptions.Center
                                },
                                new Label
                                {
                                    Text = HowToPlayThree,
                                    FontSize = 18,
                                    HorizontalOptions = LayoutOptions.Center
                                },
                                OkButton
                            }
                        };

                        ViewController.Invoke(() => MasterPage.Content = tempstack);

                        OkButton.Clicked +=
                            (senderer, args) => { ViewController.Invoke(() => MasterPage.Content = listView); };
                        break;
                    default:
                        ViewController.Invoke(() => IsPresented = false);
                        break;
                }
                ViewController.Invoke(() => ((ListView) sender).SelectedItem = null);
            };


            Detail = new NavigationPage(ViewController);
        }