public ModelLevelSlow() { //The array that contains the map /* Map legenda: * f = finish * # = barricade * o = normal tile * r = red_player home base * g = green_player home base * y = yellow_player home base * b = blue player_home base */ map = new String[,] { // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 {" "," ", " ", " ", " ", " ", " ", " ", " ", "f", " ", " ", " ", " ", " ", " ", " ", " ", " "}, {" ","o", "o", "o", "o", "o", "o", "o", "o", "#", "o", "o", "o", "o", "o", "o", "o", "o", " "}, {" ","o", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "o", " "}, {" ","o", "o", "o", "o", "o", "o", "o", "o", "#", "o", "o", "o", "o", "o", "o", "o", "o", " "}, {" "," ", " ", " ", " ", " ", " ", " ", " ", "#", " ", " ", " ", " ", " ", " ", " ", " ", " "}, {" "," ", " ", " ", " ", " ", " ", "o", "o", "#", "o", "o", " ", " ", " ", " ", " ", " ", " "}, {" "," ", " ", " ", " ", " ", " ", "o", " ", " ", " ", "o", " ", " ", " ", " ", " ", " ", " "}, {" "," ", " ", " ", " ", "o", "o", "#", "o", "o", "o", "#", "o", "o", " ", " ", " ", " ", " "}, {" "," ", " ", " ", " ", "o", " ", " ", " ", " ", " ", " ", " ", "o", " ", " ", " ", " ", " "}, {" "," ", " ", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", "o", " ", " ", " "}, {" "," ", " ", "o", " ", " ", " ", "o", " ", " ", " ", "o", " ", " ", " ", "o", " ", " ", " "}, {" ","#", "o", "o", "o", "#", "o", "o", "o", "#", "o", "o", "o", "#", "o", "o", "o", "#", " "}, {" ","o", " ", " ", " ", "o", " ", " ", " ", "o", " ", " ", " ", "o", " ", " ", " ", "o", " "}, {" ","o", "o", "R", "o", "o", "o", "G", "o", "o", "o", "Y", "o", "o", "o", "B", "o", "o", " "}, /* No barricades - line 13 */ {" "," ", " ", "r", " ", " ", " ", "g", " ", " ", " ", "y", " ", " ", " ", "b", " ", " ", " "}, {" "," ", "r", "r", "r", " ", "g", "g", "g", " ", "y", "y", "y", " ", "b", "b", "b", " ", " "}, {" "," ", " ", "r", " ", " ", " ", "g", " ", " ", " ", "y", " ", " ", " ", "b", " ", " ", " "}, }; //Amount of pawns per player pawnAmount = 5; //Width of the map in cells iMapWidth = 19; //Height of the map in cells iMapHeight = 17; //Width of the map in px iWidth = iMapWidth * 32; //Height of the map in px iHeight = iMapHeight * 32; //Set the array of barricades and give it the right size ABarricades = new Model.BarricadePawn[11]; //Initialize the array witht he size of 1, there is just 1 row where barricades can not be added to aNoBarricades = new int[1]; //Set the value '13' (row no barricades) in the array aNoBarricades[0] = 13; fillViewArray(); }
//Move the selected barricade to a location. public Boolean moveBarricade(Model.Field field) { if (field.Pawn == null && field.Barricade == null && (field.GetType() == typeof(Model.Field) || field.GetType() == typeof(Model.Barricade))) { //If the row is in the array it can not contain a barricade if (!level.ANoBarricades.Contains(field.Y)) { barricade.setLocation(field); barricade = null; level.setCursor("arrow", field); nextPlayer(); return true; } } return false; }
//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; } } }