Esempio n. 1
0
    private void HandleOnActionHistoryReceived(string sender, string actionHistory)
    {
        //DebugLog.LogWarning (actionHistory);
        JSON_Object obj = new JSON_Object(actionHistory);

        int roundStatus = obj.getInt(Constants.FIELD_ACTION_HISTORY_ROUND_STATUS);
        int round       = obj.getInt(Constants.FIELD_ACTION_HISTORY_ROUND);

        JSONArray turnsArray = obj.getJSONArray(Constants.FIELD_ACTION_HISTORY_TURNS);

        for (int i = 0; i < turnsArray.Count(); i++)
        {
            ActionResponse ar = JsonUtility.FromJson <ActionResponse> (turnsArray.getString(i));

            if (playerID.Equals(ar.Player_Name))
            {
                betAmount  += ar.Bet_Amount;
                buyInAmount = ar.Player_BuyIn_Chips;

                if (ar.Action == (int)PLAYER_ACTION.FOLD ||
                    ar.Action == (int)PLAYER_ACTION.TIMEOUT)
                {
                    GetComponent <CanvasGroup> ().alpha = .4f;
                }
            }
        }

        DisplayBetAmount();
        DisplayTotalChips();
    }
Esempio n. 2
0
        IEnumerator winnerBrodcast(string sender, JSONArray jsonResponceArray, JSONArray waPotResponceArray)
        {
            //		StartCoroutine(yourFunctionName ());
            int cntr = 0;

            if (sender.Equals(appwarp.WA_SERVER_NAME) && waPotResponceArray != null)
            {
                manageWAPotAmount(waPotResponceArray);
            }
            while (cntr < jsonResponceArray.Count())
            {
                JSON_Object winnerJsonResponce = (JSON_Object)jsonResponceArray.get(cntr);
                manageGameCompleted(sender, winnerJsonResponce.toString());
                cntr++;
                yield return(new WaitForSeconds(GameConstant.WAITING_TIME));
            }

            // Restart game
            if (sender.Equals(appwarp.TEXASS_SERVER_NAME))
            {
                texassGameManager.restartGame();
            }
            else
            {
                waGameManager.restartGame();
            }
        }
Esempio n. 3
0
        private void managePlayerCards(string sender, JSON_Object jsonResponce)
        {
//			DEBUG.Log ("Plr Card : "+sender+" \n>> "+ jsonResponce.toString());
            if (sender.Equals(appwarp.TEXASS_SERVER_NAME))
            {
                texassGameManager.addNewPlayerOnTable(
                    1,
                    jsonResponce.getString(GameConstant.TAG_PLAYER_NAME),
                    jsonResponce.getInt(GameConstant.TAG_PLAYER_BALANCE),
                    jsonResponce.getString(GameConstant.TAG_CARD_PLAYER_1),
                    jsonResponce.getString(GameConstant.TAG_CARD_PLAYER_2),
                    jsonResponce.getInt(GameConstant.TAG_GAME_STATUS),
                    jsonResponce.getInt(GameConstant.TAG_PLAYER_STATUS),
                    jsonResponce.getInt(GameConstant.TAG_CURRENT_ROUND));
            }
            else
            {
                waGameManager.addNewPlayerOnTable(
                    1,
                    jsonResponce.getString(GameConstant.TAG_PLAYER_NAME),
                    jsonResponce.getInt(GameConstant.TAG_PLAYER_BALANCE),
                    jsonResponce.getString(GameConstant.TAG_CARD_PLAYER_1),
                    jsonResponce.getString(GameConstant.TAG_CARD_PLAYER_2),
                    jsonResponce.getString(GameConstant.TAG_CARD_WA),
                    jsonResponce.getInt(GameConstant.TAG_GAME_STATUS),
                    jsonResponce.getInt(GameConstant.TAG_PLAYER_STATUS));
            }
        }
Esempio n. 4
0
        private void managePlayerMoveAction(string sender, string msg)
        {
            JSON_Object jsonResponce = new JSON_Object(msg);

            if (jsonResponce.getInt(GameConstant.TAG_ACTION) != GameConstant.ACTION_NO_TURN)
            {
                if (sender.Equals(appwarp.TEXASS_SERVER_NAME))
                {
                    texassGameManager.managePlayerMoveAction(
                        jsonResponce.getString(GameConstant.TAG_PLAYER_NAME),
                        jsonResponce.getInt(GameConstant.TAG_BET_AMOUNT),
                        jsonResponce.getInt(GameConstant.TAG_TABLE_AMOUNT),
                        jsonResponce.getInt(GameConstant.TAG_PLAYER_BALANCE),
                        jsonResponce.getInt(GameConstant.TAG_ACTION));
                }
                else
                {
                    waGameManager.managePlayerMoveAction(
                        jsonResponce.getString(GameConstant.TAG_PLAYER_NAME),
                        jsonResponce.getInt(GameConstant.TAG_BET_AMOUNT),
                        jsonResponce.getInt(GameConstant.TAG_TABLE_AMOUNT),
                        jsonResponce.getInt(GameConstant.TAG_PLAYER_BALANCE),
                        jsonResponce.getInt(GameConstant.TAG_ACTION));
                }
            }
        }
Esempio n. 5
0
    // Use this for initialization
    void Start()
    {
        JSON_Object jo1 = new JSON_Object();

        jo1.put("count", 1);
        jo1.increment("count");
        Debug.Log("Should print 2: " + jo1.getInt("count"));

        JSON_Object jo2 = new JSON_Object("{\"quote\": \"He said, \\\"I like JSON\\\"\"}");

        Debug.Log("Should print an escaped quote: " + jo2.toString());

        JSONArray ja1 = new JSONArray();

        ja1.put(jo1);
        ja1.put(jo2);

        Debug.Log("Should print count 2, and an escaped quote: " + ja1.toString());

        JSON_Object jo3 = ja1.getJSONObject(1);

        Debug.Log("Should print the same escaped quote: " + jo3.toString());

        string      twitterTest = "{\"errors\": [{\"message\": \"The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.\", \"code\": 68}]}";
        JSON_Object jo4         = new JSON_Object(twitterTest);
        JSONArray   ja2         = jo4.getJSONArray("errors");
        string      message     = ja2.getJSONObject(0).getString("message");
        int         code        = ja2.getJSONObject(0).getInt("code");

        Debug.Log(message + " code: " + code);
    }
Esempio n. 6
0
        private void manageGameCompleted(string sender, string msg)
        {
//			DEBUG.Log ("Game Completed : "+msg);
            JSON_Object   jsonResponce = new JSON_Object(msg);
            List <string> listBestCard = new List <string> ();
            JSONArray     jSONArray    = jsonResponce.getJSONArray(GameConstant.TAG_WINNER_BEST_CARDS);

            for (int i = 0; i < jSONArray.Count(); i++)
            {
                listBestCard.Add(jSONArray.get(i).ToString());
            }
            if (sender.Equals(appwarp.TEXASS_SERVER_NAME))
            {
                texassGameManager.manageGameFinishAction(
                    jsonResponce.getString(GameConstant.TAG_WINNER_NAME),
                    jsonResponce.getInt(GameConstant.TAG_WINNER_RANK),
                    jsonResponce.getInt(GameConstant.TAG_WINNERS_WINNING_AMOUNT),
                    jsonResponce.getInt(GameConstant.TAG_WINNER_TOTAL_BALENCE), listBestCard);
            }
            else
            {
                waGameManager.manageGameFinishAction(
                    jsonResponce.getString(GameConstant.TAG_WINNER_NAME),
                    jsonResponce.getInt(GameConstant.TAG_WINNER_RANK),
                    jsonResponce.getInt(GameConstant.TAG_WINNER_TOTAL_BALENCE),
                    jsonResponce.getInt(GameConstant.TAG_WINNERS_WINNING_AMOUNT),
                    listBestCard);                      //	jsonResponce.getInt (GameConstant.TAG_WINNERS_WINNING_AMOUNT),
            }
        }
Esempio n. 7
0
    private void HandleOnGameCreated(Packet gameInfo)
    {
        Debug.Log(gameInfo.ToString());

        string selectedGameType       = ddGameType.captionText.text;
        string selectedPokerType      = ddPokerType.captionText.text;
        string selectedMoneyType      = ddMoneyType.captionText.text;
        int    selectedGameSpeed      = ddGameSpeed.value;
        int    selectedLimitType      = ddLimitType.value;
        string selectedTournamentType = ddTournamentType.captionText.text;

        JSONArray   arr     = new JSONArray(gameInfo.ToString());
        JSON_Object dataObj = arr.getJSONObject(1).getJSONObject("data");
        JSON_Object gameObj = dataObj.getJSONObject("game");

        string gameType      = gameObj.getString(APIConstants.FIELD_GAME_TYPE);
        string pokerType     = gameObj.getString(APIConstants.FIELD_POKER_TYPE);
        string moneyType     = gameObj.getString(APIConstants.FIELD_MONEY_TYPE);
        string gameSpeedType = gameObj.getString(APIConstants.FIELD_GAME_SPEED);
        string limitType     = gameObj.getString(APIConstants.FIELD_LIMIT);

//		string tournamentType = gameObj.getString (APIConstants.FIELD_TOUR_TYPE);

        if (selectedGameType.Equals(GetCreatedGameType(gameType)) &&
            (selectedPokerType.Equals("All") || selectedPokerType.Equals(GetCreatedPokerType(pokerType))) ||
            (selectedMoneyType.Equals("All") || selectedMoneyType.Equals(GetCreatedMoneyType(moneyType))) ||
            (selectedGameSpeed.Equals("All") || selectedGameSpeed == GetCreatedGameSpeedType(gameSpeedType)) ||
            (selectedLimitType.Equals("All") || selectedLimitType == GetCreatedGameLimitType(limitType)))
        {
            backgroundLoader.SetActive(true);
            GetFilteredData(false);
        }
    }
Esempio n. 8
0
        /// <summary>
        /// Fills the contents of a <seealso cref="JSON_Object.Value"/>
        /// </summary>
        /// <param name="obj">The <seealso cref="JSON_Object"/></param>
        /// <param name="json">The string being parsed</param>
        /// <param name="index">The starting index of <paramref name="json"/></param>
        /// <returns>
        /// The number of characters to trim from <paramref name="json"/>
        /// </returns>
        static int FillObject(JSON_Object obj, string json, int index)
        {
            int  i        = 0;
            char end_char = json[0];

            if (end_char == '}')
            {
                return(1);
            }
            do
            {
                // The key will always be a string
                string key;
                int    key_index = GetStringEndIndex(json, 0);
                i  += key_index;
                key = json.Substring(1, key_index - 1);
                ++i; // increment to match next line
                i += TrimString(ref json, key_index + 1);
                ++i; // increment to match next line
                i += TrimString(ref json, 1);
                // The value could be any kind of JSON type
                // This is where the recursion sets in
                dynamic value = GetBase(json[0]);
                index = HandleBase(value, json);
                i    += index;
                i    += TrimString(ref json, index);
                obj.Value.Add(key, value);
                end_char = json[0];
                ++i; // increment to match next line
                i += TrimString(ref json, 1);
            } while (end_char == ',');
            return(i);
        }
Esempio n. 9
0
    public WinnerReport(string winnerInfo)
    {
        JSON_Object obj = new JSON_Object(winnerInfo);

        Winner = JsonUtility.FromJson <WinnerReport_Winner> (obj.getString("Winner"));
        Loser  = JsonUtility.FromJson <WinnerReport_Loser> (obj.getString("Loser"));
    }
Esempio n. 10
0
        private void manageBliendPlayers(string sender, JSON_Object jsonResponce)
        {
            int smallBliendAmt = jsonResponce.getInt(GameConstant.TAG_SMALL_BLIEND_AMOUNT);

            if (sender.Equals(appwarp.TEXASS_SERVER_NAME))
            {
                if (texassGameManager.getBlindAmount() != 0)
                {
//					smallBliendAmt = texassGameManager.getBlindAmount ();
                }
                texassGameManager.defineBlindPlayer(smallBliendAmt,
                                                    jsonResponce.getString(GameConstant.TAG_PLAYER_DEALER),
                                                    jsonResponce.getString(GameConstant.TAG_PLAYER_SMALL_BLIND),
                                                    jsonResponce.getString(GameConstant.TAG_PLAYER_BIG_BLIND));
                if (texassGameManager.getPlayerManager().getDealerPlayer().getPlayerName().Equals(appwarp.username))
                {
                    sendGameType(smallBliendAmt);
                }
            }
            else
            {
                if (waGameManager.getBlindAmount() != 0)
                {
//					smallBliendAmt = waGameManager.getBlindAmount ();
                }
                waGameManager.defineBlindPlayer(smallBliendAmt,
                                                jsonResponce.getString(GameConstant.TAG_PLAYER_DEALER),
                                                jsonResponce.getString(GameConstant.TAG_PLAYER_SMALL_BLIND),
                                                jsonResponce.getString(GameConstant.TAG_PLAYER_BIG_BLIND));
                if (waGameManager.getPlayerManager().getDealerPlayer().getPlayerName().Equals(appwarp.username))
                {
                    sendGameType(smallBliendAmt);
                }
            }
        }
Esempio n. 11
0
        /**
         * Timer for rebuy chips in tournament
         * */
//		private IEnumerator reBuyChipTimerOff(string sender){
//			yield return new WaitForSeconds (GameConstant.TOURNAMENT_REBUY_TIMER);
//
//			if (sender.Equals (appwarp.TEXASS_SERVER_NAME))
//				texassGameManager.canReBuy = false;
////			else
////				waGameManager.distributeCards ();
//
//		}


        private void sendGameType(int amt)
        {
            JSON_Object jsonObject = new JSON_Object();

            jsonObject.put(GameConstant.TAG_SMALL_BLIEND_AMOUNT, amt);
            jsonObject.put(GameConstant.TAG_GAME_TYPE, appwarp.GAME_TYPE);
            WarpClient.GetInstance().SendChat(GameConstant.REQUEST_FOR_BLIEND_AMOUNT + jsonObject.ToString());
        }
Esempio n. 12
0
 /// <summary>
 /// Append the specified value
 /// </summary>
 /// <param name='value'>
 /// The value to put
 /// </param>
 public JSONArray put(System.Object value)
 {
     if (value is string)
     {
         arrayList.Add(JSON_Object.quote((string)value));
     }
     else
     {
         arrayList.Add(value);
     }
     return(this);
 }
Esempio n. 13
0
    public JSON_Object SelectObj(string selector)
    {
        if (!selector.Contains(".") && !selector.Contains("["))
        {
            return(searchByName(selector));
        }
        JSON_Object obj = this;

        char[] cs     = selector.ToCharArray();
        int    cursor = 0;

        for (int i = 0; i < cs.Length; i++)
        {
            if (cs[i] == '[')
            {
                if (cs[i - 1] != ']')
                {
                    obj    = obj.searchByName(CsSubString(selector, cursor, i));
                    cursor = i;
                }
                int    t   = findEnd(CsSubString(selector, cursor, selector.Length), '[', ']');
                string cut = deDeco(CsSubString(selector, cursor + 1, cursor + t));
                int    ib;
                try
                {
                    ib  = int.Parse(cut);
                    obj = obj.objArr[ib];
                }
                catch (Exception e)
                {
                    Console.Error.Write(e);
                    obj = obj.objArr[int.Parse(select(cut))];
                }
                i = cursor + t;
                if (i + 1 < cs.Length && cs[i + 1] == '.')
                {
                    i++;
                }
                cursor = i + 1;
            }
            else if (cs[i] == '.' || i >= selector.Length - 1)
            {
                string newSelec = CsSubString(selector, cursor, i + 1);
                if (newSelec.EndsWith("."))
                {
                    newSelec = CsSubString(newSelec, 0, newSelec.Length - 1);
                }
                obj    = obj.searchByName(newSelec);
                cursor = i + 1;
            }
        }
        return(obj);
    }
Esempio n. 14
0
    /// <summary>
    /// Copy constructor
    /// </summary>
    /// <param name='other'>
    /// The JSONObject to copy from
    /// </param>
    public JSON_Object(JSON_Object other)
    {
        map = new Dictionary <string, object>();

        if (other != null)
        {
            foreach (var keyValuePair in other.map)
            {
                map[keyValuePair.Key] = keyValuePair.Value;
            }
        }
    }
Esempio n. 15
0
    private void HandleOnSnGTournamentStarted(Packet packet)
    {
        try {
            JSONArray arr = new JSONArray(packet.ToString());

            JSON_Object obj    = arr.getJSONObject(1).getJSONObject("data");
            string      gameID = obj.getString("game_id");

            UpdateTournamentStatusToRunning(gameID);
        } catch (Exception e) {
            Debug.LogError("> Exception  : " + e);
        }
    }
Esempio n. 16
0
 /// <summary>
 /// Same as the get version of this same function, but does not log errors on failure
 /// </summary>
 /// <returns>
 /// The casted object. Returns the default value you specify if the conversion is not possible, or the index is out of bounds.
 /// </returns>
 /// <param name='index'>
 /// Index.
 /// </param>
 /// <param name='defaultValue'>
 /// The default value to return on failure.
 /// </param>
 public string optString(int index, string defaultValue)
 {
     if (index < arrayList.Count)
     {
         object obj = arrayList[index];
         if (obj is string)
         {
             return(JSON_Object.unquote((string)obj));
         }
         return(obj.ToString());
     }
     return(defaultValue);
 }
Esempio n. 17
0
 public void manageReBuyChips(string sender, string msg)
 {
     if (sender.Equals(appwarp.TEXASS_SERVER_NAME))
     {
         JSON_Object jSONObject = new JSON_Object(msg);
         if (sender.Equals(appwarp.TEXASS_SERVER_NAME))
         {
             texassGameManager.getPlayerManager().addBalanceToPlayer(
                 jSONObject.getString(GameConstant.TAG_PLAYER_NAME),
                 jSONObject.getInt(GameConstant.TAG_PLAYER_BALANCE));
         }
     }
 }
Esempio n. 18
0
        private void manageWAPotAmount(JSONArray waPotResponceArray)
        {
            int cntr = 0;

            while (cntr < waPotResponceArray.Count())
            {
                JSON_Object waWinnerObject = (JSON_Object)waPotResponceArray.get(cntr);
                waGameManager.manageWACardPotAmt(
                    waWinnerObject.getString(GameConstant.TAG_WINNER_NAME),
                    waWinnerObject.getInt(GameConstant.TAG_WINNER_TOTAL_BALENCE),
                    waWinnerObject.getInt(GameConstant.TAG_WINNERS_WINNING_AMOUNT));
                cntr++;
            }
        }
Esempio n. 19
0
    public string select(string selector)
    {
        JSON_Object obj = SelectObj(selector);

        if (obj == null)
        {
            return(null);
        }
        if (obj.val == null)
        {
            return("[Object]");
        }
        return(SelectObj(selector).val);
    }
Esempio n. 20
0
 /// <summary>
 /// Same as the get version of this same function, but does not log errors on failure
 /// </summary>
 /// <param name='index'>
 /// Index.
 /// </param>
 public System.Object opt(int index)
 {
     if (index < arrayList.Count)
     {
         System.Object value;
         value = arrayList[index];
         if (value is string)
         {
             return(JSON_Object.unquote((string)value));
         }
         return(value);
     }
     return(new System.Object());
 }
Esempio n. 21
0
    private void HandleOnSnGPlayerEliminated(Packet packet)
    {
        try {
            JSONArray arr = new JSONArray(packet.ToString());

            JSON_Object obj          = arr.getJSONObject(1).getJSONObject("data");
            string      gameID       = obj.getString("game_id");
            int         totalPlayers = obj.getInt("user_count");

            UpdatePlayersCount(gameID, totalPlayers);
        } catch (Exception e) {
            Debug.LogError("> Exception  : " + e);
        }
    }
Esempio n. 22
0
    private void HandleOnPlayerJoinedSnGTournament(Packet packet)
    {
        try {
            JSONArray arr = new JSONArray(packet.ToString());

            JSON_Object obj          = arr.getJSONObject(1).getJSONObject("data");
            JSON_Object gameObj      = new JSON_Object(obj.getString("game"));
            JSONArray   playersArr   = new JSONArray(gameObj.getString("users"));
            int         totalPlayers = playersArr.Count();

            UpdatePlayersCount(gameObj.getString("id"), totalPlayers);
        } catch (Exception e) {
            Debug.LogError("> Exception  : " + e);
        }
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="API_PlayerInfo"/> class.
    /// </summary>
    /// <param name="playerInfo">Player info.</param>
    public API_TournamentAwardInfo(string tournamentInfo)
    {
        JSON_Object obj = new JSON_Object(tournamentInfo);

        awardsWinnerList = new List <API_TournaAwardPlayerInfo> ();
        JSONArray arr = new JSONArray(obj.getString("awards_winner"));

        for (int i = 0; i < arr.Count(); i++)
        {
            API_TournaAwardPlayerInfo player = JsonUtility.FromJson <API_TournaAwardPlayerInfo> (arr.getString(i));
            awardsWinnerList.Add(player);
        }

        game_id = obj.getString("game_id");
    }
Esempio n. 24
0
 /// <summary>
 /// Get the object in the array specified index.
 /// </summary>
 /// <param name='index'>
 /// Index.
 /// </param>
 public System.Object get(int index)
 {
     if (index < arrayList.Count)
     {
         System.Object value;
         value = arrayList[index];
         if (value is string)
         {
             return(JSON_Object.unquote((string)value));
         }
         return(value);
     }
     Debug.LogError("JSONArray.cs get(): index " + index + " out of range " + arrayList.Count);
     return(null);
 }
    public API_TournamentRegPlayers(string tourPlayers)
    {
        JSON_Object obj = new JSON_Object(tourPlayers);

        id         = obj.getString("id");
        game_name  = obj.getString("game_name");
        poker_type = obj.getString("poker_type");

        JSONArray playerArr = obj.getJSONArray("users");

        playerList = new List <SingleGameInfoPlayer> ();
        for (int i = 0; i < playerArr.Count(); i++)
        {
            playerList.Add(JsonUtility.FromJson <SingleGameInfoPlayer> (playerArr.getString(i)));
        }
    }
Esempio n. 26
0
 /// <summary>
 /// Put the specified value at index.
 /// </summary>
 /// <param name='index'>
 /// Which index to put
 /// </param>
 /// <param name='value'>
 /// The value to put
 /// </param>
 public JSONArray put(int index, System.Object value)
 {
     if (index == arrayList.Count)
     {
         put(value);
     }
     if (value is string)
     {
         arrayList[index] = JSON_Object.quote((string)value);
     }
     else
     {
         arrayList[index] = value;
     }
     return(this);
 }
Esempio n. 27
0
    /// <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);
            }
        }
    }
Esempio n. 28
0
        private void manageRoundCompleted(string sender, string msg)
        {
            JSON_Object jsonResponce = new JSON_Object(msg);

            if (sender.Equals(appwarp.TEXASS_SERVER_NAME))
            {
                texassGameManager.moveToNextRound(
                    jsonResponce.getInt(GameConstant.TAG_ROUND),
                    jsonResponce.getInt(GameConstant.TAG_TABLE_AMOUNT));
            }
            else
            {
                waGameManager.moveToNextRound(
                    jsonResponce.getInt(GameConstant.TAG_ROUND),
                    jsonResponce.getInt(GameConstant.TAG_TABLE_AMOUNT));
            }
        }
Esempio n. 29
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>";
        }
    }
Esempio n. 30
0
    private void HandleSnGTournamentStart(Packet packet)
    {
        Debug.LogWarning("=====> " + packet.ToString() + " <======");

        JSONArray   arr = new JSONArray(packet.ToString());
        JSON_Object obj = arr.getJSONObject(1).getJSONObject("data");

        TournamentStartResp tsr = JsonUtility.FromJson <TournamentStartResp> (obj.toString());

        if (tsr.game.users.Contains(LoginScript.loggedInPlayer.id))
        {
            if (tsr.game.users.Contains(LoginScript.loggedInPlayer.id))
            {
                UIManager.Instance.tournamentStartingPanel.DisplayTournamentStarting(tsr.game.id, "TOURNAMENT STARTING", tsr.game.name + " Tournament is going to start");
            }
        }
    }