Пример #1
0
        /// <summary>
        /// This method refers to the Player class method called
        /// 'AddSettlementToSettlementListOfPlayer(Settlement,int,int,Player)'
        /// This AddSettlementToSettlementListOfPlayer method does what it
        /// suggests: it adds a settlement to the player's list of settlements.
        ///
        /// </summary>
        /// <param name="squareTileManagement">the object pertaining to the </param>
        /// <param name="tileHelper"></param>
        /// <param name="isTurnOfPlayerOne"></param>
        public void EstablishSettlementAndWhatNot(SquareTile squareTileManagement, TileHelper tileHelper, bool isTurnOfPlayerOne)
        {
            if (playerObj.HasToEstablishASettlementThisTurn)
            {
                //this if-statement prevents the player from placing a settlement
                //on another settlement, water or a mountain.
                if (squareTileManagement.selectedTileStruct.tile != TileType.Settlement &&
                    squareTileManagement.selectedTileStruct.tile != TileType.SettlementBlue &&
                    squareTileManagement.selectedTileStruct.tile != TileType.SettlementRed &&
                    squareTileManagement.selectedTileStruct.tile != TileType.Water &&
                    squareTileManagement.selectedTileStruct.tile != TileType.Mountain)
                {
                    //aesthetically makes the tile into a settlement
                    squareTileManagement.MakeTileIntoSettlement(tileHelper, isTurnOfPlayerOne);
                    //debug statement
                    Console.WriteLine("making tile into a settlement");

                    //Indicates that the player no longer has to set
                    //up a settlement
                    playerObj.HasToEstablishASettlementThisTurn = false;
                    //Adds the settlement to the list
                    playerObj.AddSettlementToSettlementListOfPlayer(new Settlement("",
                                                                                   squareTileManagement.selectedTileStruct.x,
                                                                                   squareTileManagement.selectedTileStruct.y, playerObj));
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Changes the tile into either a SettlementRed or a
 /// SettlementBlue.
 /// </summary>
 /// <param name="tileHelper"></param>
 /// <param name="isTurnOfPlayerOne"></param>
 public void MakeTileIntoSettlement(TileHelper tileHelper, bool isTurnOfPlayerOne)
 {
     if (isTurnOfPlayerOne)
     {
         tileHelper.ChangeTile(TileType.SettlementBlue, selectedTileStruct.x, selectedTileStruct.y);
     }
     else
     {
         tileHelper.ChangeTile(TileType.SettlementRed, selectedTileStruct.x, selectedTileStruct.y);
     }
 }
Пример #3
0
 /// <summary>
 /// This method refers to the Player class method called
 /// 'AddSettlementToSettlementListOfPlayer(Settlement,int,int,Player)'
 /// This AddSettlementToSettlementListOfPlayer method does what it
 /// suggests: it adds a settlement to the player's list of settlements.
 ///
 /// It also refers to the square tile management method called 'MakeTileIntoSettlement'
 /// which aesthetically transforms a given tile into a settlement tile
 ///
 /// @@@@This version of EstablishSettlementAndWhatNot is not actually used.@@@@
 /// The overloaded one is (which is down below)
 ///
 /// </summary>
 /// <param name="squareTileManagement"></param>
 /// <param name="tileHelper"></param>
 public void EstablishSettlementAndWhatNot(SquareTile squareTileManagement, TileHelper tileHelper)
 {
     // Checks if the player has a settlement they can place.
     if (playerObj.HasToEstablishASettlementThisTurn)
     {
         // Checks if the selected tile is a valid placement spot.
         if (squareTileManagement.selectedTileStruct.tile != TileType.Settlement &&
             squareTileManagement.selectedTileStruct.tile != TileType.Water &&
             squareTileManagement.selectedTileStruct.tile != TileType.Mountain)
         {
             squareTileManagement.MakeTileIntoSettlement(tileHelper);
             Console.WriteLine("making tile into a settlement");
             playerObj.HasToEstablishASettlementThisTurn = false;
             playerObj.AddSettlementToSettlementListOfPlayer(new Settlement("",
                                                                            squareTileManagement.selectedTileStruct.x,
                                                                            squareTileManagement.selectedTileStruct.y, playerObj));
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Translates the x and y coordinate on the gamemap into the actual
        /// tile
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public void PointToTile(float x, float y, TileHelper tileHelper)
        {
            //float width = height;//weird huh?
            //col = (int)(x / width);
            //if (col % 2 == 0)
            //    row = (int)(y / height);
            //else
            //    row = (int)((y - height / 2) / height);

            ////Find the test area
            //float testx = col * width;
            //float testy = row * height;
            //if (col % 2 == 1) testy += height / 2;


            this.selectedTileStruct.x    = (int)(x / this.height);
            this.selectedTileStruct.y    = (int)(y / this.height);
            this.selectedTileStruct.tile = tileHelper.GetTile(this.selectedTileStruct.x, this.selectedTileStruct.y);
        }
Пример #5
0
        public void SetAdjacentTiles(Player playerObj)
        {
            //Create a two dimensional array of 3 and 3
            this.adjacentTiles = new TileType[3, 3];


            //Cycle through the array
            for (int i = this.coordinates.x - 1; i < this.coordinates.x + 1; i++)
            {
                for (int j = this.coordinates.y + 1; j < this.coordinates.y - 1; j++)
                {
                    if (i > -1 && i < 29 && j > -1 && j < 39)
                    {
                        //The current adjacent tile is equal to the one from the map
                        //in the same location
                        adjacentTiles[i, j] = new TileHelper().GetTile(i, j);

                        // Increments the appropriate resources by the appropriate amounts based off
                        // what type of tile the current index of the TileHelper 'adjacentTiles' is
                        // equivalent to.
                        switch (adjacentTiles[i, j])
                        {
                        case TileType.Grass:
                            playerObj.Resources[0] += 3;    //3 food yield
                            break;

                        case TileType.Forest:
                            playerObj.Resources[0] += 1;    //3 food yield
                            playerObj.Resources[1] += 3;
                            break;

                        case TileType.Desert:
                            playerObj.Resources[5] += 1;
                            playerObj.Resources[9] += 2;
                            break;

                        case TileType.Hill:
                            playerObj.Resources[0] += 1;    //3 food yield
                            playerObj.Resources[3] += 2;
                            playerObj.Resources[6] += 2;
                            playerObj.Resources[8] += 1;
                            break;

                        case TileType.Mountain:
                            //random luxury resource gained from a mountain

                            Random rnd    = new Random();
                            byte   result = (byte)rnd.Next(1, 4);
                            switch (result)
                            {
                            case 1:
                                playerObj.Resources[7] += 2;
                                break;

                            case 2:
                                playerObj.Resources[2] += 2;
                                break;

                            case 3:
                                playerObj.Resources[4] += 3;
                                break;

                            case 4:
                                playerObj.Resources[6] += 4;
                                break;
                            }
                            break;

                        case TileType.Swamp:
                            playerObj.Resources[0] += 1;
                            playerObj.Resources[1] += 1;
                            break;

                        case TileType.Water:
                            playerObj.Resources[0] += 2;
                            playerObj.Resources[5] += 3;
                            playerObj.Resources[2] += 1;
                            break;
                        }
                    }
                }
            }

            //Set the yields
        }
Пример #6
0
 /// <summary>
 /// Changes the tile into a Settlement (TileType.Settlement)
 /// </summary>
 /// <param name="tileHelper"></param>
 public void MakeTileIntoSettlement(TileHelper tileHelper)
 {
     tileHelper.ChangeTile(TileType.Settlement, selectedTileStruct.x, selectedTileStruct.y);
 }