Exemplo n.º 1
0
    public IEnumerator LoggingIntoServer()
    {
        yield return(StartCoroutine(DataBaseHandeler.GetHttp("server_login.php?id=" + DataBaseHandeler.serverID + "&password="******"session id: " + DataBaseHandeler.sessionID);
    }
    public void ShowScore(EndGameMessage message, List <PlayerData> players, PlayerData myData)
    {
        List <HighScorePair> highscores = new List <HighScorePair>();

        for (int i = 0; i < message.PlayerIDHighscorePairs.Length; i++)
        {
            if (myData.playerIndex == message.PlayerIDHighscorePairs[i].playerID)
            {
                myData.score = message.PlayerIDHighscorePairs[i].score;
            }
            highscores.Add(message.PlayerIDHighscorePairs[i]);
        }
        highscores = highscores.OrderBy(x => x.score).Reverse().ToList();

        nameText.text  = "";
        scoreText.text = "";

        foreach (HighScorePair scores in highscores)
        {
            nameText.text  += players.Find(x => x.playerIndex == scores.playerID).name + "\n";
            scoreText.text += scores.score + "\n";
        }

        //upload score
        if (DataBaseHandeler.userID != -1)
        {
            Debug.Log("user: "******"score: " + myData.score);
            string url = "score_insert.php?user="******"&score=" + myData.score + "&session_id=" + DataBaseHandeler.sessionID;
            StartCoroutine(DataBaseHandeler.GetHttp(url));
        }
    }
    public IEnumerator Registering(string url)
    {
        yield return(StartCoroutine(DataBaseHandeler.GetHttp(url)));

        if (DataBaseHandeler.response == 0 + "")
        {
            message.text = "something went wrong...";
        }
        else
        {
            message.text = "You're registerd succesfully!";
        }
    }
Exemplo n.º 4
0
    public IEnumerator LoggingIn(string url)
    {
        yield return(StartCoroutine(DataBaseHandeler.GetHttp(url)));

        if (DataBaseHandeler.response == 0 + "")
        {
            message.text = "invalid email or username";
        }
        else
        {
            LoginData loginData = new LoginData();
            loginData = JsonUtility.FromJson <LoginData>(DataBaseHandeler.response);

            Debug.Log(loginData.id);
            Debug.Log(loginData.first_name);
            DataBaseHandeler.userID       = loginData.id;
            DataBaseHandeler.userNickname = loginData.first_name + " " + loginData.last_name;

            GoToMenu();
        }
    }
    public IEnumerator ShowStatistics()
    {
        yield return(StartCoroutine(DataBaseHandeler.GetHttp("statistics.php")));

        Debug.Log("Response: " + DataBaseHandeler.response);

        DataBaseStatistic highscores = new DataBaseStatistic();

        highscores = JsonUtility.FromJson <DataBaseStatistic>(DataBaseHandeler.response);

        Debug.Log("highscores: " + highscores.test);
        nameText.text  = "";
        scoreText.text = "";

        foreach (DatabaseHighScore scores in highscores.topofmonth)
        {
            Debug.Log("Gemiddelde: " + scores.gemiddelde);
            nameText.text  += scores.first_name + " " + scores.last_name + "\n";
            scoreText.text += scores.gemiddelde + "\n";
        }
    }