Exemplo n.º 1
0
 public PlayerViewSleep()
 {
     this.InitializeComponent();
     _signInFlow = ProgramContainer.container.GetInstance <ISignInFlow>();
     player      = _signInFlow.GetPlayer();
     Init();
 }
Exemplo n.º 2
0
 public PlayerViewRecentActivities()
 {
     this.InitializeComponent();
     _signInFlow      = ProgramContainer.container.GetInstance <ISignInFlow>();
     _activityFetcher = ProgramContainer.container.GetInstance <IActivityFetcher>();
     player           = _signInFlow.GetPlayer();
     Init();
 }
        public NewUnassignedPlayerSeeGoals()
        {
            this.InitializeComponent();
            _IProgressFetcher = ProgramContainer.container.GetInstance <IProgressFetcher>();
            _signInFlow       = ProgramContainer.container.GetInstance <ISignInFlow>();
            _IGoalsHandler    = ProgramContainer.container.GetInstance <IGoalsHandler>();

            player = _signInFlow.GetPlayer();

            welcome.Text = $"OK {player.FirstName}, these are the goals your coach assigned you!";
            InitAllProgressBars(null, null);
        }
Exemplo n.º 4
0
 public Game_Hub()
 {
     this.InitializeComponent();
     _signInFlow          = ProgramContainer.container.GetInstance <ISignInFlow>();
     _IBalanceHandler     = ProgramContainer.container.GetInstance <IBalanceHandler>();
     _IUserTypeRepository = ProgramContainer.container.GetInstance <UserTypeRepository>();
     player         = _signInFlow.GetPlayer();
     CoachAndPlayer = false;
     if (_IUserTypeRepository.GetUserType(player.UserId).UserType == UserType.CoachAndPlayer)
     {
         ToBeACoach.Content = "Switch to Coach mode";
     }
     welcome.Text  = "Hey " + player.FirstName + ", welcome to the game hub\n";
     crystals.Text = "You have " + _IBalanceHandler.GetBalance() + " crystals!\n";
 }
 public NewUnassignedPlayerExplenations()
 {
     _signInFlow = ProgramContainer.container.GetInstance <ISignInFlow>();
     this.InitializeComponent();
     _userTypeRepository = ProgramContainer.container.GetInstance <UserTypeRepository>();
     player = _signInFlow.GetPlayer();
     if (Coach_Lobby.CoachAndPlayer)
     {
         _userTypeRepository.SaveUserType(player.UserId, UserType.CoachAndPlayer);
         ((SignInFlow)_signInFlow).SaveUserToLocalStorage(UserType.Player);
     }
     welcome.Text = "Hi " + player.FirstName + ".\n" +
                    "You will soon see the goals your coach assigned you, but first... some explanations about boost\n" +
                    "\n" +
                    "Your coach assigned you daily (and possibly) weekly goals, once you complete a goal you will recive a certian amount of crystals (chosen by your coach). But you can also get crystals if your coach is impressed by a certian activity you had.\n" +
                    "\n" +
                    "You can spend Your crystals in the Game Hub. There you will be able to play cool and exciting games such as Tic Tac Toe !\n" +
                    "\n" +
                    "Are you ready?\n";
 }
Exemplo n.º 6
0
        public async void log_in_button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var _tokenGenerator = new HealthTokenGenerator();
                await _tokenGenerator.GetHealthAuthenticationToken();

                var userType = _signInFlow.SignIn();

                if (userType == UserType.CoachAndPlayer)
                {
                    var messageDialog = new MessageDialog("Hey! We noticed you are both a coach and a player. As what would you like to log in as?");
                    messageDialog.Commands.Add(new UICommand("Coach")
                    {
                        Id = 0
                    });
                    messageDialog.Commands.Add(new UICommand("Player")
                    {
                        Id = 1
                    });

                    var result = await messageDialog.ShowAsync();

                    if ((int)result.Id == 0)
                    {
                        userType = UserType.Coach;
                    }
                    else
                    {
                        userType = UserType.Player;
                    }
                    ((SignInFlow)_signInFlow).SaveUserToLocalStorage(userType);
                }
                switch (userType)
                {
                case UserType.None:

                    this.Frame.Navigate(typeof(New_User));
                    break;

                case UserType.Player:

                    Player player = _signInFlow.GetPlayer();
                    if (player.FirstName == null)                             //The coach doesn't have a health account
                    {
                        var messageDialog = new MessageDialog("Hi new player, we noticed you don't have a microsoft health account. Please go to microsoft's health app and create one.");
                        messageDialog.Commands.Add(new UICommand("OK")
                        {
                            Id = 0
                        });
                        var result = await messageDialog.ShowAsync();

                        _signInFlow.SignOut();
                        return;
                    }
                    this.Frame.Navigate(typeof(Game_Hub));
                    break;

                case UserType.Coach:

                    Coach coach = _signInFlow.GetCoach();
                    if (coach.FirstName == null)                            //The coach doesn't have a health account
                    {
                        var messageDialog = new MessageDialog("Hi new coach, we noticed you don't have a microsoft health account. Please go to microsoft's health app and create one.");
                        messageDialog.Commands.Add(new UICommand("OK")
                        {
                            Id = 0
                        });
                        var result = await messageDialog.ShowAsync();

                        _signInFlow.SignOut();
                        return;
                    }

                    else if (coach.PaymentLastDigits == "")                             //the coach hasn't completed his sign up
                    {
                        var messageDialog = new MessageDialog("Hey! We noticed you haven't completed your Sign In, so we will now continue!");
                        messageDialog.Commands.Add(new UICommand("OK")
                        {
                            Id = 0
                        });
                        var result = await messageDialog.ShowAsync();

                        this.Frame.Navigate(typeof(New_Coach_CreditCard));
                    }
                    else                             //the coach is OK.
                    {
                        this.Frame.Navigate(typeof(Coach_Lobby));
                    }
                    break;

                case UserType.UnassignedPlayer:

                    this.Frame.Navigate(typeof(New_Player));
                    break;
                }
            }
            catch (UserDeniedAccessExeption)
            {
                var messageDialog = new MessageDialog("An error occured:  User denied access. Please try again.");
                messageDialog.Commands.Add(new UICommand("OK")
                {
                    Id = 0
                });
                var result = await messageDialog.ShowAsync();

                _signInFlow.SignOut();
                return;
            }
            catch (UserCancelSignInExeption)
            {
                var messageDialog = new MessageDialog("An error occured:  User canceled Sign In. Please try again.");
                messageDialog.Commands.Add(new UICommand("OK")
                {
                    Id = 0
                });
                var result = await messageDialog.ShowAsync();

                _signInFlow.SignOut();
                return;
            }
            catch (TokenAcquiringException)
            {
                var messageDialog = new MessageDialog("An error occured:  Token acquiring failed. Please try again.");
                messageDialog.Commands.Add(new UICommand("OK")
                {
                    Id = 0
                });
                var result = await messageDialog.ShowAsync();

                _signInFlow.SignOut();
                return;
            }
            catch (Exception exc)
            {
                var messageDialog = new MessageDialog("An unknown error occured. Please try again.");
                messageDialog.Commands.Add(new UICommand("OK")
                {
                    Id = 0
                });
                var result = await messageDialog.ShowAsync();

                _signInFlow.SignOut();
                return;
            }
        }