Esempio n. 1
0
 public void ResetStatsButton_Pressed()
 {
     PopupManager.Get().NewQuestion(PopupType.Warning, "", "Reset Your Local and Server Stats?", (PopupQuestionResult result) =>
     {
         if (result == PopupQuestionResult.Accept)
         {
             PlayerPrefs.DeleteAll();
             StartCoroutine(TaskExtension.YieldWait(UserDatabase.Get().PostUserHighScore(0)));
         }
     });
 }
Esempio n. 2
0
    public void GameOver()
    {
        Time.timeScale = 0.0f;

        InputController.DisableInput();
        UIManager.GetInstance().ShowGameOverPanel();
        TetrisGame.GetInstance().GameOver();
        // Post highscore to database.
        if (isHighscoreBitten)
        {
            isHighscoreBitten = false;
            UserDatabase.Get().SyncUserHighscore();
        }
    }
        private void LoginClick(object sender, RoutedEventArgs e)
        {
            User logged = _db.Get(textboxLogin.Text, textboxPassword.Password);

            if (logged != null)
            {
                _parent.LoggedUser = logged;
                _parent.Close();
            }
            else
            {
                MessageBox.Show("Login and/or password is invalid");
            }
        }
Esempio n. 4
0
 void AuthStateChanged(object sender, System.EventArgs eventArgs)
 {
     if (auth.CurrentUser != user)
     {
         user = auth.CurrentUser;
         if (auth.CurrentUser == null)
         {
             // SignedOut
             PlayerPrefs.SetInt("highscore", 0);
             PlayerPrefs.Save();
         }
         else
         {
             // SignedIn
             UserDatabase.Get().SyncUserHighscore();
         }
     }
 }
Esempio n. 5
0
 private void Signup_Click(object sender, RoutedEventArgs e)
 {
     if (textboxPassword.Password == textboxConfirm.Password)
     {
         if (_db.Add(textboxLogin.Text, textboxPassword.Password))
         {
             _parent.LoggedUser = _db.Get(textboxLogin.Text, textboxPassword.Password);
             _parent.Close();
         }
         else
         {
             MessageBox.Show("User with such login already exists");
         }
     }
     else
     {
         MessageBox.Show("Passwords don't match");
     }
 }
Esempio n. 6
0
        public object Login(User user)
        {
            User authUser = UserDatabase.Get(user.Login, user.Password);

            if (authUser == null)
            {
                return(NotFound(new { message = "Invalid credentials" }));
            }

            string token = TokenService.GenerateToken(user, Startup.PrivateKey);

            user.Password = "";

            return(new
            {
                user = user,
                token = token
            });
        }
Esempio n. 7
0
    IEnumerator LoadUserDatas()
    {
        PopupManager.Get().OpenLoading("", "Loading...");

        Task <UserData[]> task = UserDatabase.Get().GetAllUserData();

        yield return(TaskExtension.YieldWait(task));

        if (task.IsCompleted)
        {
            UserData[] userDatas = task.Result;
            if (userDatas.Length > 0)
            {
                foreach (UserData userData in userDatas)
                {
                    ScoreBoardEntry entry = Instantiate(scoreBoardEntryPrefab, scoreBoardTable);
                    entry.Init(userData.iconURL, userData.name, userData.highScore);
                    scoreBoardEntries.Add(entry);
                }
            }
        }
        PopupManager.Get().CloseLoading();
    }