예제 #1
0
        //Method called when a player clicks on a field
        public void fieldClick(Model.Field field)
        {
            //If the dice is rolled
            if (dice.Gedobbeld)
            {
                //If the field does contain a Pawn and the Pawn belongs to the player
                if (field.Pawn != null &&
                    field.Pawn.PlayerNumber == PlayerTurn)
                {
                    //Select the Pawn and get it's possible moves
                    aPawnMovementOptions = field.Pawn.getPossibleMoves(dice.Worp).ToArray();
                    level.createBlurs(aPawnMovementOptions, field);
                    //Set the selected pawn
                    pawnSelected = field.Pawn;

                    level.setCursor(PlayerTurn.ToString(), field);
                }
                //Else if there is an Pawn selected and the field you click on is added to the possible moves
                else if (pawnSelected != null &&
                        aPawnMovementOptions.Contains(field))
                {
                    //If the possible move contains an enemy Pawn
                    if (field.Pawn != null &&
                        field.Pawn.PlayerNumber != playerTurn)
                    {
                        //Send enemy Pawn back to it's start location
                        field.Pawn.toStartLocation();
                    }
                    //Move the Pawn to it's new location
                    levelModel.Fields[pawnSelected.CurrentLocation.X, pawnSelected.CurrentLocation.Y].Pawn.setLocation(field);
                    //Change back the cursor to an arrow
                    level.setCursor("arrow", field);

                    //If the target field contains a barricade
                    if (field.Barricade != null)
                    {
                        //Remember the barricade and do not end the players turn
                        barricade = field.Barricade;

                        level.setCursor("barricade", field);
                    }
                    //Else if the target field is a finish
                    else if (field is Model.Finish)
                    {
                        //The game has been won.
                        winGame();
                    }
                    //Else the turn is over
                    else
                    {
                        //Give the turn to the next player
                        nextPlayer();
                    }
                    //Remove the possible moves- and selected pawn blurs
                    level.removeBlurs();
                    //Empty the selected pawn
                    pawnSelected = null;
                }
            }
        }
예제 #2
0
 //Create new pawns for each player.
 public void createPawn(Model.Field field, Ellipse image, int i)
 {
     Pawn pawn = new Pawn(image, field, i);
     aPlayers[i].addPawn(pawn);
 }
예제 #3
0
 //Add a new pawn to this player.
 public void addPawn(Pawn pawn)
 {
     aPawns[iArrayAmount] = pawn;
     iArrayAmount++;
 }