Пример #1
0
        /// <summary>
        /// Moves the player's location through the tile list and calls PassGo's location action if it was passed mid-move
        /// </summary>
        /// <param name="player">Current player</param>
        public void Move(Player player, int differentLocation = -1)
        {
            int newLocation;

            // For using the Move method with the chance cards
            // When differentLocation is not specified, add the rolled dice to the player's location
            if (differentLocation == -1)
            {
                newLocation = player.Location + RolledDice[0] + RolledDice[1];
            } // If the differentLocation is previously determined, set newLocation
            else
            {
                newLocation = differentLocation;
            }
            // // if the player passes go and is not in jail
            if (newLocation < player.Location && newLocation != 10)
            {
                if (GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(CardSpace))
                {
                    CardSpace cardTile = (CardSpace)GameLoop.getInstance().Gameboard.TileOrder[player.Location];
                    // if the card tile calls for going back 3 spaces and is not the first community chest card at location 2
                    if (cardTile.ProcessedCard[0, 3] == "Location" && GameLoop.getInstance().Gameboard.TileOrder[player.Location] != GameLoop.getInstance().Gameboard.TileOrder[2])
                    {
                        // don't collect go
                    }
                    else
                    {
                        // If player passed Go, collect $200
                        TileOrder[0].LocationAction(player);
                    }
                }
            }
            player.Location = newLocation;
        }
Пример #2
0
        /// <summary>
        /// Performs the action for the player's new location based on what type of tile it is.
        /// </summary>
        /// <param name="player">Current Player</param>
        private void LocationResponse(Player player)
        {
            // if the player lands on a propertym display pay rent or purchase property form
            if (GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(Basic) ||
                GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(Utility) ||
                GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(Railroad))
            {
                Property property = (Property)GameLoop.getInstance().Gameboard.TileOrder[player.Location];
                DisplayPayRentOrPurchasePropertyForm(player, property);

                DisplayCurrentPlayerProperties(player);      // GUI
            } // when a player lands on a community chest spot or chance spot
            else if (GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(CardSpace))
            {
                // Get the cardSpace and display the community or chance form
                CardSpace cardTile = (CardSpace)GameLoop.getInstance().Gameboard.TileOrder[player.Location];
                DisplayCommunityOrChanceForm(player, cardTile);
                // if the community or chance card calls for the player to advance to a property, display pay rent or purchase property form
                if (cardTile.ProcessedCard[0, 1] == "Advance" && (GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(Basic) ||
                                                                  GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(Utility) ||
                                                                  GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(Railroad)))
                {
                    DisplayCurrentPlayerMoney(player);
                    DisplayPayRentOrPurchasePropertyForm(player, (Property)GameLoop.getInstance().Gameboard.TileOrder[player.Location]);
                } // if the community or chance card calls for the player to advance to a card space, display community or chance card form
                else if (cardTile.ProcessedCard[0, 1] == "Advance" && (GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(CardSpace)))
                {
                    DisplayCurrentPlayerMoney(player);
                    DisplayCommunityOrChanceForm(player, (CardSpace)GameLoop.getInstance().Gameboard.TileOrder[player.Location]);
                } // if the community or chance card calls for the player to advance to the go to jail space, send the player to jail
                else if (cardTile.ProcessedCard[0, 1] == "Advance" && (GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(GoToJail)))
                {
                    GoToJail goToJailTile = (GoToJail)GameLoop.getInstance().Gameboard.TileOrder[player.Location];
                    goToJailTile.LocationAction(player);
                } // if the community or chance card calls for the player to advance to the go to Income Tax, decrease the player's money by 10% (if more) or pay $200
                else if (cardTile.ProcessedCard[0, 1] == "Advance" && (GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(FreeParking)))
                {
                    FreeParking freeParking = (FreeParking)GameLoop.getInstance().Gameboard.TileOrder[player.Location];
                    PayTaxForm(player, freeParking);
                }
            } // if Luxury Tax or Income Tax, display tax form
            else if (GameLoop.getInstance().Gameboard.TileOrder[player.Location].GetType() == typeof(FreeParking))
            {
                FreeParking freeParking = (FreeParking)GameLoop.getInstance().Gameboard.TileOrder[player.Location];
                if (freeParking.Name == "Income Tax" || freeParking.Name == "Luxury Tax")
                {
                    PayTaxForm(player, freeParking);
                }
            }
            // if not a property or community chest or chance card, call location action on that tile
            else
            {
                GameLoop.getInstance().Gameboard.TileOrder[player.Location].LocationAction(player);
            }
            DisplayCurrentPlayerMoney(player);      // GUI
            DisplayCurrentPlayerLocation(player);
            DisplayCurrentPlayerProperties(player);
            UpdateBoard(player);
        }
Пример #3
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            // Get the current player, player location, and CardSpace that the player landed on
            Player    currentPlayer         = GameLoop.getInstance().Gameboard.Players[GameLoop.getInstance().Gameboard.CurrentPlayerIndex];
            int       playerCurrentLocation = currentPlayer.Location;
            CardSpace cardTile = (CardSpace)GameLoop.getInstance().Gameboard.TileOrder[playerCurrentLocation];

            // Carry out the specifications of the picked card
            cardTile.LocationAction(currentPlayer);
            this.Close();
        }
Пример #4
0
        /// <summary>
        /// Displays the community chest form or the chance form
        /// </summary>
        /// <param name="player">the current player</param>
        /// <param name="cardTile">the CardSpace tile that the current player landed on</param>
        private void DisplayCommunityOrChanceForm(Player player, CardSpace cardTile)
        {
            List <Card> cardsList = new List <Card>();

            // if land on a community chest card space, set the list of community chest cards  and the processing array to a local variable
            if (player.Location == 2 || player.Location == 17 || player.Location == 33)
            {
                cardsList = GameLoop.getInstance().Gameboard.CommunityChestCards;
                cardTile.CardsForProcessing = new string[GameLoop.getInstance().Gameboard.CommunityChestCardsForProcessing.GetLength(0),
                                                         GameLoop.getInstance().Gameboard.CommunityChestCardsForProcessing.GetLength(1)];
                cardTile.CardsForProcessing = GameLoop.getInstance().Gameboard.CommunityChestCardsForProcessing;
            } // if land on a chance card space, set the list of chance cards and the processing array to local variables
            else if (player.Location == 7 || player.Location == 22 || player.Location == 36)
            {
                cardsList = GameLoop.getInstance().Gameboard.ChanceCards;
                cardTile.CardsForProcessing = new string[GameLoop.getInstance().Gameboard.ChanceCardsForProcessing.GetLength(0),
                                                         GameLoop.getInstance().Gameboard.ChanceCardsForProcessing.GetLength(1)];
                cardTile.CardsForProcessing = GameLoop.getInstance().Gameboard.ChanceCardsForProcessing;
            }

            // pick a random proccessed card
            int randomNum = GameLoop.getInstance().Gameboard.Rand.Next(cardTile.CardsForProcessing.GetLength(0));

            for (int j = 0; j < cardTile.ProcessedCard.GetLength(1); j++)
            {
                cardTile.ProcessedCard[0, j] = cardTile.CardsForProcessing[randomNum, j];
            }

            // if a Community Chest, card display the form
            if (cardTile.Name.Contains("Community Chest"))
            {
                CommunityChestCard communityChestCard = new CommunityChestCard();
                communityChestCard.Owner = this;
                communityChestCard.tbOutputCommunityChest.Text = cardTile.ProcessedCard[0, 0];
                communityChestCard.ShowDialog();
            } // if a Chance card, display the form
            else if (cardTile.Name.Contains("Chance"))
            {
                ChanceCard chanceCard = new ChanceCard();
                chanceCard.Owner = this;
                // Display the card's description
                chanceCard.tbOutputChance.Text = cardTile.ProcessedCard[0, 0];
                chanceCard.ShowDialog();
            }
        }
Пример #5
0
        /// <summary>
        /// Initializes all the tiles in the game and stores them in order.
        /// </summary>
        private void InitializeTileOrder()
        {
            _TileOrder = new Tile[40];

            _TileOrder[0]  = new PassGo();
            _TileOrder[1]  = new Basic("Mediterranean Avenue", 60, 2);
            _TileOrder[2]  = new CardSpace("Community Chest");
            _TileOrder[3]  = new Basic("Baltic Avenue", 80, 4);
            _TileOrder[4]  = new FreeParking("Income Tax"); //IncomeTax
            _TileOrder[5]  = new Railroad("Reading Railroad", 200, 25);
            _TileOrder[6]  = new Basic("Oriental Avenue", 100, 6);
            _TileOrder[7]  = new CardSpace("Chance");
            _TileOrder[8]  = new Basic("Vermont Avenue", 100, 6);
            _TileOrder[9]  = new Basic("Connecticut Avenue", 120, 8);
            _TileOrder[10] = new Jail();
            _TileOrder[11] = new Basic("St. Charles Place", 140, 10);
            _TileOrder[12] = new Utility("Electric Company", 150, 1);
            _TileOrder[13] = new Basic("States Avenue", 140, 10);
            _TileOrder[14] = new Basic("Virginia Avenue", 160, 12);
            _TileOrder[15] = new Railroad("Pennsylvania Railroad", 200, 25);
            _TileOrder[16] = new Basic("St. James Place", 180, 14);
            _TileOrder[17] = new CardSpace("Community Chest");
            _TileOrder[18] = new Basic("Tennessee Avenue", 180, 14);
            _TileOrder[19] = new Basic("New York Avenue", 200, 16);
            _TileOrder[20] = new FreeParking();
            _TileOrder[21] = new Basic("Kentucky Avenue", 220, 18);
            _TileOrder[22] = new CardSpace("Chance");
            _TileOrder[23] = new Basic("Indiana Avenue", 220, 18);
            _TileOrder[24] = new Basic("Illinois Avenue", 240, 20);
            _TileOrder[25] = new Railroad("B & O Railroad", 200, 25);
            _TileOrder[26] = new Basic("Atlantic Avenue", 260, 22);
            _TileOrder[27] = new Basic("Ventnor Avenue", 260, 22);
            _TileOrder[28] = new Utility("Water Works", 150, 1);
            _TileOrder[29] = new Basic("Marvin Gardens", 280, 24);
            _TileOrder[30] = new GoToJail();
            _TileOrder[31] = new Basic("Pacific Avenue", 300, 26);
            _TileOrder[32] = new Basic("North Carolina Avenue", 300, 26);
            _TileOrder[33] = new CardSpace("Community Chest");
            _TileOrder[34] = new Basic("Pennsylvania Avenue", 320, 28);
            _TileOrder[35] = new Railroad("Short Line Railroad", 200, 25);
            _TileOrder[36] = new CardSpace("Chance");
            _TileOrder[37] = new Basic("Park Place", 350, 35);
            _TileOrder[38] = new FreeParking("Luxury Tax");   //LuxuryTax
            _TileOrder[39] = new Basic("Boardwalk", 400, 50);
        }