Ejemplo n.º 1
0
    private void OnMouseDown()
    {
        //todo: check road bought
        if (!GameController.ShouldRoadClickable)
        {
            return;
        }
        if (GameController.Turn != MainScreen.ThisPlayerID)
        {
            return;
        }
        if (!IsRoadPositionValid())
        {
            // todo Uncomment for build.
            MainScreen.showDialog("خطا", "نمی توانید جاده خود را اینجا بسازید");
            return;
        }

        builtID = MainScreen.ThisPlayerID;
        ChangeRoadColor(MainScreen.ThisPlayerPlayerColor.GetColor());
        Debug.Log(gameObject.name);
        GameController.ShouldRoadClickable = false;
        if (GameController.Action == GameState.init1 || GameController.Action == GameState.init2)
        {
            var body = "{\"vertex\": " + MainScreen.SelectedSettlement + ", \"road_v1\": " + s1.name +
                       ", \"road_v2\": " + s2.name + "}";
            StartCoroutine(Network.PostRequest(GameController.Action == GameState.init1 ? URL.Init1 : URL.Init2, body,
                                               s => { }, URL.Headers(), true));
        }
    }
Ejemplo n.º 2
0
    /**
     * It's time to roll the dice. Post to server if it's your turn.
     */
    public void Dice(string[] args)
    {
        var turn = int.Parse(args[0]);

        if (turn == ThisPlayerID)
        {
            StartCoroutine(Network.PostRequest(URL.Dice, string.Empty, s => { }, URL.Headers()));
        }
    }
Ejemplo n.º 3
0
    public void OnBankTradeStarted()
    {
        if (give.options.Contains(desert))
        {
            return;
        }

        string request;

        if (give.options[give.value].text == "آجر")
        {
            request = "brick";
        }
        else if (give.options[give.value].text == "چوب")
        {
            request = "wood";
        }
        else if (give.options[give.value].text == "گوسفند")
        {
            request = "sheep";
        }
        else if (give.options[give.value].text == "سنگ")
        {
            request = "stone";
        }
        else
        {
            request = "wheat";
        }

        string will;

        if (want.options[want.value].text == "آجر")
        {
            will = "brick";
        }
        else if (want.options[want.value].text == "چوب")
        {
            will = "wood";
        }
        else if (want.options[want.value].text == "گوسفند")
        {
            will = "sheep";
        }
        else if (want.options[want.value].text == "سنگ")
        {
            will = "stone";
        }
        else
        {
            will = "wheat";
        }

        StartCoroutine(Network.PostRequest(URL.TradeBank, "{\"give\": \"" + request + "\", \"want\": \"" + will + "\"}", s => { },
                                           URL.Headers(), true));
    }
Ejemplo n.º 4
0
    private void BuyRoad()
    {
        var personal = UpdateMyPlayer.Personal;

        if (personal.brick_count == 0 || personal.wood_count == 0)
        {
            return;
        }
        StartCoroutine(Network.PostRequest(URL.CreateRoad, string.Empty, s => { }, URL.Headers()));
    }
Ejemplo n.º 5
0
    private void BuyDevelopmentCard()
    {
        var personal = UpdateMyPlayer.Personal;

        if (personal.sheep_count == 0 || personal.wheat_count == 0 || personal.stone_count == 0)
        {
            return;
        }

        StartCoroutine(Network.PostRequest(URL.BuyDevelopmentCard, string.Empty, s =>
        {
            s = s.Trim('"');
            string message;
            string title;
            switch (s)
            {
            case "victory":
                message = "تبریک! شما یک قدم به پیروزی نزدیکتر شدید.";
                title   = "کارت پیروزی";
                break;

            case "monopoly":
                message = "یک کارت مونوپولی برای شما.";
                title   = "کارت مونوپولی";
                break;

            case "year_of_plenty":
                message = "یک کارت سال فراوانی به کارت های شما اضافه شد.";
                title   = "کارت سال فراوانی";
                break;

            case "road_building":
                message = "شما در قرعه کشی بانک برنده کمک هزینه ساخت دو جاده شده اید.";
                title   = "کارت ساخت جاده";
                break;

            case "knight":
                message = "امنیت قلمرو خود را بیش از پیش تضمین کنید.";
                title   = "کارت شوالیه";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            // var result = DisplayDialog(title, message, "باشه.");
        }, URL.Headers()));
    }
Ejemplo n.º 6
0
    public void OnBuyStarted()
    {
        if (_willingBrick.text == "0" &&
            _willingWheat.text == "0" &&
            _willingWood.text == "0" &&
            _willingSheep.text == "0" &&
            _willingStone.text == "0" ||
            _offeringBrick.text == "0" &&
            _offeringWheat.text == "0" &&
            _offeringWood.text == "0" &&
            _offeringSheep.text == "0" &&
            _offeringStone.text == "0")
        {
            return;
        }

        var data = new TradeRequest
        {
            give = new Trade
            {
                brick = int.Parse(_offeringBrick.text),
                sheep = int.Parse(_offeringSheep.text),
                stone = int.Parse(_offeringStone.text),
                wheat = int.Parse(_offeringWheat.text),
                wood = int.Parse(_offeringWood.text)
            },
            want = new Trade
            {
                brick = int.Parse(_willingBrick.text),
                sheep = int.Parse(_willingSheep.text),
                stone = int.Parse(_willingStone.text),
                wheat = int.Parse(_willingWheat.text),
                wood = int.Parse(_willingWood.text)
            }
        };
        StartCoroutine(Network.PostRequest(URL.Trade, JsonUtility.ToJson(data), s => { }, URL.Headers(), true));
    }
Ejemplo n.º 7
0
 public void Pass()
 {
     StartCoroutine(Network.PostRequest(URL.Pass, string.Empty, s => { }, URL.Headers()));
 }