Exemplo n.º 1
0
        /// <summary>
        /// Crete and show a new sorted players view, for the end of a game
        /// </summary>
        /// <param name="game"></param>
        public static void NewSortedPlayersView(Game game)
        {
            // Create a new form, then show it
            SortedPlayersView view = new SortedPlayersView(game);
            view.Show();

            // Count this new window
            windowCount++;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new game window
        /// </summary>
        /// <param name="players"></param>
        /// <param name="options"></param>
        public static GameController NewGame(List<Player> players, GameOptions options)
        {
            // Create a new game, with the players and options
            Game game = new Game(players, options);

            // Give the game to a new controller, which will set up the form and other things
            GameController controller = new GameController(game);

            // Count the window
            windowCount++;

            return controller;
        }
Exemplo n.º 3
0
        public SortedPlayersView(Game theGame)
        {
            InitializeComponent();

            // Save the parameter for later
            game = theGame;

            sortedPlayerViews.Add(sortedPlayerView1);
            sortedPlayerViews.Add(sortedPlayerView2);
            sortedPlayerViews.Add(sortedPlayerView3);
            sortedPlayerViews.Add(sortedPlayerView4);

            // Sort the players
            sortPlayersByScore();

            // Setup the sorted player views
            for (int i = 0; i < Game.MAXPLAYERS; i++)
            {
                // Check if the player exists
                if (i < game.NumberOfPlayers)
                {
                    // Set the info so the view can display the player's properties
                    sortedPlayerViews[i].SetInfo(game.Players[i], game);

                }
                else
                {
                    // If the player doesn't exist, hide its view
                    sortedPlayerViews[i].Visible = false;
                }
            }

            // Handle the form closing event
            FormClosed += new FormClosedEventHandler(SortedPlayersView_FormClosed);

            // Set the height of the form to only what's needed
            Height = game.NumberOfPlayers * 94 + 145;

            // Set the background image
            BackgroundImage = Properties.Resources.CardTable;

            // Set the scoring method label
            scoringMethodLabel.Text = ( game.Options.ScoringSystem == GameOptions.ScoringSystems.Basic ? "Simple Scoring" : "Card Value Scoring" );
        }
Exemplo n.º 4
0
        public GameView(Game newGame, GameController gameController)
        {
            InitializeComponent();

            toolTip = new ToolTip();

            // Must redefine the background image to make the optimizing code work properly
            BackgroundImage = Properties.Resources.GameView;

            // Save the parameters
            game = newGame;
            controller = gameController;

            // Create picture boxes for each card, and store them in a hash table
            foreach (Card c in game.Deck)
                cardsViews.Add(c, createPictureBoxForCard(c));

            // Add controls to their arrays

            playerLabels.Add(player1Label);
            playerLabels.Add(player2Label);
            playerLabels.Add(player3Label);
            playerLabels.Add(player4Label);

            playerComputerBadges.Add(player1ComputerBadge);
            playerComputerBadges.Add(player2ComputerBadge);
            playerComputerBadges.Add(player3ComputerBadge);
            playerComputerBadges.Add(player4ComputerBadge);

            // Set player name and type labels
            for (int i = 0; i < 4; i++)
            {
                if (i < game.Players.Count)
                {
                    playerLabels[i].Text = game.Players[i].Name;
                    playerComputerBadges[i].Image = Player.PlayerTypeBadge(game.Players[i].Type);
                }

                else
                {
                    playerLabels[i].Visible = false;
                    playerComputerBadges[i].Visible = false;
                }
            }

            // Set the game info message
            gameInfoMessage.Text = GameOptions.ScoringSystemToString(game.Options.ScoringSystem) + (game.Options.StopPlayingAfterFirst ? ",\r\nStopping after winner" : "");

            // Handle the form closing event
            FormClosing += new FormClosingEventHandler(GameView_FormClosing);

            // Set up the end game highlight flashing timer
            endGameHighlightTimer.Interval = 500;
            endGameHighlightTimer.Tick += new EventHandler(endGameHighlightTimer_Tick);

            // Check if there's too many cards
            tooManyCards = game.NumberOfPlayers * game.Options.CardsForEachPlayer > 50;

            #if DEBUG
                debugControls.Visible = true;
            #endif
        }
Exemplo n.º 5
0
        public void SetInfo(Player thePlayer, Game theGame)
        {
            game = theGame;
            player = thePlayer;
            gamePlayer = game.PlayersCards[player] as Game.GamePlayer;

            // Don't show the score label if basic scoring is used
            if (game.Options.ScoringSystem == GameOptions.ScoringSystems.Basic)
                scoreLabel.Visible = false;

            nameLabel.Text = player.Name;
            scoreLabel.Text = "Score: " + player.Score;

            //typeLabel.Text = Player.PlayerTypeToString(player.Type);
            typeBadge.Image = Player.PlayerTypeBadge(player.Type);

            turnsLabel.Text = gamePlayer.NumberOfTurns.ToString();
            cardsPickedUpLabel.Text = gamePlayer.NumberOfCardsPickedUp.ToString();
            cardsPlayedLabel.Text = gamePlayer.NumberOfCardsPlayed.ToString();

            ordinalLabel.Text = GetOrdinalStringForInt(player.Rank + 1);
        }