示例#1
0
        /**
         * Called when gameButton2 was clicked, it analyses the game situation (using GameState attribute)
         * and then handles the click button accordingly.
         */
        private void Button2_action()
        {
            if (GameState == GameStage.NO_ACTION)
            {
                return;
            }

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

            GameStage state = GameState;

            GameState = GameStage.NO_ACTION;

            switch (state)
            {
            case GameStage.DICE:
                SaveButton_action();
                GameState = GameStage.DICE;
                break;

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

            case GameStage.WHAT_NEXT:
                window.ShowMortgageMenu();
                GameState = GameStage.MORTGAGE_MENU;
                break;

            case GameStage.TRADE_CONFIRM:
                window.ShowPlayerInfo(currentPlayer);
                window.ShowMessage("Your offer was declined!");
                Thread.Sleep(2000);
                break;

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

            default:
                break;
            }
            if (GameState == GameStage.NO_ACTION)
            {
                ShowWhatNext(currentPlayer);
            }

            if (currentPlayer is AIPlayer)
            {
                AIDecider.PlayTurn((AIPlayer)currentPlayer, window, this, propertyManager
                                   .CardAt(gameplan.PlayerPosition(currentPlayer)));
            }
        }