Ejemplo n.º 1
0
    IEnumerator GetUserData()
    {
        if (string.IsNullOrEmpty(WebServices.CookieString))
        {
            UnityWebRequest www = WebServices.Authenticated_Get("me");

            yield return(www.SendWebRequest());

            if (www.isHttpError || www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                Debug.Log(www.downloadHandler.text);
                currUser.username   = JsonUtility.FromJson <User>(www.downloadHandler.text).username;
                currUser.scores     = JsonUtility.FromJson <User>(www.downloadHandler.text).scores;
                currUser.items      = JsonUtility.FromJson <User>(www.downloadHandler.text).items;
                currUserscores.text = currUser.scores.ToString();

                foreach (string x in currUser.items)
                {
                    if (x.Equals("cat1"))
                    {
                        Instantiate(cat, new Vector3(0, 0, 0), Quaternion.identity);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    IEnumerator GetUserData()
    {
        //if(string.IsNullOrEmpty(WebServices.CookieString)) {
        UnityWebRequest www = WebServices.Authenticated_Get("me");

        yield return(www.SendWebRequest());

        if (www.isHttpError || www.isNetworkError)
        {
            Debug.Log(www.error);
            errorMessageBox.gameObject.SetActive(true);
            errorMessage.gameObject.SetActive(true);
            errorMessage.text = www.error;
            errorMessageBox.GetComponent <Image>().color = new Color32(255, 255, 255, 150);
            errorMessage.GetComponent <Text>().color     = new Color32(0, 0, 0, 255);
        }
        else
        {
            Debug.Log(www.downloadHandler.text);
            currUser = JsonUtility.FromJson <User>(www.downloadHandler.text);
            if (currUser.username != "")
            {
                currUser.username = JsonUtility.FromJson <User>(www.downloadHandler.text).username;
                currUser.scores   = JsonUtility.FromJson <User>(www.downloadHandler.text).scores;
            }
        }
        //} else {
        // Debug.Log("CookieString is null or empty");
        //}
    }
Ejemplo n.º 3
0
    IEnumerator GetUserData()
    {
        //if (string.IsNullOrEmpty(WebServices.CookieString)) {
        UnityWebRequest www = WebServices.Authenticated_Get("me");

        yield return(www.SendWebRequest());

        if (www.isHttpError || www.isNetworkError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log(www.downloadHandler.text);
            data.currUser.username   = JsonUtility.FromJson <User>(www.downloadHandler.text).username;
            data.currUser.scores     = JsonUtility.FromJson <User>(www.downloadHandler.text).scores;
            data.userScores          = data.currUser.scores;
            data.currUser.updates    = JsonUtility.FromJson <User>(www.downloadHandler.text).updates;
            data.updateScores        = data.currUser.updates;
            data.currUser.items      = JsonUtility.FromJson <User>(www.downloadHandler.text).items;
            data.currUser.locations  = JsonUtility.FromJson <User>(www.downloadHandler.text).locations;
            data.currUser.autoCount  = JsonUtility.FromJson <User>(www.downloadHandler.text).autoCount;
            data.currUser.autoTime   = JsonUtility.FromJson <User>(www.downloadHandler.text).autoTime;
            data.currUsername.text   = data.currUser.username;
            data.currUserscores.text = data.currUser.scores.ToString();
            data.itemSearch(data.countCat, data.currUser.items, data.currUser.locations);
        }
        //}
    }
Ejemplo n.º 4
0
    IEnumerator GetPureData()
    {
        //if (string.IsNullOrEmpty(WebServices.CookieString)) {
        UnityWebRequest www = WebServices.Authenticated_Get("me");

        yield return(www.SendWebRequest());

        if (www.isHttpError || www.isNetworkError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log(www.downloadHandler.text);
            currUser.username = JsonUtility.FromJson <User>(www.downloadHandler.text).username;
            currUser.scores   = JsonUtility.FromJson <User>(www.downloadHandler.text).scores;
            userScores        = currUser.scores;
            currUser.updates  = JsonUtility.FromJson <User>(www.downloadHandler.text).updates;
            updateScores      = currUser.updates;

            currUser.autoCount = JsonUtility.FromJson <User>(www.downloadHandler.text).autoCount;
            currUser.autoTime  = JsonUtility.FromJson <User>(www.downloadHandler.text).autoTime;

            currUsername.text   = currUser.username;
            currUserscores.text = currUser.scores.ToString();
        }
    }
Ejemplo n.º 5
0
    IEnumerator GetUserData()
    {
        if (!string.IsNullOrEmpty(WebServices.CookieString))
        {
            UnityWebRequest www = WebServices.Authenticated_Get("me");

            yield return(www.SendWebRequest());

            if (www.isHttpError || www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                Debug.Log(www.downloadHandler.text);
                currUser.username = JsonUtility.FromJson <User>(www.downloadHandler.text).username;
                currUser.scores   = JsonUtility.FromJson <User>(www.downloadHandler.text).scores;
            }
        }
    }
Ejemplo n.º 6
0
    IEnumerator GetUserData()
    {
        //if (string.IsNullOrEmpty(WebServices.CookieString)) {
        UnityWebRequest www = WebServices.Authenticated_Get("me");

        yield return(www.SendWebRequest());

        if (www.isHttpError || www.isNetworkError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log(www.downloadHandler.text);
            currUser.username = JsonUtility.FromJson <User>(www.downloadHandler.text).username;
            currUser.scores   = JsonUtility.FromJson <User>(www.downloadHandler.text).scores;
            Debug.Log("currUser : "******"userScores : " + userScores);
            currUser.updates      = JsonUtility.FromJson <User>(www.downloadHandler.text).updates;
            updateScores          = currUser.updates;
            currUser.items        = JsonUtility.FromJson <User>(www.downloadHandler.text).items;
            currUser.locations    = JsonUtility.FromJson <User>(www.downloadHandler.text).locations;
            currUser.autoCount    = JsonUtility.FromJson <User>(www.downloadHandler.text).autoCount;
            currUser.autoTime     = JsonUtility.FromJson <User>(www.downloadHandler.text).autoTime;
            currUser.recentLogin  = JsonUtility.FromJson <User>(www.downloadHandler.text).recentLogin;
            currUser.recentLogout = JsonUtility.FromJson <User>(www.downloadHandler.text).recentLogout;


            if (countCat < currUser.items.Length)
            {
                itemSearchLogin(currUser.items, currUser.locations);
            }

            if (!string.IsNullOrEmpty(currUser.recentLogin) && !string.IsNullOrEmpty(currUser.recentLogout) && !isLogin)
            {
                System.DateTime login        = System.DateTime.Parse(currUser.recentLogin);
                System.DateTime logout       = System.DateTime.Parse(currUser.recentLogout);
                System.TimeSpan passed       = login.Subtract(logout);
                double          totalSeconds = passed.TotalSeconds;
                tempScores = 0;

                for (int i = 0; i < currUser.autoCount.Length; ++i)
                {
                    if (currUser.autoCount[i] > 0)
                    {
                        tempScores += (int)(totalSeconds / currUser.autoTime[i]);
                    }
                }

                double totalMinutes = passed.TotalMinutes;
                double totalHours   = passed.TotalHours;

                if (totalMinutes > 1 || totalHours > 1)
                {
                    totalTime = totalHours > 1.0 ? (int)totalHours : (int)totalMinutes;
                    string str = totalHours > 1.0 ? "hours" : "minutes";
                    timeManagerBox.gameObject.SetActive(true);
                    timeManagerText.gameObject.SetActive(true);

                    timeManagerText.text = "You logged in " + totalTime.ToString() + " " + str;// +
                    //"\n" + "You earns " + tempScores.ToString() + " points by Auto Clicker Cat!!";
                    timeManagerBox.GetComponent <Image>().color = new Color32(255, 255, 255, 150);
                    timeManagerText.GetComponent <Text>().color = new Color32(0, 0, 0, 255);
                    //userScores += (int)(totalTime);
                }
                isLogin = true;
            }
        }
        //}
    }