コード例 #1
0
    public static void playerTrade(string CurrentUserGame, string CurrentUserId)
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        TradePlayerJson command = new TradePlayerJson();

        command.gameId   = CurrentUserGame;
        command.playerId = CurrentUserId;
        command.lumber_o = 1;
        command.wool_o   = 2;
        command.grain_o  = 3;
        command.brick_o  = 4;
        command.ore_o    = 5;
        command.lumber_r = 6;
        command.wool_r   = 7;
        command.grain_r  = 8;
        command.brick_r  = 9;
        command.ore_r    = 10;
        RequestJson req = new RequestJson();

        RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/playerTrade", command).Then(Response =>
        {
            Debug.Log(Response.code);
            Debug.Log(Response.status);

            JSONObject json_message = new JSONObject();
            json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
            json_message.AddField("username", LoginScript.CurrentUser);
            json_message.AddField("lumber_o", command.lumber_o);
            json_message.AddField("wool_o", command.wool_o);
            json_message.AddField("grain_o", command.grain_o);
            json_message.AddField("brick_o", command.brick_o);
            json_message.AddField("ore_o", command.ore_o);
            json_message.AddField("lumber_r", command.lumber_r);
            json_message.AddField("wool_r", command.wool_r);
            json_message.AddField("grain_r", command.grain_r);
            json_message.AddField("brick_r", command.brick_r);
            json_message.AddField("ore_r", command.ore_r);

            socket.Emit("playerTrade", json_message);
        }).Catch(err => { Debug.Log(err); });
    }
コード例 #2
0
    public static void acceptTrade(string CurrentUserGame, string CurrentUserId)
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        TradePlayerJson command = new TradePlayerJson();

        command.gameId   = CurrentUserGame;
        command.playerId = CurrentUserId;
        RequestJson req = new RequestJson();

        RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/wantToTrade", command).Then(Response =>
        {
            Debug.Log("Accept Trade " + Response.code);
            Debug.Log("Accdept Trade " + Response.status);
            JSONObject json_message = new JSONObject();
            json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
            json_message.AddField("username", LoginScript.CurrentUser);
            json_message.AddField("gameEngineId", LoginScript.CurrentUserGEId);
            json_message.AddField("wantToTrade", "true");
            socket.Emit("wantToTrade", json_message);
        }).Catch(err => { Debug.Log(err); });
    }
コード例 #3
0
    public void trade()
    {
        print("playertrade");
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        TradePlayerJson command = new TradePlayerJson();

        command.gameId   = LoginScript.CurrentUserGameId;
        command.playerId = LoginScript.CurrentUserGEId;

        if (infild0.text == "")
        {
            command.lumber_o = 0;
        }
        else
        {
            command.lumber_o = int.Parse(infild0.text);
        }

        if (infild1.text == "")
        {
            command.wool_o = 0;
        }
        else
        {
            command.wool_o = int.Parse(infild1.text);
        }

        if (infild2.text == "")
        {
            command.grain_o = 0;
        }
        else
        {
            command.grain_o = int.Parse(infild2.text);
        }

        if (infild3.text == "")
        {
            command.brick_o = 0;
        }
        else
        {
            command.brick_o = int.Parse(infild3.text);
        }

        if (infild4.text == "")
        {
            command.ore_o = 0;
        }
        else
        {
            command.ore_o = int.Parse(infild4.text);
        }

        if (infild5.text == "")
        {
            command.lumber_r = 0;
        }
        else
        {
            command.lumber_r = int.Parse(infild5.text);
        }

        if (infild6.text == "")
        {
            command.wool_r = 0;
        }
        else
        {
            command.wool_r = int.Parse(infild6.text);
        }

        if (infild7.text == "")
        {
            command.grain_r = 0;
        }
        else
        {
            command.grain_r = int.Parse(infild7.text);
        }

        if (infild8.text == "")
        {
            command.brick_r = 0;
        }
        else
        {
            command.brick_r = int.Parse(infild8.text);
        }

        if (infild9.text == "")
        {
            command.ore_r = 0;
        }
        else
        {
            command.ore_r = int.Parse(infild9.text);
        }

        print(command.lumber_o);
        print(command.brick_o);
        print(command.brick_r);
        print(command.ore_r);
        print("aaaaaa");

        RequestJson req = new RequestJson();
        Text        txt = FindTextFiel.find();

        RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/playerTrade", command).Then(Response =>
        {
            Debug.Log(Response.code);
            Debug.Log(Response.status);
            txt.text = Response.status;
            if (Response.code == 200)
            {
                JSONObject json_message = new JSONObject();
                json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
                json_message.AddField("username", LoginScript.CurrentUser);
                json_message.AddField("lumber_o", command.lumber_o);
                json_message.AddField("wool_o", command.wool_o);
                json_message.AddField("grain_o", command.grain_o);
                json_message.AddField("brick_o", command.brick_o);
                json_message.AddField("ore_o", command.ore_o);
                json_message.AddField("lumber_r", command.lumber_r);
                json_message.AddField("wool_r", command.wool_r);
                json_message.AddField("grain_r", command.grain_r);
                json_message.AddField("brick_r", command.brick_r);
                json_message.AddField("ore_r", command.ore_r);

                socket.Emit("playerTrade", json_message);
            }


            MakeRequestResponse command1 = new MakeRequestResponse();
            command1.gameId   = LoginScript.CurrentUserGameId;
            command1.playerId = LoginScript.CurrentUserGEId;
            RequestJson req1  = new RequestJson();
            RestClient.Post <UpdateJson>("https://catan-connectivity.herokuapp.com/game/update", command1).Then(Response1 =>
            {
                Debug.Log("Update code " + Response1.code);
                Debug.Log("Update status " + Response1.status);
                Debug.Log("Update arguments lumber " + Response1.arguments.lumber);

                lumber.text = Response1.arguments.lumber.ToString();
                ore.text    = Response1.arguments.ore.ToString();
                grain.text  = Response1.arguments.grain.ToString();
                brick.text  = Response1.arguments.brick.ToString();
                wool.text   = Response1.arguments.wool.ToString();
            }).Catch(err => { Debug.Log(err); });
        }).Catch(err => { Debug.Log(err); });
    }
コード例 #4
0
    public void setupEvents()
    {
        socket.On("wantToTrade", (E) =>
        {
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                if (E.data[3].str == "false")
                {
                    trade--;
                }
                else
                {
                    trade += 10;
                }
                if (trade > 0)
                {
                    trade = 0;
                    TradePlayerJson command = new TradePlayerJson();
                    command.gameId          = LoginScript.CurrentUserGameId;
                    command.playerId        = LoginScript.CurrentUserGEId;
                    RequestJson req         = new RequestJson();
                    RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/sendPartners", command).Then(Response =>
                    {
                        Debug.Log("SendParteners " + Response.code);
                        Debug.Log("Send Parteners " + Response.status);
                        Debug.Log("Send Partenets " + Response.arguments.player_0);
                        SelectedPartener commandSelect = new SelectedPartener();
                        commandSelect.gameId           = LoginScript.CurrentUserGameId;
                        commandSelect.playerId         = LoginScript.CurrentUserGEId;
                        commandSelect.player           = Response.arguments.player_0;
                        Debug.Log("Playerul este: " + commandSelect.player);
                        RequestJson request = new RequestJson();
                        RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/selectPartner", commandSelect).Then(Response2 =>
                        {
                            Debug.Log("SelectPartener " + Response2.code);
                            Debug.Log("SelectPartener " + Response2.status);

                            Text txt = FindTextFiel.find();
                            txt.text = Response2.status;

                            if (Response2.code == 200)
                            {
                                JSONObject json_message = new JSONObject();
                                json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
                                socket.Emit("UpdateResource", json_message);


                                MakeRequestResponse command1 = new MakeRequestResponse();
                                command1.gameId   = LoginScript.CurrentUserGameId;
                                command1.playerId = LoginScript.CurrentUserGEId;
                                RequestJson req1  = new RequestJson();
                                RestClient.Post <UpdateJson>("https://catan-connectivity.herokuapp.com/game/update", command1).Then(Response1 =>
                                {
                                    Debug.Log("Update code " + Response1.code);
                                    Debug.Log("Update status " + Response1.status);
                                    Debug.Log("Update arguments lumber " + Response1.arguments.lumber);

                                    lumber.text = Response1.arguments.lumber.ToString();
                                    ore.text    = Response1.arguments.ore.ToString();
                                    grain.text  = Response1.arguments.grain.ToString();
                                    brick.text  = Response1.arguments.brick.ToString();
                                    wool.text   = Response1.arguments.wool.ToString();
                                }).Catch(err => { Debug.Log(err); });
                            }
                        }).Catch(err => { Debug.Log(err); });
                    }).Catch(err => { Debug.Log(err); });
                }
                if (trade == -3)
                {
                    trade = 0;
                    TradePlayerJson command = new TradePlayerJson();
                    command.gameId          = LoginScript.CurrentUserGameId;
                    command.playerId        = LoginScript.CurrentUserGEId;
                    // command.arguments = null;
                    RequestJson req = new RequestJson();
                    RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/sendPartners", command).Then(Response =>
                    {
                        Debug.Log("SendParteners " + Response.code);
                        Debug.Log("Send Parteners " + Response.status);
                        Debug.Log("Send Partenets " + Response.arguments.player_0);
                        SelectedPartener commandSelect = new SelectedPartener();
                        commandSelect.gameId           = LoginScript.CurrentUserGameId;
                        commandSelect.playerId         = LoginScript.CurrentUserGEId;
                        commandSelect.player           = null;
                        RequestJson request            = new RequestJson();
                        RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/selectPartner", commandSelect).Then(Response2 =>
                        {
                            Debug.Log("Nu a selectat nimeni");
                            Debug.Log(Response2.status);
                        }).Catch(err => { Debug.Log(err); });
                    }).Catch(err => { Debug.Log(err); });
                }
            }
        });
        socket.On("buildsettlement", (E) =>
        {
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                Debug.Log("builtsettelment");
                string user_who_built_settelment = E.data[1].str;
                string intesection = E.data[2].ToString();
                casute.SetActive(true);
                inter = GameObject.Find(intesection);
                print(inter.name);

                if (user_who_built_settelment == LoginScript.CurrentLobby.master)
                {
                    AfiseazaDrum.afiseaza(newPiece1, inter);
                }

                else if (user_who_built_settelment == LoginScript.CurrentLobby.first)
                {
                    AfiseazaDrum.afiseaza(newPiece2, inter);
                }
                else if (user_who_built_settelment == LoginScript.CurrentLobby.second)
                {
                    AfiseazaDrum.afiseaza(newPiece3, inter);
                }
                else if (user_who_built_settelment == LoginScript.CurrentLobby.third)
                {
                    AfiseazaDrum.afiseaza(newPiece4, inter);
                }
                casute.SetActive(false);
            }
        });
        socket.On("buildroad", (E) =>
        {
            turn++;
            Debug.Log("buildroad");
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                Debug.Log("buildroad227711");
                string user_who_built_road = E.data[1].str;
                string start = E.data[2].ToString();
                string end   = E.data[3].ToString();
                drumuri.SetActive(true);
                inter  = GameObject.Find(start + " " + end);
                inter1 = GameObject.Find(end + " " + start);
                if (inter == null)
                {
                    inter = GameObject.Find(end + " " + start);
                }

                if (user_who_built_road == LoginScript.CurrentLobby.master && ver.text == "0")
                {
                    AfiseazaDrum.afiseaza(newPieceR1, inter);
                    player1.SetActive(false);
                    player2.SetActive(true);
                    player3.SetActive(false);
                    player4.SetActive(false);
                }

                else if (user_who_built_road == LoginScript.CurrentLobby.first && ver.text == "0")
                {
                    AfiseazaDrum.afiseaza(newPieceR2, inter);
                    player2.SetActive(false);
                    player3.SetActive(true);
                    player1.SetActive(false);
                    player4.SetActive(false);
                }
                else if (user_who_built_road == LoginScript.CurrentLobby.second && ver.text == "0")
                {
                    AfiseazaDrum.afiseaza(newPieceR3, inter);
                    player3.SetActive(false);
                    player4.SetActive(true);
                    player1.SetActive(false);
                    player2.SetActive(false);
                }
                else if (user_who_built_road == LoginScript.CurrentLobby.third && ver.text == "0")
                {
                    AfiseazaDrum.afiseaza(newPieceR4, inter);
                    player4.SetActive(true);
                    player1.SetActive(false);
                    player3.SetActive(false);
                    player2.SetActive(false);
                    //ok1 = true;
                    ver.text = "1";
                }
                else if (user_who_built_road == LoginScript.CurrentLobby.third && ver.text == "1")
                {
                    AfiseazaDrum.afiseaza(newPieceR4, inter);
                    player4.SetActive(false);
                    player1.SetActive(false);
                    player3.SetActive(true);
                    player2.SetActive(false);
                }
                else if (user_who_built_road == LoginScript.CurrentLobby.second && ver.text == "1")
                {
                    AfiseazaDrum.afiseaza(newPieceR3, inter);
                    player4.SetActive(false);
                    player1.SetActive(false);
                    player3.SetActive(false);
                    player2.SetActive(true);
                }
                else if (user_who_built_road == LoginScript.CurrentLobby.first && ver.text == "1")
                {
                    AfiseazaDrum.afiseaza(newPieceR2, inter);
                    player4.SetActive(false);
                    player1.SetActive(true);
                    player3.SetActive(false);
                    player2.SetActive(false);
                }
                else if (user_who_built_road == LoginScript.CurrentLobby.master && ver.text == "1")
                {
                    AfiseazaDrum.afiseaza(newPieceR1, inter);
                    player4.SetActive(false);
                    player1.SetActive(true);
                    player3.SetActive(false);
                    player2.SetActive(false);
                    ver.text = "2";
                }
                if (user_who_built_road == LoginScript.CurrentLobby.master && ver.text == "2")
                {
                    AfiseazaDrum.afiseaza(newPieceR1, inter);
                }

                else if (user_who_built_road == LoginScript.CurrentLobby.first && ver.text == "2")
                {
                    AfiseazaDrum.afiseaza(newPieceR2, inter);
                }
                else if (user_who_built_road == LoginScript.CurrentLobby.second && ver.text == "2")
                {
                    AfiseazaDrum.afiseaza(newPieceR3, inter);
                }
                else if (user_who_built_road == LoginScript.CurrentLobby.third && ver.text == "2")
                {
                    AfiseazaDrum.afiseaza(newPieceR4, inter);
                }
                drumuri.SetActive(false);
            }
        });
        socket.On("RollDice", (E) =>
        {
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                print("dice roll info");
                for (int i = 0; i <= 27; i++)
                {
                    print(E.data[i].ToString());
                }

                if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser)
                {
                    lumber.text = (int.Parse(lumber.text) + int.Parse(E.data[23].ToString())).ToString();
                    ore.text    = (int.Parse(ore.text) + int.Parse(E.data[27].ToString())).ToString();
                    grain.text  = (int.Parse(grain.text) + int.Parse(E.data[25].ToString())).ToString();
                    brick.text  = (int.Parse(brick.text) + int.Parse(E.data[26].ToString())).ToString();
                    wool.text   = (int.Parse(wool.text) + int.Parse(E.data[24].ToString())).ToString();
                }
                else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser)
                {
                    lumber.text = (int.Parse(lumber.text) + int.Parse(E.data[17].ToString())).ToString();
                    ore.text    = (int.Parse(ore.text) + int.Parse(E.data[21].ToString())).ToString();
                    grain.text  = (int.Parse(grain.text) + int.Parse(E.data[19].ToString())).ToString();
                    brick.text  = (int.Parse(brick.text) + int.Parse(E.data[20].ToString())).ToString();
                    wool.text   = (int.Parse(wool.text) + int.Parse(E.data[18].ToString())).ToString();
                }
                else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser)
                {
                    lumber.text = (int.Parse(lumber.text) + int.Parse(E.data[11].ToString())).ToString();
                    ore.text    = (int.Parse(ore.text) + int.Parse(E.data[15].ToString())).ToString();
                    grain.text  = (int.Parse(grain.text) + int.Parse(E.data[13].ToString())).ToString();
                    brick.text  = (int.Parse(brick.text) + int.Parse(E.data[14].ToString())).ToString();
                    wool.text   = (int.Parse(wool.text) + int.Parse(E.data[12].ToString())).ToString();
                }
                else if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser)
                {
                    lumber.text = (int.Parse(lumber.text) + int.Parse(E.data[5].ToString())).ToString();
                    ore.text    = (int.Parse(ore.text) + int.Parse(E.data[9].ToString())).ToString();
                    grain.text  = (int.Parse(grain.text) + int.Parse(E.data[7].ToString())).ToString();
                    brick.text  = (int.Parse(brick.text) + int.Parse(E.data[8].ToString())).ToString();
                    wool.text   = (int.Parse(wool.text) + int.Parse(E.data[6].ToString())).ToString();
                }

                string dice_1 = E.data[2].ToString();
                string dice_2 = E.data[3].ToString();
                switch (dice_1)
                {
                case "1":
                    side1.SetActive(true);
                    side2.SetActive(false);
                    side3.SetActive(false);
                    side4.SetActive(false);
                    side5.SetActive(false);
                    side6.SetActive(false);

                    break;

                case "2":
                    side1.SetActive(false);
                    side2.SetActive(true);
                    side3.SetActive(false);
                    side4.SetActive(false);
                    side5.SetActive(false);
                    side6.SetActive(false);

                    break;

                case "3":
                    side1.SetActive(false);
                    side2.SetActive(false);
                    side3.SetActive(true);
                    side4.SetActive(false);
                    side5.SetActive(false);
                    side6.SetActive(false);

                    break;

                case "4":
                    side1.SetActive(false);
                    side2.SetActive(false);
                    side3.SetActive(false);
                    side4.SetActive(true);
                    side5.SetActive(false);
                    side6.SetActive(false);

                    break;

                case "5":
                    side1.SetActive(false);
                    side2.SetActive(false);
                    side3.SetActive(false);
                    side4.SetActive(false);
                    side5.SetActive(true);
                    side6.SetActive(false);

                    break;

                case "6":
                    side1.SetActive(false);
                    side2.SetActive(false);
                    side3.SetActive(false);
                    side4.SetActive(false);
                    side5.SetActive(false);
                    side6.SetActive(true);

                    break;
                }

                switch (dice_2)
                {
                case "1":
                    sside1.SetActive(true);
                    sside2.SetActive(false);
                    sside3.SetActive(false);
                    sside4.SetActive(false);
                    sside5.SetActive(false);
                    sside6.SetActive(false);

                    break;

                case "2":
                    sside1.SetActive(false);
                    sside2.SetActive(true);
                    sside3.SetActive(false);
                    sside4.SetActive(false);
                    sside5.SetActive(false);
                    sside6.SetActive(false);
                    break;

                case "3":
                    sside1.SetActive(false);
                    sside2.SetActive(false);
                    sside3.SetActive(true);
                    sside4.SetActive(false);
                    sside5.SetActive(false);
                    sside6.SetActive(false);
                    break;

                case "4":
                    sside1.SetActive(false);
                    sside2.SetActive(false);
                    sside3.SetActive(false);
                    sside4.SetActive(true);
                    sside5.SetActive(false);
                    sside6.SetActive(false);
                    break;

                case "5":
                    sside1.SetActive(false);
                    sside2.SetActive(false);
                    sside3.SetActive(false);
                    sside4.SetActive(false);
                    sside5.SetActive(true);
                    sside6.SetActive(false);
                    break;

                case "6":
                    sside1.SetActive(false);
                    sside2.SetActive(false);
                    sside3.SetActive(false);
                    sside4.SetActive(false);
                    sside5.SetActive(false);
                    sside6.SetActive(true);
                    break;
                }
                Debug.Log(dice_1);
                Debug.Log(dice_2);
                if (int.Parse(dice_1) + int.Parse(dice_2) == 7)
                {
                    int player_0_sum = int.Parse(lumber.text) + int.Parse(brick.text) + int.Parse(ore.text) + int.Parse(wool.text) + int.Parse(grain.text);

                    if (player_0_sum > 7)
                    {
                        player_0_sum       = player_0_sum / 2;
                        DiscardAmount.text = "You have to discard " + player_0_sum.ToString() + " of your cards";
                        tataPanel.SetActive(true);
                        tataPanel.SetActive(true);
                        ibirck.text  = "";
                        iore.text    = "";
                        ilumber.text = "";
                        igrain.text  = "";
                        iwool.text   = "";
                    }
                }
            }
        });


        socket.On("endturn", (E) =>
        {
            Debug.Log("endturn");
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                string user_who_end_turn = E.data[1].str;
                if (LoginScript.CurrentLobby.master == user_who_end_turn)
                {
                    player1.SetActive(false);
                    player2.SetActive(true);
                    player3.SetActive(false);
                    player4.SetActive(false);
                }
                else if (LoginScript.CurrentLobby.first == user_who_end_turn)
                {
                    player2.SetActive(false);
                    player3.SetActive(true);
                    player1.SetActive(false);
                    player4.SetActive(false);
                }
                else if (LoginScript.CurrentLobby.second == user_who_end_turn)
                {
                    player3.SetActive(false);
                    player4.SetActive(true);
                    player1.SetActive(false);
                    player2.SetActive(false);
                }
                else if (LoginScript.CurrentLobby.third == user_who_end_turn)
                {
                    player4.SetActive(false);
                    player1.SetActive(true);
                    player3.SetActive(false);
                    player2.SetActive(false);
                }
            }
            MakeRequestResponse command1 = new MakeRequestResponse();
            command1.gameId   = LoginScript.CurrentUserGameId;
            command1.playerId = LoginScript.CurrentUserGEId;
            RequestJson req1  = new RequestJson();
            RestClient.Post <UpdateJson>("https://catan-connectivity.herokuapp.com/game/update", command1).Then(Response1 =>
            {
                Debug.Log("Update code " + Response1.code);
                Debug.Log("Update status " + Response1.status);
                Debug.Log("Update arguments lumber " + Response1.arguments.lumber);

                print("end turn info");
                print(Response1.arguments.lumber.ToString());
                print(Response1.arguments.ore.ToString());
                print(Response1.arguments.grain.ToString());
                print(Response1.arguments.brick.ToString());
                print(Response1.arguments.wool.ToString());

                lumber.text = Response1.arguments.lumber.ToString();
                ore.text    = Response1.arguments.ore.ToString();
                grain.text  = Response1.arguments.grain.ToString();
                brick.text  = Response1.arguments.brick.ToString();
                wool.text   = Response1.arguments.wool.ToString();
            }).Catch(err => { Debug.Log(err); });
        });
        socket.On("buyCity", (E) =>
        {
            Debug.Log("buyCity");
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                Debug.Log("buyCity");
                string user_who_built_settelment = E.data[1].str;
                string intesection = E.data[2].ToString();
                casute.SetActive(true);
                interO = GameObject.Find(intesection);
                ///Debug.Log(intesection);

                if (user_who_built_settelment == LoginScript.CurrentLobby.master)
                {
                    AfiseazaDrum.afiseaza(newPieceO1, interO);
                }

                else if (user_who_built_settelment == LoginScript.CurrentLobby.first)
                {
                    AfiseazaDrum.afiseaza(newPieceO2, interO);
                }
                else if (user_who_built_settelment == LoginScript.CurrentLobby.second)
                {
                    AfiseazaDrum.afiseaza(newPieceO3, interO);
                }
                else if (user_who_built_settelment == LoginScript.CurrentLobby.third)
                {
                    AfiseazaDrum.afiseaza(newPieceO4, interO);
                }

                casute.SetActive(false);
            }
        });
        socket.On("playerTrade", (E) =>
        {
            Debug.Log("playerTrade");
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                tradePanel.SetActive(true);
                playerName.text = "Player " + E.data[1].str + " want to trade";
                print(E.data[2].ToString());
                print(E.data[3].ToString());
                print(E.data[4].ToString());
                print(E.data[5].ToString());
                print(E.data[6].ToString());
                print(E.data[7].ToString());
                print(E.data[8].ToString());
                print(E.data[9].ToString());
                print(E.data[10].ToString());
                print(E.data[11].ToString());
                of1.text = "" + E.data[2].ToString();
                of2.text = "" + E.data[3].ToString();
                of3.text = "" + E.data[4].ToString();
                of4.text = "" + E.data[5].ToString();
                of5.text = "" + E.data[6].ToString();

                rq1.text = "" + E.data[7].ToString();
                rq2.text = "" + E.data[8].ToString();
                rq3.text = "" + E.data[9].ToString();
                rq4.text = "" + E.data[10].ToString();
                rq5.text = "" + E.data[11].ToString();
            }
        });

        socket.On("UpdateResource", (E) =>
        {
            Debug.Log("playerTrade");
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                MakeRequestResponse command1 = new MakeRequestResponse();
                command1.gameId   = LoginScript.CurrentUserGameId;
                command1.playerId = LoginScript.CurrentUserGEId;
                RequestJson req1  = new RequestJson();
                RestClient.Post <UpdateJson>("https://catan-connectivity.herokuapp.com/game/update", command1).Then(Response1 =>
                {
                    Debug.Log("Update code " + Response1.code);
                    Debug.Log("Update status " + Response1.status);
                    print(Response1.arguments.lumber.ToString());
                    print(Response1.arguments.ore.ToString());
                    print(Response1.arguments.grain.ToString());
                    print(Response1.arguments.brick.ToString());
                    print(Response1.arguments.wool.ToString());

                    lumber.text = Response1.arguments.lumber.ToString();
                    ore.text    = Response1.arguments.ore.ToString();
                    grain.text  = Response1.arguments.grain.ToString();
                    brick.text  = Response1.arguments.brick.ToString();
                    wool.text   = Response1.arguments.wool.ToString();
                }).Catch(err => { Debug.Log(err); });
            }
        });
        socket.On("placeRobber", (E) =>
        {
            Debug.Log("placeRobber");
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                tataHot.SetActive(true);
                GameObject rob = GameObject.Find("0" + E.data[1].str);
                GameObject x   = GameObject.Find("Robber777(Clone)");

                Destroy(x);
                AfiseazaDrum.afiseaza(Robbler, rob);
                //Instantiate(Robler, rob.position, rob.rotation);
                //Rober.SetActive(false);
                tataHot.SetActive(false);
            }
        });

        socket.On("Stolen", (E) =>
        {
            Debug.Log("Stolen");
            if (E.data[0].str == LoginScript.CurrentUserLobbyId)
            {
                MakeRequestResponse command1 = new MakeRequestResponse();
                command1.gameId   = LoginScript.CurrentUserGameId;
                command1.playerId = LoginScript.CurrentUserGEId;
                RequestJson req1  = new RequestJson();
                RestClient.Post <UpdateJson>("https://catan-connectivity.herokuapp.com/game/update", command1).Then(Response1 =>
                {
                    Debug.Log("Update code " + Response1.code);
                    Debug.Log("Update status " + Response1.status);
                    print(Response1.arguments.lumber.ToString());
                    print(Response1.arguments.ore.ToString());
                    print(Response1.arguments.grain.ToString());
                    print(Response1.arguments.brick.ToString());
                    print(Response1.arguments.wool.ToString());

                    lumber.text = Response1.arguments.lumber.ToString();
                    ore.text    = Response1.arguments.ore.ToString();
                    grain.text  = Response1.arguments.grain.ToString();
                    brick.text  = Response1.arguments.brick.ToString();
                    wool.text   = Response1.arguments.wool.ToString();
                }).Catch(err => { Debug.Log(err); });
            }
        });
    }