コード例 #1
0
    public void Confirm()
    {
        LogManager.addLog(string.Format("{0} bought {1} from {2} for {3} Baht.",
                                        currentPlayer.name, currentField.name, currentField.owner.name,
                                        currentField.getBuyOutPrice().ToString()));

        LogManager.addLog(string.Format("{0} get {1} Baht from Buyout",
                                        currentField.owner.name, (currentField.getBuyOutPrice() * 0.7).ToString()));

        this.currentPlayer.money      -= this.currentField.getBuyOutPrice();
        this.currentField.owner.money += (int)(this.currentField.getBuyOutPrice()
                                               * (1 - GameController.Tax) / 2);


        this.currentField.owner.removeField(this.currentField);
        if (this.currentField.type == FieldType.marketField)
        {
            this.currentPlayer.changeMultiPlyer(this.currentField.zone, 2);
            this.currentField.owner.changeMultiPlyer(this.currentField.zone, 1);
        }
        this.currentField.owner = this.currentPlayer;
        this.currentPlayer.AddField(this.currentField);



        GameController.isBuyOut    = true;
        GameController.isBuyoutFin = true;
    }
コード例 #2
0
ファイル: GameController.cs プロジェクト: Pongparit/ABSU
    IEnumerator defaultFieldEvent()
    {
        DefaultField field     = defaultField.Find(x => x.Id == players[currentPlayer].fieldId);
        Player       curPlayer = players[currentPlayer];
        Player       owner     = field.owner;

        if ((owner == null || owner == curPlayer) && curPlayer.buyQouta > 0)
        {
            //No Owner
            isShopOpen = true;
            isBuyFin   = false;
            ShopCanvas.SetActive(isShopOpen);
            // Debug.Log(defaultField.Find(x => x.Id== curPlayer.fieldId).ToString());
            shoplist.Display(curPlayer, defaultField.Find(x => x.Id == curPlayer.fieldId));
            // logManager.addLog("test");
            yield return(new WaitUntil(() => isBuyFin == true));

            curPlayer.updateUI();
            field.updateUI();

            isShopOpen = false;
            ShopCanvas.SetActive(isShopOpen);
            //
            yield return(null);
        }
        else
        {
            //Other Owner
            int standCost   = field.getStandCost();
            int buyoutPrice = field.getBuyOutPrice();
            //Reduce Money here
            if (curPlayer.money > standCost)
            {
                curPlayer.money -= standCost;
                owner.money     += standCost;

                logManager.addLog(string.Format("{0} Lose {1} Baht to {2}.", curPlayer.name, standCost, owner.name));
                owner.updateUI();
                curPlayer.updateUI();
                // field.updateUI();
                if (curPlayer.money >= buyoutPrice)
                {
                    //Buy out here
                    isBuyFin    = false;
                    isBuyOut    = false;
                    isBuyoutFin = false;
                    BuyOutCanvas.SetActive(true);
                    buyout.Display(curPlayer, defaultField.Find(x => x.Id == curPlayer.fieldId));
                    yield return(new WaitUntil(() => isBuyoutFin == true));

                    BuyOutCanvas.SetActive(false);
                    owner.updateUI();
                    curPlayer.updateUI();
                    field.updateUI();
                    if (isBuyOut && curPlayer.buyQouta > 0 && field.type == FieldType.defaultField)
                    {
                        isShopOpen = true;
                        ShopCanvas.SetActive(isShopOpen);
                        shoplist.Display(curPlayer, defaultField.Find(x => x.Id == curPlayer.fieldId));
                        yield return(new WaitUntil(() => isBuyFin == true));

                        isShopOpen = false;
                        ShopCanvas.SetActive(isShopOpen);
                        owner.updateUI();
                        curPlayer.updateUI();
                        field.updateUI();
                    }
                }
            }
            else
            {
                owner.money += standCost;
                foreach (DefaultField f in curPlayer.owning)
                {
                    f.removePlant();
                    f.owner = null;
                }
                players.Remove(curPlayer);
            }

            yield return(null);
        }
    }