コード例 #1
0
        /// <summary>
        /// Metoda kojom pripremimo sljedecu rundu za igru.
        /// </summary>
        private void SetNextRound()
        {
            btnDeal.Enabled = false;                        //moramo onemoguciti pokretanje nove runde jer je jedna vec pokrenuta
            user.Active     = false;                        //korisnik jos ne igra na pocetku runde
            player2.Active  = false; dealer.Active = false; //na pocetku runde igra player1,ostali nisu aktivni
            OnemoguciKontrole();                            //korisniku onemogucimo kontrole
            //postavimo svim osobama koordinate pocetne pozicije njihove prve karte
            user.SetNewCard(520, 373);
            player1.SetNewCard(815, 330); player2.SetNewCard(215, 242); dealer.SetNewCard(512, 42);

            //uvjet za ponovno mjesanje spila karata.
            if (deck.CardsNumber / (52 * BlackjackGame.BrojSpilova) < 0.3)
            {
                deck = new Deck(BlackjackGame.BrojSpilova);//postavimo novi spil za igru,koji se promjesa
            }

            //postavimo pocetne ruke,po redu kako sjede u igri
            //za prvog igraca
            player1.AddNewCard(new Card(deck.ReturnCard().ID));
            player1.AddNewCard(new Card(deck.ReturnCard().ID));

            //za igraca korisnika
            user.AddNewCard(new Card(deck.ReturnCard().ID));
            user.AddNewCard(new Card(deck.ReturnCard().ID));

            //za drugog igraca
            player2.AddNewCard(new Card(deck.ReturnCard().ID));
            player2.AddNewCard(new Card(deck.ReturnCard().ID));

            //za djelitelja,dodamo samo jednu kartu po pravilima
            dealer.AddNewCard(new Card(deck.ReturnCard().ID));
            Sprite poledjina = new Sprite("sprites\\blue_back.png", dealer.LastCard_X, dealer.LastCard_Y, 65, 100, "card");

            Game.AddSprite(poledjina);

            lblDealerScore.Visible = true; lblUserScore.Visible = true;
            lblDealerScore.Text    = dealer.HandValue.ToString();
            lblUserScore.Text      = user.HandValue.ToString();

            //postavimo da je trenutni igrac player1
            //BlackjackGame.TrenutniIgrac = TrenutniIgrac.Player1; VRATITI PO POTREBI
            player1.Active       = true;
            lblActivePlayer.Text = "Active player: player 1";
        }
コード例 #2
0
ファイル: BGL.cs プロジェクト: sawyervaray/Blackjack
        private void SetNextRound()
        {
            btnDeal.Enabled = false;
            user.Active     = false;
            player2.Active  = false; dealer.Active = false;
            OnemoguciKontrole();

            user.SetNewCard(520, 373);
            player1.SetNewCard(815, 330); player2.SetNewCard(215, 242); dealer.SetNewCard(512, 42);


            if (deck.CardsNumber / (52 * BlackjackGame.BrojSpilova) < 0.3)
            {
                deck = new Deck(BlackjackGame.BrojSpilova);
            }


            player1.AddNewCard(new Card(deck.ReturnCard().ID));
            player1.AddNewCard(new Card(deck.ReturnCard().ID));


            user.AddNewCard(new Card(deck.ReturnCard().ID));
            user.AddNewCard(new Card(deck.ReturnCard().ID));


            player2.AddNewCard(new Card(deck.ReturnCard().ID));
            player2.AddNewCard(new Card(deck.ReturnCard().ID));


            dealer.AddNewCard(new Card(deck.ReturnCard().ID));
            Sprite poledjina = new Sprite("sprites\\blue_back.png", dealer.LastCard_X, dealer.LastCard_Y, 65, 100, "card");

            Game.AddSprite(poledjina);

            lblDealerScore.Visible = true; lblUserScore.Visible = true;
            lblDealerScore.Text    = dealer.HandValue.ToString();
            lblUserScore.Text      = user.HandValue.ToString();


            player1.Active       = true;
            lblActivePlayer.Text = "Active player: player 1";
        }