Ejemplo n.º 1
1
 public Game(Random random)
 {
     this.dice = new Dice(random);
     this.players = new Player[NUMBER_OF_PLAYERS];
     this.table = new Table();
     this.playerIndex = 0;
     this.currentPlayerIndex = 0;
     this.palpitating = new Player[3];
     this.palpitatingIndex = 0;
     this.round = 1;
 }
Ejemplo n.º 2
0
        void Roll_Dice(object sender, RoutedEventArgs e)
        {
            if (start) {
                //Player must choose piece or nest first
                if (choosen == false)
                {
                    BitmapImage choosePiece = new BitmapImage(new Uri("/images/choose.png", UriKind.Relative));
                    bubble.Source = choosePiece;

                }
                else
                {

                    Button b = e.Source as Button;
                    Dice newDice = new Dice();
                    int number = newDice.roll_dice();
                    BitmapImage Img = new BitmapImage(new Uri("/images/bubble" + number.ToString() + ".png", UriKind.Relative));
                    bubble.Source = Img;
                    BitmapImage theDice = new BitmapImage(new Uri("/images/dice" + number.ToString() + ".jpg", UriKind.Relative));
                    dice.Source = theDice;

                   // Console.WriteLine("Värde x: " + Pieces[2].X + " värde y: " + Pieces[2].Y);
                    Pieces = pieces;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// When the "roll dice" button has been clicked - communicate with rule engine
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void RollDiceAndHandleEvents(object sender, RoutedEventArgs e)
        {
            if (hasGameStarted)
            {
                // Force player to choose the right piece
                if (!hasChosenPiece)
                {
                    chooseTalkingBubble("/images/choosepieceid.png");
                }
                else if (hasChosenPiece && (ChosenPieceColor != gameEvent.Player))
                {
                    chooseTalkingBubble("/images/chooserightpieceid.png");
                }
                // Piece now chosen,try rolling the dice
                else
                {
                    Dice newDice = new Dice();
                    int diceRoll = newDice.rollDice();
                    showDice("/images/dice" + diceRoll.ToString() + ".jpg");

                    // Let the rule engine do its magic and update the game state, then update GUI
                    gameState = parseNewEvent(diceRoll);
                    changePieces(gameState);
                    showInstructions(diceRoll);

                    // Prepare next turn
                    resetInGameValues();
                    gameEvent.Player = switchTurn();
                    createTurnString(ref turn);
                    PlayerTurn = turn;
                }
            }
        }