Exemple #1
0
 public void SellCard()
 {
     if (owner == turn.player)
     {
         if (upgradeLevel > 0 && owner == turn.player && owner.GetComponent <Property>().CheckForSell(this))
         {
             upgradeLevel--;
             upgradeCost -= 50;
             cost        /= 2;
         }
         else if (upgradeLevel == 0)
         {
             // заложить
             owner.GetComponent <Money>().Transaction(-cost / 2);
             cost        = 0;
             upgradeCost = startValue;
         }
     }
 }
Exemple #2
0
    public void Buy()
    {
        PlayerStuff player = GetComponent <Turn>().player;
        Card        card   = player.targetCard;
        Property    prop   = player.GetComponent <Property>();

        if (player.gameObject.GetComponent <Money>().Transaction(card.cost))
        {
            print("Опреция завершена");

            player.GetComponent <Property>().AddCard();

            player.EndTurn();
        }
        else
        {
            print("Недостаточно стредств");
        }
    }
Exemple #3
0
    public void Buy(Card card, PlayerStuff player)
    {
        Property prop = player.GetComponent <Property>();

        if (player.gameObject.GetComponent <Money>().Transaction(card.cost))
        {
            print("Опреция завершена");

            prop.AddCard(card);
        }
        else
        {
            print("Недостаточно стредств");
        }
    }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        warningWindow.gameObject.SetActive(false);

        turn = GameObject.Find("players").GetComponent <Turn>();
        okFirst.onClick.AddListener(() =>
        {
            firstFinished = !firstFinished;
            turn.player.tablePlayer.GetComponent <TradeCenter>().firstFinished = firstFinished;
            ColorBlock newColors = okFirst.colors;
            if (firstFinished)
            {
                newColors.normalColor      = finishedColor;
                newColors.highlightedColor = finishedColor;
                okFirst.colors             = newColors;
            }
            else
            {
                newColors.normalColor      = notFinishedColor;
                newColors.highlightedColor = notFinishedColor;

                okFirst.colors = newColors;
            }
        });

        okSecond.onClick.AddListener(() =>
        {
            if (firstFinished)
            {
                secondFinished = !secondFinished;

                warningWindow.gameObject.SetActive(true);
            }
        });

        warningOk.onClick.AddListener(() =>
        {
            //добавить карты, деньги
            foreach (Transform item in list1.transform)
            {
                turn.player.GetComponent <Property>().RemoveCard(item.GetComponent <tradeCard>().card);
                secondTrader.GetComponent <Property>().AddCard(item.GetComponent <tradeCard>().card);
                GameObject.DestroyObject(item.gameObject);
            }
            foreach (Transform item in list2.transform)
            {
                secondTrader.GetComponent <Property>().RemoveCard(item.GetComponent <tradeCard>().card);
                turn.player.GetComponent <Property>().AddCard(item.GetComponent <tradeCard>().card);
                GameObject.DestroyObject(item.gameObject);
            }

            turn.player.GetComponent <Money>().Transaction(Convert.ToInt32(moneyAmount1.text.Split(' ')[1].TrimEnd('$')) + -(Convert.ToInt32(moneyAmount2.text.Split(' ')[1].TrimEnd('$'))));
            secondTrader.GetComponent <Money>().Transaction(-(Convert.ToInt32(moneyAmount1.text.Split(' ')[1].TrimEnd('$'))) + Convert.ToInt32(moneyAmount2.text.Split(' ')[1].TrimEnd('$')));



            // reset
            firstFinished = false;
            turn.player.tablePlayer.GetComponent <TradeCenter>().firstFinished = false;
            turn.player.tablePlayer.GetComponent <TradeCenter>().ResetList();
            secondFinished    = false;
            money1.text       = string.Empty;
            money2.text       = string.Empty;
            moneyAmount1.text = moneyAmount2.text = "Деньгами: 0$";

            ColorBlock newColors       = okFirst.colors;
            newColors.normalColor      = notFinishedColor;
            newColors.highlightedColor = notFinishedColor;
            okFirst.colors             = newColors;

            warningWindow.gameObject.SetActive(false);

            gameObject.SetActive(false);
        });

        warningReject.onClick.AddListener(() =>
        {
            warningWindow.gameObject.SetActive(false);
        });

        addMoney1.onClick.AddListener(() =>
        {
            if (turn.player.GetComponent <Money>().IsMoneyGreaterThan((string.IsNullOrEmpty(money1.text) ? 0 : int.Parse(money1.text))))
            {
                int money         = Convert.ToInt32(moneyAmount1.text.Split(' ')[1].TrimEnd('$'));
                moneyAmount1.text = "Деньгами: " + (money + (string.IsNullOrEmpty(money1.text) ? 0 : int.Parse(money1.text))) + "$";
                money1.text       = string.Empty;
            }
        });

        addMoney2.onClick.AddListener(() =>
        {
            if (secondTrader.GetComponent <Money>().IsMoneyGreaterThan((string.IsNullOrEmpty(money2.text) ? 0 : int.Parse(money2.text))))
            {
                int money = Convert.ToInt32(moneyAmount2.text.Split(' ')[1].TrimEnd('$'));

                moneyAmount2.text = "Деньгами: " + (money + (string.IsNullOrEmpty(money2.text) ? 0 : int.Parse(money2.text))) + "$";
                money2.text       = string.Empty;
            }
        });


        money1.onValidateInput += (string input, int charIndex, char c) => "0123456789".Contains(c.ToString()) ? c : '\0';
        money2.onValidateInput += (string input, int charIndex, char c) => "0123456789".Contains(c.ToString()) ? c : '\0';

        tradeCancel.onClick.AddListener(() =>
        { // reset
            firstFinished = false;
            turn.player.tablePlayer.GetComponent <TradeCenter>().firstFinished = false;
            turn.player.tablePlayer.GetComponent <TradeCenter>().ResetList();
            secondFinished    = false;
            money1.text       = string.Empty;
            money2.text       = string.Empty;
            moneyAmount1.text = moneyAmount2.text = "Деньгами: 0$";

            ColorBlock newColors       = okFirst.colors;
            newColors.normalColor      = notFinishedColor;
            newColors.highlightedColor = notFinishedColor;
            okFirst.colors             = newColors;

            warningWindow.gameObject.SetActive(false);

            gameObject.SetActive(false);
        });
    }
Exemple #5
0
    internal void ChanceCard()
    {
        PlayerStuff player = turn.player;

        dia = hud.GetComponentInChildren <DialogCentre>(true);

        switch (UnityEngine.Random.Range(0, 4))
        {
        case 0: dia.ShowMessage("Игрок " + player.name + " находит мелочь на дороге. +684$"); player.GetComponent <Money>().Transaction(-684); player.EndTurn(); break;

        case 1: dia.ShowMessage("Игрок " + player.name + " замечает несколько купюр в зимней куртке. +980$"); player.GetComponent <Money>().Transaction(-980); player.EndTurn(); break;

        case 2: dia.ShowMessage("Игрок " + player.name + " выигрывает региональный конкурс предпринимателей. +1500$"); player.GetComponent <Money>().Transaction(-1500); player.EndTurn(); break;

        case 3: dia.ShowMessage("Игрок " + player.name + " проливает чай на свой компьютер. Починка 1000$"); player.targetCard.cost = 1000; ShowPay(); break;

        case 4: dia.ShowMessage("Игроку " + player.name + " пора отдохнуть. Поезка на море обойдется в 2000$"); player.targetCard.cost = 2000; ShowPay(); break;
        }
    }