Пример #1
0
 /**
  * Overloaded method.
  * Displays the data unique for PropertyCard.
  */
 public void DisplayCard(PropertyCard card, Color color)
 {
     paymentLabel1.Text      = "Payment 1: " + card.GetPayment(0) + "m";
     paymentLabel2.Text      = "Payment 2: " + card.GetPayment(1) + "m";
     paymentLabel3.Text      = "Payment 3: " + card.GetPayment(2) + "m";
     paymentLabel4.Text      = "Payment 4: " + card.GetPayment(3) + "m";
     apartmentCostLabel.Text = "Improvement cost: " + card.ApartmentCost + "m";
     mortgageLabel.Text      = "Mortgage: " + card.MortgageValue + "m";
     DisplayCard(card, Color.WhiteSmoke, color);
 }
Пример #2
0
        /**
         * Called when gameButton1 was clicked, it analyses the game situation (using GameState attribute)
         * and then handles the click button accordingly.
         */
        private void Button1_action()
        {
            if (GameState == GameStage.NO_ACTION)
            {
                return;
            }

            window.Enabled = false;

            Card card = propertyManager
                        .CardAt(gameplan.PlayerPosition(currentPlayer));
            Player owner = propertyManager.WhoOwns(card);

            GameStage state = GameState;

            GameState = GameStage.NO_ACTION;

            switch (state)
            {
            case GameStage.DICE:
                window.HideButton();
                RollDice();
                break;

            case GameStage.AWAITING_PURCHASE:
                propertyManager.AddOwnership(card, currentPlayer);
                currentPlayer.Money -= card.Cost;
                break;

            case GameStage.AWAITING_RENT:
                float money = card.GetPayment();
                currentPlayer.Money -= money;
                owner.Money         += money;
                break;

            case GameStage.AWAITING_UPGRADE:
                PropertyCard c2 = (PropertyCard)card;
                window.DrawApartment(
                    gameplan.GetCoordsOfNextApartment(
                        gameplan.PlayerPosition(
                            currentPlayer), c2.Apartments));
                c2.AddApartment();
                currentPlayer.Money -= c2.ApartmentCost;
                break;

            case GameStage.NO_FUNDS_PAY:
                RemovePlayer();
                NextPlayer();
                break;

            case GameStage.WHAT_NEXT:
                window.ShowTradeOptions(propertyManager
                                        .GetTradeOptions(currentPlayer),
                                        currentPlayer);
                GameState = GameStage.TRADE_OFFER;
                break;

            case GameStage.TRADE_OFFER:
                MakeTradeOffer();
                break;

            case GameStage.TRADE_CONFIRM:
                propertyManager.ChangeOwner(currentPlayer,
                                            selectedItem, window.GetOfferedMoney());
                break;

            case GameStage.MORTGAGE_MENU:
                window.ShowMortgagedProperties(propertyManager.GetMortgagedProperties(currentPlayer, false), true);
                GameState = GameStage.MORTGAGE_TAKE;
                break;

            case GameStage.MORTGAGE_TAKE:
                TakeMortgage();
                break;

            case GameStage.MORTGAGE_PAY:
                PayMortgageOff();
                break;

            case GameStage.HOLIDAY:
                NextPlayer();
                break;

            default:
                Console.Write("An unexpected error occurred! " + GameState);
                break;
            }
            if (GameState == GameStage.NO_ACTION)
            {
                ShowWhatNext(currentPlayer);
            }
            window.Update();
            if (currentPlayer is AIPlayer)
            {
                AIDecider.PlayTurn((AIPlayer)currentPlayer, window, this, propertyManager
                                   .CardAt(gameplan.PlayerPosition(currentPlayer)));
            }
            window.Enabled = true;
        }