/// <summary>
    /// Initializes a new instance of the <see cref="API_GameInfo"/> class.
    /// </summary>
    /// <param name="gameInfo">Game info.</param>
    public API_GameInfo(string gameInfo)
    {
        JSON_Object obj = new JSON_Object(gameInfo);

        total        = obj.getInt("total");
        per_page     = obj.getString("per_page");
        current_page = obj.getInt("current_page");
        last_page    = obj.getInt("last_page");
        if (obj.has("next_page_url"))
        {
            next_page_url = obj.getString("next_page_url");
        }
        if (obj.has("prev_page_url"))
        {
            prev_page_url = obj.getString("prev_page_url");
        }
        if (obj.has("from"))
        {
            from = obj.getString("from");
        }
        if (obj.has("to"))
        {
            to = obj.getString("to");
        }

        JSONArray arr = new JSONArray(obj.getString("data"));

        gameList = new List <GameData> ();
        for (int i = 0; i < arr.Count(); i++)
        {
            GameData data = new GameData(arr.getString(i));
            if (!data.game_type.Equals(APIConstants.CASH_GAME_GAME_TYPE) && data.status.Equals(APIConstants.TOURNAMENT_STATUS_FINISHED))
            {
                DateTime currentTime  = DateTime.Parse(data.currenrTime);
                DateTime finishedTime = DateTime.Parse(data.finished_time);

                if ((currentTime - finishedTime).Minutes < 10)
                {
                    gameList.Add(data);
                }
            }
            else
            {
                gameList.Add(data);
            }
        }
    }
Exemple #2
0
    /// <summary>
    /// Raises the login response received event.
    /// </summary>
    /// <param name="www">Www.</param>
    private void OnLoginResponseReceived(WWW www)
    {
        UIManager.Instance.loader.gameObject.SetActive(false);
        debugString += "\n" + www.text;
        if (www.error != null)
        {
            DebugLog.LogError(www.error);
            UIManager.Instance.loginPanel.txtError.text = "<color=yellow>Something went wrong.</color>";
            DebugLog.Log(www.text);
            JSON_Object errorObj = new JSON_Object(www.text);
            if (errorObj.has("messages"))
            {
                JSONArray arr = errorObj.getJSONArray("messages");
                if (arr.Count() > 0)
                {
                    UIManager.Instance.loginPanel.txtError.text = "<color=yellow>" + arr.getString(0) + "</color>";
                }
            }

            return;
        }

        DebugLog.LogWarning(www.text);

        JSON_Object obj = new JSON_Object(www.text);

        if (obj.getString("status").Equals(APIConstants.STATUS_AUTHORIZED))
        {
            API_LoginPlayerInfo loggedInPlayerInfo = new API_LoginPlayerInfo(www.text);
            LoginScript.loggedInPlayer = loggedInPlayerInfo;

//			GetProfileImage (loggedInPlayerInfo.avtar);
            APIConstants.PLAYER_TOKEN = loggedInPlayerInfo.token;

//			UIManager.Instance.loginPanel.gameObject.SetActive (false);
            UIManager.Instance.lobbyPanel.gameObject.SetActive(true);

            GetPlayerInfo();

            StartUpdatingLoginStatus();
        }
        else
        {
            UIManager.Instance.loginPanel.txtError.text = "<color=red>Something went wrong.</color>";
        }
    }