コード例 #1
0
ファイル: ChangeTexture.cs プロジェクト: robertpalade/Catan
    // Update is called once per frame
    void Update()
    {
        Text txt = FindTextFiel.find();
        BoardConnectivityJson board = ReceiveBoardScript.ReceivedBoard;

        if (done == false)
        {
            if (ReceiveBoardScript.ReceivedBoard.board[0] != null)
            {
                string str = "";
                str       = board.board[nr].number.ToString();
                text.text = str;
                string resource = board.board[nr].resource;
                txt.text = resource;
                Debug.Log(resource);
                switch (resource)
                {
                case "lumber":
                    Instantiate(objForest, SpawnForestOre.position, SpawnForestOre.rotation);
                    break;

                case "wool":
                    Instantiate(objPasture, SpawnPasture.position, SpawnPasture.rotation);
                    break;

                case "ore":
                    Instantiate(objOre, SpawnForestOre.position, SpawnForestOre.rotation);
                    break;

                case "grain":
                    Instantiate(objGrain, SpawnPasture.position, SpawnPasture.rotation);
                    break;

                case "desert":
                    tataLaRobberi.SetActive(true);
                    Instantiate(objDesert, SpawnDesertField.position, SpawnDesertField.rotation);
                    Instantiate(robbler, robber.position, robber.rotation);
                    tataLaRobberi.SetActive(false);
                    break;

                case "brick":
                    Instantiate(objBrick, SpawnHills.position, SpawnHills.rotation);
                    break;
                }
                done = true;
            }

            // else
            //     Debug.Log("Null");
        }
    }
コード例 #2
0
    void OnMouseDown()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        Text txt = FindTextFiel.find();

        MakeRequestResponse command = new MakeRequestResponse();

        command.gameId       = LoginScript.CurrentUserGameId;
        command.playerId     = LoginScript.CurrentUserGEId;
        command.intersection = int.Parse(piece.name);
        RequestJson req = new RequestJson();

        RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/buyCity", command).Then(Response =>
        {
            req.code   = Response.code;
            req.status = Response.status;
            if (req.code == 200)
            {
                JSONObject json_message = new JSONObject();
                json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
                json_message.AddField("username", LoginScript.CurrentUser);
                json_message.AddField("intersection", command.intersection);
                socket.Emit("buyCity", json_message);
                allPieces.SetActive(false);
                if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser)
                {
                    AfiseazaDrum.afiseaza(newPieceO1, piece);
                }
                else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser)
                {
                    AfiseazaDrum.afiseaza(newPieceO2, piece);
                }
                else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser)
                {
                    AfiseazaDrum.afiseaza(newPieceO3, piece);
                }
                else if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser)
                {
                    AfiseazaDrum.afiseaza(newPieceO4, piece);
                }
            }
            Debug.Log(req.code);
            Debug.Log(req.status);

            txt.text = req.status;
        }).Catch(err => { Debug.Log(err); });
        allPieces.SetActive(false);
    }
コード例 #3
0
    public void pressed()
    {
        Text txt = FindTextFiel.find();
        MakeRequestResponse command2 = new MakeRequestResponse();

        command2.gameId   = LoginScript.CurrentUserGameId;
        command2.playerId = LoginScript.CurrentUserGEId;
        command2.answer   = "yes";
        command2.player   = tex1.text;

        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        RestClient.Post <MoveRobberRequest>("https://catan-connectivity.herokuapp.com/game/stealResource", command2).Then(Response2 =>
        {
            Debug.Log("Stolen");
            txt.text = Response2.status;
            JSONObject json_message = new JSONObject();
            json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
            socket.Emit("Stolen", 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);

                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());

                ilumber.text = Response1.arguments.lumber.ToString();
                iore.text    = Response1.arguments.ore.ToString();
                igrain.text  = Response1.arguments.grain.ToString();
                ibirck.text  = Response1.arguments.brick.ToString();
                iwool.text   = Response1.arguments.wool.ToString();
            }).Catch(err => { Debug.Log(err); });
        }).Catch(err => { Debug.Log(err); });
    }
コード例 #4
0
ファイル: Dices.cs プロジェクト: robertpalade/Catan
    public void Show()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        int  j, i;
        Text txt = FindTextFiel.find();
        MakeRequestResponse command = new MakeRequestResponse();

        command.gameId   = LoginScript.CurrentUserGameId;
        command.playerId = LoginScript.CurrentUserGEId;
        RequestJson req = new RequestJson();

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


            if (req.code == 200)
            {
                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("dice_1", Response.arguments.dice_1);
                json_message.AddField("dice_2", Response.arguments.dice_2);
                json_message.AddField("player_0", Response.arguments.player_0);
                json_message.AddField("lumber_0", Response.arguments.lumber_0);
                json_message.AddField("wool_0", Response.arguments.wool_0);
                json_message.AddField("grain_0", Response.arguments.grain_0);
                json_message.AddField("brick_0", Response.arguments.brick_0);
                json_message.AddField("ore_0", Response.arguments.ore_0);
                json_message.AddField("player_1", Response.arguments.player_1);
                json_message.AddField("lumber_1", Response.arguments.lumber_1);
                json_message.AddField("wool_1", Response.arguments.wool_1);
                json_message.AddField("grain_1", Response.arguments.grain_1);
                json_message.AddField("brick_1", Response.arguments.brick_1);
                json_message.AddField("ore_1", Response.arguments.ore_1);
                json_message.AddField("player_2", Response.arguments.player_2);
                json_message.AddField("lumber_2", Response.arguments.lumber_2);
                json_message.AddField("wool_2", Response.arguments.wool_2);
                json_message.AddField("grain_2", Response.arguments.grain_2);
                json_message.AddField("brick_2", Response.arguments.brick_2);
                json_message.AddField("ore_2", Response.arguments.ore_2);
                json_message.AddField("player_3", Response.arguments.player_3);
                json_message.AddField("lumber_3", Response.arguments.lumber_3);
                json_message.AddField("wool_3", Response.arguments.wool_3);
                json_message.AddField("grain_3", Response.arguments.grain_3);
                json_message.AddField("brick_3", Response.arguments.brick_3);
                json_message.AddField("ore_3", Response.arguments.ore_3);
                socket.Emit("RollDice", json_message);

                j = Response.arguments.dice_1;
                i = Response.arguments.dice_2;

                if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser)
                {
                    lumber.text = (int.Parse(lumber.text) + Response.arguments.lumber_3).ToString();
                    ore.text    = (int.Parse(ore.text) + Response.arguments.ore_3).ToString();
                    grain.text  = (int.Parse(grain.text) + Response.arguments.grain_3).ToString();
                    brick.text  = (int.Parse(brick.text) + Response.arguments.brick_3).ToString();
                    wool.text   = (int.Parse(wool.text) + Response.arguments.wool_3).ToString();
                }
                else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser)
                {
                    lumber.text = (int.Parse(lumber.text) + Response.arguments.lumber_2).ToString();
                    ore.text    = (int.Parse(ore.text) + Response.arguments.ore_2).ToString();
                    grain.text  = (int.Parse(grain.text) + Response.arguments.grain_2).ToString();
                    brick.text  = (int.Parse(brick.text) + Response.arguments.brick_2).ToString();
                    wool.text   = (int.Parse(wool.text) + Response.arguments.wool_2).ToString();
                }
                else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser)
                {
                    lumber.text = (int.Parse(lumber.text) + Response.arguments.lumber_1).ToString();
                    ore.text    = (int.Parse(ore.text) + Response.arguments.ore_1).ToString();
                    grain.text  = (int.Parse(grain.text) + Response.arguments.grain_1).ToString();
                    brick.text  = (int.Parse(brick.text) + Response.arguments.brick_1).ToString();
                    wool.text   = (int.Parse(wool.text) + Response.arguments.wool_1).ToString();
                }
                else if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser)
                {
                    lumber.text = (int.Parse(lumber.text) + Response.arguments.lumber_0).ToString();
                    ore.text    = (int.Parse(ore.text) + Response.arguments.ore_0).ToString();
                    grain.text  = (int.Parse(grain.text) + Response.arguments.grain_0).ToString();
                    brick.text  = (int.Parse(brick.text) + Response.arguments.brick_0).ToString();
                    wool.text   = (int.Parse(wool.text) + Response.arguments.wool_0).ToString();
                }


                switch (j)
                {
                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 (i)
                {
                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;
                }
                if (i + j == 7)
                {
                    tataHot.SetActive(true);

                    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)
                    {
                        tataPanel.SetActive(true);
                        player_0_sum      = player_0_sum / 2;
                        DiscarAmount.text = "You have to discard " + player_0_sum.ToString() + " of your cards";
                        ibirck.text       = "";
                        iore.text         = "";
                        ilumber.text      = "";
                        igrain.text       = "";
                        iwool.text        = "";
                    }
                }
            }
            txt.text = req.status;
        }).Catch(err => { Debug.Log(err); });
    }
コード例 #5
0
ファイル: BankTrade.cs プロジェクト: robertpalade/Catan
    public void Trade()
    {
        print("banktrade");
        string str  = null;
        string str1 = null;

        if (togle0.isOn)
        {
            str = "lumber";
        }
        else
        if (togle1.isOn)
        {
            str = "brick";
        }
        else
        if (togle2.isOn)
        {
            str = "wool";
        }
        else
        if (togle3.isOn)
        {
            str = "grain";
        }
        else
        if (togle4.isOn)
        {
            str = "ore";
        }

        if (togle5.isOn)
        {
            str1 = "lumber";
        }
        else
        if (togle6.isOn)
        {
            str1 = "brick";
        }
        else
        if (togle7.isOn)
        {
            str1 = "wool";
        }
        else
        if (togle8.isOn)
        {
            str1 = "grain";
        }
        else
        if (togle9.isOn)
        {
            str1 = "ore";
        }

        MakeRequestResponse command = new MakeRequestResponse();

        command.gameId   = LoginScript.CurrentUserGameId;
        command.playerId = LoginScript.CurrentUserGEId;
        command.port     = -1;
        command.offer    = str;
        command.request  = str1;
        print(str);
        print(str1);
        RequestJson req = new RequestJson();
        Text        txt = FindTextFiel.find();

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

            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); });
    }
コード例 #6
0
ファイル: EndTurn.cs プロジェクト: robertpalade/Catan
    public void endTurn()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        Text txt = FindTextFiel.find();

        if (ver.text == "2")
        {
            MakeRequestResponse command = new MakeRequestResponse();
            command.gameId       = LoginScript.CurrentUserGameId;
            command.playerId     = LoginScript.CurrentUserGEId;
            command.intersection = 0;
            command.start        = 0;
            command.end          = 0;
            //Debug.Log(CurrentUserGame);
            //Debug.Log(CurrentUserId);
            RequestJson req = new RequestJson();
            RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/endTurn", command).Then(Response =>
            {
                req.code      = Response.code;
                req.status    = Response.status;
                req.arguments = Response.arguments;
                Debug.Log(req.code);
                Debug.Log(req.arguments);
                Debug.Log(req.status);
                txt.text = req.status;
                if (req.code == 200)
                {
                    JSONObject json_message = new JSONObject();
                    json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
                    json_message.AddField("username", LoginScript.CurrentUser);
                    socket.Emit("endturn", json_message);
                    if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser)
                    {
                        player1.SetActive(false);
                        player2.SetActive(true);
                        player3.SetActive(false);
                        player4.SetActive(false);
                    }
                    else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser)
                    {
                        player2.SetActive(false);
                        player3.SetActive(true);
                        player1.SetActive(false);
                        player4.SetActive(false);
                    }
                    else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser)
                    {
                        player3.SetActive(false);
                        player4.SetActive(true);
                        player1.SetActive(false);
                        player2.SetActive(false);
                    }
                    else if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser)
                    {
                        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());

                    ilumber.text = Response1.arguments.lumber.ToString();
                    iore.text    = Response1.arguments.ore.ToString();
                    igrain.text  = Response1.arguments.grain.ToString();
                    ibirck.text  = Response1.arguments.brick.ToString();
                    iwool.text   = Response1.arguments.wool.ToString();
                }).Catch(err => { Debug.Log(err); });
            }).Catch(err => { Debug.Log(err); });
        }
    }
コード例 #7
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); });
    }
コード例 #8
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); });
            }
        });
    }
コード例 #9
0
ファイル: addDevCard.cs プロジェクト: robertpalade/Catan
    public void buyDev()
    {
        Text txt = FindTextFiel.find();
        MakeRequestResponse command = new MakeRequestResponse();

        command.gameId   = LoginScript.CurrentUserGameId;
        command.playerId = LoginScript.CurrentUserGEId;
        RequestJsonDevelopmentExceptMonopoly req = new RequestJsonDevelopmentExceptMonopoly();

        RestClient.Post <RequestJsonDevelopmentExceptMonopoly>("https://catan-connectivity.herokuapp.com/game/buyDevelopment", command).Then(Response =>
        {
            req.code      = Response.code;
            req.status    = Response.status;
            req.arguments = Response.arguments;
            int nr        = 0;
            print(req.arguments.development);
            if (req.code == 200)
            {
                knight       = GameObject.Find("KnightText").GetComponent <Text>();
                roadbuid     = GameObject.Find("RoadBuildingText").GetComponent <Text>();
                monopoly     = GameObject.Find("MonopolyText").GetComponent <Text>();
                yearofplenty = GameObject.Find("YearOfPlentyText").GetComponent <Text>();
                univer       = GameObject.Find("VictoryPointText").GetComponent <Text>();
                if (req.arguments.development == "roadBuilding")
                {
                    nr            = int.Parse(roadbuid.text) + 1;
                    roadbuid.text = nr.ToString();
                }
                if (req.arguments.development == "knight")
                {
                    nr          = int.Parse(knight.text) + 1;
                    knight.text = nr.ToString();
                }
                if (req.arguments.development == "monopoly")
                {
                    nr            = int.Parse(monopoly.text) + 1;
                    monopoly.text = nr.ToString();
                }
                if (req.arguments.development == "yearOfPlenty")
                {
                    nr = int.Parse(yearofplenty.text) + 1;
                    yearofplenty.text = nr.ToString();
                }
                int x;

                x           = int.Parse(igrain.text) - 1;
                igrain.text = x.ToString();
                x           = int.Parse(iwool.text) - 1;
                iwool.text  = x.ToString();
                x           = int.Parse(iore.text) - 1;
                iore.text   = x.ToString();
            }



            Debug.Log(req.code);
            Debug.Log(req.status);
            Debug.Log(req.arguments);
            txt.text = req.status;
        }).Catch(err => { Debug.Log(err); });
    }
コード例 #10
0
ファイル: provizoriu.cs プロジェクト: robertpalade/Catan
    void OnMouseDown()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIOComponent>();
        Text txt = FindTextFiel.find();

        if (numar != -1)
        {
            if (ver.text == "2")
            {
                MakeRequestResponse command = new MakeRequestResponse();
                command.gameId       = LoginScript.CurrentUserGameId;
                command.playerId     = LoginScript.CurrentUserGEId;
                command.intersection = numar;
                RequestJson req = new RequestJson();

                RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/buySettlement", command).Then(Response =>
                {
                    req.code   = Response.code;
                    req.status = Response.status;
                    if (req.code == 200)
                    {
                        JSONObject json_message = new JSONObject();
                        json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
                        json_message.AddField("username", LoginScript.CurrentUser);
                        json_message.AddField("intersection", command.intersection);
                        print(command.intersection);
                        socket.Emit("buildsettlement", json_message);


                        if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece1, piece);
                        }
                        else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece2, piece);
                        }
                        else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece3, piece);
                        }
                        else if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece4, piece);
                        }

                        allPieces.SetActive(false);
                        int x       = int.Parse(lumber.text) - 1;
                        lumber.text = x.ToString();
                        x           = int.Parse(brick.text) - 1;
                        brick.text  = x.ToString();
                        x           = int.Parse(grain.text) - 1;
                        grain.text  = x.ToString();
                        x           = int.Parse(wool.text) - 1;
                        wool.text   = x.ToString();
                    }

                    Debug.Log(req.code);
                    Debug.Log(req.status);

                    txt.text = req.status;
                }).Catch(err => { Debug.Log(err); });
            }
            else
            {
                MakeRequestResponse command = new MakeRequestResponse();
                command.gameId       = LoginScript.CurrentUserGameId;
                command.playerId     = LoginScript.CurrentUserGEId;
                command.intersection = numar;
                RequestJson req = new RequestJson();

                RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/buildSettlement", command).Then(Response =>
                {
                    req.code   = Response.code;
                    req.status = Response.status;
                    if (req.code == 200)
                    {
                        JSONObject json_message = new JSONObject();
                        json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
                        json_message.AddField("username", LoginScript.CurrentUser);
                        json_message.AddField("intersection", command.intersection);
                        print(command.intersection);
                        socket.Emit("buildsettlement", json_message);


                        if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece1, piece);
                        }
                        else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece2, piece);
                        }
                        else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece3, piece);
                        }
                        else if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece4, piece);
                        }
                    }
                    allPieces.SetActive(false);
                    Debug.Log(req.code);
                    Debug.Log(req.status);

                    txt.text = req.status;
                    if (ver.text == "1")
                    {
                        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); });
            }
        }
        else
        {
            if (ver.text == "2")
            {
                MakeRequestResponse command = new MakeRequestResponse();
                command.gameId       = LoginScript.CurrentUserGameId;
                command.playerId     = LoginScript.CurrentUserGEId;
                command.intersection = 0;
                command.start        = capat1;
                command.end          = capat2;
                //Debug.Log(CurrentUserGame);
                //Debug.Log(CurrentUserId);
                RequestJson req = new RequestJson();


                RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/buyRoad", command).Then(Response =>
                {
                    req.code   = Response.code;
                    req.status = Response.status;
                    if (req.code == 200)
                    {
                        JSONObject json_message = new JSONObject();
                        json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
                        json_message.AddField("username", LoginScript.CurrentUser);
                        json_message.AddField("start", command.start);
                        json_message.AddField("end", command.end);
                        socket.Emit("buildroad", json_message);
                        allPieces.SetActive(false);
                        if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece1, piece);
                        }
                        else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece2, piece);
                        }
                        else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece3, piece);
                        }
                        else if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser)
                        {
                            AfiseazaDrum.afiseaza(newPiece4, piece);
                        }

                        int x       = int.Parse(lumber.text) - 1;
                        lumber.text = x.ToString();
                        x           = int.Parse(brick.text) - 1;
                        brick.text  = x.ToString();
                    }
                    Debug.Log(req.code);
                    Debug.Log(req.status);

                    txt.text = req.status;
                }).Catch(err => { Debug.Log(err); });
                allPieces.SetActive(false);
            }

            else
            {
                MakeRequestResponse command = new MakeRequestResponse();
                command.gameId       = LoginScript.CurrentUserGameId;
                command.playerId     = LoginScript.CurrentUserGEId;
                command.intersection = 0;
                command.start        = capat1;
                command.end          = capat2;
                //Debug.Log(CurrentUserGame);
                //Debug.Log(CurrentUserId);
                RequestJson req = new RequestJson();


                RestClient.Post <RequestJson>("https://catan-connectivity.herokuapp.com/game/buildRoad", command).Then(Response =>
                {
                    req.code   = Response.code;
                    req.status = Response.status;
                    if (req.code == 200)
                    {
                        JSONObject json_message = new JSONObject();
                        json_message.AddField("lobbyid", LoginScript.CurrentUserLobbyId);
                        json_message.AddField("username", LoginScript.CurrentUser);
                        json_message.AddField("start", command.start);
                        json_message.AddField("end", command.end);
                        socket.Emit("buildroad", json_message);
                        allPieces.SetActive(false);
                        if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser && ver.text == "0")
                        {
                            AfiseazaDrum.afiseaza(newPiece1, piece);
                            player1.SetActive(false);
                            player2.SetActive(true);
                            player3.SetActive(false);
                            player4.SetActive(false);
                        }
                        else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser && ver.text == "0")
                        {
                            AfiseazaDrum.afiseaza(newPiece2, piece);

                            player2.SetActive(false);
                            player3.SetActive(true);
                            player1.SetActive(false);
                            player4.SetActive(false);
                        }
                        else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser && ver.text == "0")
                        {
                            AfiseazaDrum.afiseaza(newPiece3, piece);

                            player3.SetActive(false);
                            player4.SetActive(true);
                            player1.SetActive(false);
                            player2.SetActive(false);
                        }
                        else if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser && ver.text == "0")
                        {
                            AfiseazaDrum.afiseaza(newPiece4, piece);

                            player4.SetActive(true);
                            player1.SetActive(false);
                            player3.SetActive(false);
                            player2.SetActive(false);
                            //  ok = true;
                            ver.text = "1";
                        }
                        else if (LoginScript.CurrentLobby.third == LoginScript.CurrentUser && ver.text == "1")
                        {
                            AfiseazaDrum.afiseaza(newPiece4, piece);
                            player4.SetActive(false);
                            player1.SetActive(false);
                            player3.SetActive(true);
                            player2.SetActive(false);
                        }
                        else if (LoginScript.CurrentLobby.second == LoginScript.CurrentUser && ver.text == "1")
                        {
                            AfiseazaDrum.afiseaza(newPiece3, piece);
                            player4.SetActive(false);
                            player1.SetActive(false);
                            player3.SetActive(false);
                            player2.SetActive(true);
                        }
                        else if (LoginScript.CurrentLobby.first == LoginScript.CurrentUser && ver.text == "1")
                        {
                            AfiseazaDrum.afiseaza(newPiece2, piece);
                            player4.SetActive(false);
                            player1.SetActive(true);
                            player3.SetActive(false);
                            player2.SetActive(false);
                        }
                        else if (LoginScript.CurrentLobby.master == LoginScript.CurrentUser && ver.text == "1")
                        {
                            AfiseazaDrum.afiseaza(newPiece1, piece);
                            player4.SetActive(false);
                            player1.SetActive(true);
                            player3.SetActive(false);
                            player2.SetActive(false);
                            ver.text = "2";
                        }
                    }
                    Debug.Log(req.code);
                    Debug.Log(req.status);
                    txt.text = req.status;
                }).Catch(err => { Debug.Log(err); });
            }


            allPieces.SetActive(false);
        }
    }