public GameNode(int a, int b, int c, GameHex d, GameHex e, GameHex f, int g) : base(a, b, c) { this.hex1 = d; this.hex2 = e; this.hex3 = f; this.settleType = g; threePort = false; woodPort = false; brickPort = false; grainPort = false; orePort = false; woolPort = false; hasPort = false; }
//Purpose: Draw the hexes that make up the gameboard and the hexNumbers of each hex private void DrawBoard() { Texture2D texture; GameHex hexInfo = new GameHex(); //Draw Ocean Pieces for (int row = 0; row < 7; row++) { for (int col = 0; col < 15; col++) { if (row % 2 == 0 && col % 2 == 0 || (row % 2 == 1 && col % 2 == 1)) { hexMiddle.X = sea.Width / 2; hexMiddle.Y = sea.Height / 2; float positionWidth = halfWidth - (col - 7) * hexMiddle.X * hexScale; float positionHeight = halfHeight - (row - 3) * sea.Height * 0.75f * hexScale; Vector2 position = new Vector2(positionWidth, positionHeight); ourGame.SpriteBatch.Draw(sea, position, null, Color.White, 0f, hexMiddle, hexScale, SpriteEffects.None, 0f); } } } //Draw game hexes and hex numbers foreach (GameHex gh in ourGame.gameBoard.gameHexes) { hexInfo = ourGame.gameBoard.getHexInfo(gh); if (hexInfo.hexType != null) { switch (hexInfo.hexType) { case "Clay": { texture = brick; break; } case "Desert": { texture = desert; break; } case "Grain": { texture = grain; break; } case "Wood": { texture = lumber; break; } case "Rock": { texture = ore; break; } case "Sheep": { texture = wool; break; } case "Ocean": { texture = sea; break; } default: { texture = null; break; } } //X position of hex (middle) float positionWidth = halfWidth + (gh.column - 5) * hexMiddle.X * hexScale; //Y position of hex (middle) float positionHeight = halfHeight + (gh.row - 3) * texture.Height * 0.75f * hexScale; int hexNumber = hexInfo.hexNumber; Vector2 position = new Vector2(positionWidth, positionHeight); //Draw Hexes ourGame.SpriteBatch.Draw(texture, position, null, Color.White, 0f, hexMiddle, hexScale, SpriteEffects.None, 0f); //Set position of numbers (middle of hex minus half the width/height of the scaled number texture) Vector2 numPosition = new Vector2(positionWidth + (hexMiddle.X - two.Width / 2) * hexScale, positionHeight + (hexMiddle.Y - two.Height / 2) * hexScale); //Draw Numbers on Hexes if (hexNumber > 0) { ourGame.SpriteBatch.Draw(numbers[hexNumber - 2], numPosition, null, Color.White, 0f, hexMiddle, hexScale, SpriteEffects.None, 0f); } //Draw the Robber if (hexInfo.hasRobber) { //Set position of Robber Vector2 robberOrigin = new Vector2(robber.Width / 2, robber.Height / 2); Vector2 robberPosition = new Vector2(positionWidth - 30, positionHeight - 10); ourGame.SpriteBatch.Draw(robber, robberPosition, null, Color.White, 0f, robberOrigin, 0.6f, SpriteEffects.None, 0f); } } } }
//Purpose: Get the 6 GameNodes that surround GameHex gh // Pass this the robber's hex to get the nodes that surround the robber //Params: gh - the GameHex that we're requesting the nodes for //Return: A list of the 6 GameNodes that surround the GameHex gh public List<GameNode> nodesSurroundingHex(GameHex gh) { List<GameNode> gn = new List<GameNode>(); for (int x = 0; x < 12; x++) { for (int y = 0; y < 22; y++) { if (boardArray[x, y] is GameNode) { GameNode tmp = (GameNode)boardArray[x, y]; if ((tmp.hex1 == gh) || (tmp.hex2 == gh) || (tmp.hex3 == gh)) gn.Add(tmp); } } } return gn; }
//Not finished yet, right now it's set up more for automated taking //Need more information on wiring it up to the GUI. //But the logic is there public void moveRobber(GameHex moveHere, Player px) { //Move the robber setRobber(moveHere); //Get the 6 nodes surrounding it List<GameNode> buildingAround = nodesSurroundingHex(moveHere); bool keepGoing = true; Random rdm = new Random(); while (keepGoing) { int random = rdm.Next(0, 6); GameNode tmp = buildingAround[random]; if ((tmp.owner != 0) && (tmp.owner != px.playerNumber)) { //steal a random card from tmp.owner keepGoing = false; } } }
//Purpose: To return hex based upon the row and column given //Params: r - the row the hex is in, c - the column the hex is in //Return: Hexagon corresponding to the row and column given public GameHex getHexInfo(GameHex gh) { GameHex boardHex = new GameHex(); for (int j = 0; j < 20; j++) { if (gameHexes[j].row == gh.row && gameHexes[j].column == gh.column) { boardHex.hexType = gameHexes[j].hexType; boardHex.hexNumber = gameHexes[j].hexNumber; boardHex.hasRobber = gameHexes[j].hasRobber; return boardHex; } } return boardHex; }
//Get a list of players that have settlements around the hex provided public IEnumerable<Player> eligibleVictims(GameHex gh, SettlersOfCatan game, Player mover) { List<Player> playerList = new List<Player>(); List<GameNode> surroundSettles = nodesSurroundingHex(gh); foreach (GameNode gn in surroundSettles) { foreach (Player px in game.players) { if ((px.playerNumber == gn.owner) && (mover.playerNumber != px.playerNumber)) { playerList.Add(px); } } } IEnumerable<Player> players = playerList.Distinct(); return players; }
public GameBoard(string gameType) { switch (gameType) { case "BaseGame": { string[] boardNumbers = { "5", "2", "6", "3", "8", "10", "9", "12", "11", "4", "8", "10", "9", "4", "5", "6", "3", "11" }; string[] boardHexes = {"Desert", "Sheep", "Sheep","Sheep","Sheep", "Clay", "Clay", "Clay", "Rock", "Rock", "Rock", "Grain", "Grain", "Grain", "Grain","Wood", "Wood", "Wood", "Wood"}; Random rnd = new Random(); string[] randHex = boardHexes.OrderBy(x => rnd.Next()).ToArray(); string[,] finishedHexes = new String[19, 2]; int y = 0; for (int x = 0; x < 19; x++) { string Desert = "Desert"; finishedHexes[x, 0] = randHex[x]; if (string.ReferenceEquals(randHex[x], Desert)) { finishedHexes[x, 1] = "0"; } else { finishedHexes[x, 1] = boardNumbers[y]; y++; } } int[] ports = { 1, 2, 3, 4, 5, 0, 0, 0, 0 }; randPorts = ports.OrderBy(x => rnd.Next()).ToArray(); //Game Hexes (hexType, hexNumber, row, columns GameHex GH1 = new GameHex(finishedHexes[0, 0], int.Parse(finishedHexes[0, 1]), 1, 7); GameHex GH2 = new GameHex(finishedHexes[1, 0], int.Parse(finishedHexes[1, 1]), 1, 5); GameHex GH3 = new GameHex(finishedHexes[2, 0], int.Parse(finishedHexes[2, 1]), 1, 3); GameHex GH4 = new GameHex(finishedHexes[3, 0], int.Parse(finishedHexes[3, 1]), 2, 2); GameHex GH5 = new GameHex(finishedHexes[4, 0], int.Parse(finishedHexes[4, 1]), 3, 1); GameHex GH6 = new GameHex(finishedHexes[5, 0], int.Parse(finishedHexes[5, 1]), 4, 2); GameHex GH7 = new GameHex(finishedHexes[6, 0], int.Parse(finishedHexes[6, 1]), 5, 3); GameHex GH8 = new GameHex(finishedHexes[7, 0], int.Parse(finishedHexes[7, 1]), 5, 5); GameHex GH9 = new GameHex(finishedHexes[8, 0], int.Parse(finishedHexes[8, 1]), 5, 7); GameHex GH10 = new GameHex(finishedHexes[9, 0], int.Parse(finishedHexes[9, 1]), 4, 8); GameHex GH11 = new GameHex(finishedHexes[10, 0], int.Parse(finishedHexes[10, 1]), 3, 9); GameHex GH12 = new GameHex(finishedHexes[11, 0], int.Parse(finishedHexes[11, 1]), 2, 8); GameHex GH13 = new GameHex(finishedHexes[12, 0], int.Parse(finishedHexes[12, 1]), 2, 6); GameHex GH14 = new GameHex(finishedHexes[13, 0], int.Parse(finishedHexes[13, 1]), 2, 4); GameHex GH15 = new GameHex(finishedHexes[14, 0], int.Parse(finishedHexes[14, 1]), 3, 3); GameHex GH16 = new GameHex(finishedHexes[15, 0], int.Parse(finishedHexes[15, 1]), 4, 4); GameHex GH17 = new GameHex(finishedHexes[16, 0], int.Parse(finishedHexes[16, 1]), 4, 6); GameHex GH18 = new GameHex(finishedHexes[17, 0], int.Parse(finishedHexes[17, 1]), 3, 7); GameHex GH19 = new GameHex(finishedHexes[18, 0], int.Parse(finishedHexes[18, 1]), 3, 5); GameHex Ocean = new GameHex("Ocean", -1, -5, -5); gameHexes.Add(GH1); gameHexes.Add(GH2); gameHexes.Add(GH3); gameHexes.Add(GH4); gameHexes.Add(GH5); gameHexes.Add(GH6); gameHexes.Add(GH7); gameHexes.Add(GH8); gameHexes.Add(GH9); gameHexes.Add(GH10); gameHexes.Add(GH11); gameHexes.Add(GH12); gameHexes.Add(GH13); gameHexes.Add(GH14); gameHexes.Add(GH15); gameHexes.Add(GH16); gameHexes.Add(GH17); gameHexes.Add(GH18); gameHexes.Add(GH19); gameHexes.Add(Ocean); //Place the Robber on the Desert initializeRobber(); //Game Nodes (locx, locy, player, hex1, hex2, hex4, settleType) GameNode A5 = new GameNode(1, 5, 0, Ocean, Ocean, GH1, 0); GameNode A7 = new GameNode(1, 7, 0, Ocean, Ocean, GH1, 0); GameNode A9 = new GameNode(1, 9, 0, GH1, Ocean, GH2, 0); GameNode A11 = new GameNode(1, 11, 0, Ocean, Ocean, GH2, 0); GameNode A13 = new GameNode(1, 13, 0, GH2, Ocean, GH3, 0); GameNode A15 = new GameNode(1, 15, 0, Ocean, Ocean, GH3, 0); GameNode A17 = new GameNode(1, 17, 0, GH3, Ocean, Ocean, 0); GameNode C3 = new GameNode(3, 3, 0, Ocean, Ocean, GH12, 0); GameNode C5 = new GameNode(3, 5, 0, Ocean, GH1, GH12, 0); GameNode C7 = new GameNode(3, 7, 0, GH12, GH1, GH13, 0); GameNode C9 = new GameNode(3, 9, 0, GH1, GH2, GH13, 0); GameNode C11 = new GameNode(3, 11, 0, GH13, GH2, GH14, 0); GameNode C13 = new GameNode(3, 13, 0, GH2, GH3, GH14, 0); GameNode C15 = new GameNode(3, 15, 0, GH14, GH3, GH4, 0); GameNode C17 = new GameNode(3, 17, 0, GH3, Ocean, GH4, 0); GameNode C19 = new GameNode(3, 19, 0, GH4, Ocean, Ocean, 0); GameNode E1 = new GameNode(5, 1, 0, Ocean, Ocean, GH11, 0); GameNode E3 = new GameNode(5, 3, 0, Ocean, GH12, GH11, 0); GameNode E5 = new GameNode(5, 5, 0, GH11, GH12, GH18, 0); GameNode E7 = new GameNode(5, 7, 0, GH12, GH13, GH18, 0); GameNode E9 = new GameNode(5, 9, 0, GH18, GH13, GH19, 0); GameNode E11 = new GameNode(5, 11, 0, GH13, GH14, GH19, 0); GameNode E13 = new GameNode(5, 13, 0, GH19, GH14, GH15, 0); GameNode E15 = new GameNode(5, 15, 0, GH14, GH4, GH15, 0); GameNode E17 = new GameNode(5, 17, 0, GH15, GH4, GH5, 0); GameNode E19 = new GameNode(5, 19, 0, GH4, Ocean, GH5, 0); GameNode E21 = new GameNode(5, 21, 0, GH5, Ocean, Ocean, 0); GameNode G1 = new GameNode(7, 1, 0, Ocean, GH11, Ocean, 0); GameNode G3 = new GameNode(7, 3, 0, Ocean, GH11, GH10, 0); GameNode G5 = new GameNode(7, 5, 0, GH11, GH18, GH10, 0); GameNode G7 = new GameNode(7, 7, 0, GH10, GH18, GH17, 0); GameNode G9 = new GameNode(7, 9, 0, GH18, GH19, GH17, 0); GameNode G11 = new GameNode(7, 11, 0, GH17, GH19, GH16, 0); GameNode G13 = new GameNode(7, 13, 0, GH19, GH15, GH16, 0); GameNode G15 = new GameNode(7, 15, 0, GH16, GH15, GH6, 0); GameNode G17 = new GameNode(7, 17, 0, GH15, GH5, GH6, 0); GameNode G19 = new GameNode(7, 19, 0, GH6, GH5, Ocean, 0); GameNode G21 = new GameNode(7, 21, 0, GH5, Ocean, Ocean, 0); GameNode I3 = new GameNode(9, 3, 0, Ocean, GH10, Ocean, 0); GameNode I5 = new GameNode(9, 5, 0, Ocean, GH10, GH9, 0); GameNode I7 = new GameNode(9, 7, 0, GH10, GH17, GH9, 0); GameNode I9 = new GameNode(9, 9, 0, GH9, GH17, GH8, 0); GameNode I11 = new GameNode(9, 11, 0, GH17, GH16, GH8, 0); GameNode I13 = new GameNode(9, 13, 0, GH8, GH16, GH7, 0); GameNode I15 = new GameNode(9, 15, 0, GH16, GH6, GH7, 0); GameNode I17 = new GameNode(9, 17, 0, GH7, GH6, Ocean, 0); GameNode I19 = new GameNode(9, 19, 0, GH6, Ocean, Ocean, 0); GameNode K5 = new GameNode(11, 5, 0, Ocean, GH9, Ocean, 0); GameNode K7 = new GameNode(11, 7, 0, Ocean, GH9, Ocean, 0); GameNode K9 = new GameNode(11, 9, 0, GH9, GH8, Ocean, 0); GameNode K11 = new GameNode(11, 11, 0, Ocean, GH8, Ocean, 0); GameNode K13 = new GameNode(11, 13, 0, GH8, GH7, Ocean, 0); GameNode K15 = new GameNode(11, 15, 0, Ocean, GH7, Ocean, 0); GameNode K17 = new GameNode(11, 17, 0, GH7, Ocean, Ocean, 0); C3.AddPort(randPorts[0]); E3.AddPort(randPorts[0]); A5.AddPort(randPorts[1]); A7.AddPort(randPorts[1]); A11.AddPort(randPorts[2]); A13.AddPort(randPorts[2]); C17.AddPort(randPorts[3]); C19.AddPort(randPorts[3]); E21.AddPort(randPorts[4]); G21.AddPort(randPorts[4]); I19.AddPort(randPorts[5]); I17.AddPort(randPorts[5]); K11.AddPort(randPorts[6]); K13.AddPort(randPorts[6]); K5.AddPort(randPorts[7]); K7.AddPort(randPorts[7]); G3.AddPort(randPorts[8]); I3.AddPort(randPorts[8]); //Game Roads (locx, locy, player, Node1, Node2) GameRoad A6 = new GameRoad(1, 6, 0, A5, A7); GameRoad A8 = new GameRoad(1, 8, 0, A7, A9); GameRoad A10 = new GameRoad(1, 10, 0, A9, A11); GameRoad A12 = new GameRoad(1, 12, 0, A11, A13); GameRoad A14 = new GameRoad(1, 14, 0, A13, A15); GameRoad A16 = new GameRoad(1, 16, 0, A15, A17); GameRoad B5 = new GameRoad(2, 5, 0, A5, C5); GameRoad B9 = new GameRoad(2, 9, 0, A9, C9); GameRoad B13 = new GameRoad(2, 13, 0, A13, C13); GameRoad B17 = new GameRoad(2, 17, 0, A17, C17); GameRoad C4 = new GameRoad(3, 4, 0, C3, C5); GameRoad C6 = new GameRoad(3, 6, 0, C5, C7); GameRoad C8 = new GameRoad(3, 8, 0, C7, C9); GameRoad C10 = new GameRoad(3, 10, 0, C9, C11); GameRoad C12 = new GameRoad(3, 12, 0, C11, C13); GameRoad C14 = new GameRoad(3, 14, 0, C13, C15); GameRoad C16 = new GameRoad(3, 16, 0, C15, C17); GameRoad C18 = new GameRoad(3, 18, 0, C17, C19); GameRoad D3 = new GameRoad(4, 3, 0, C3, E3); GameRoad D7 = new GameRoad(4, 7, 0, C7, E7); GameRoad D11 = new GameRoad(4, 11, 0, C11, E11); GameRoad D15 = new GameRoad(4, 15, 0, C15, E15); GameRoad D19 = new GameRoad(4, 19, 0, C19, E19); GameRoad E2 = new GameRoad(5, 2, 0, E1, E3); GameRoad E4 = new GameRoad(5, 4, 0, E3, E5); GameRoad E6 = new GameRoad(5, 6, 0, E5, E7); GameRoad E8 = new GameRoad(5, 8, 0, E7, E9); GameRoad E10 = new GameRoad(5, 10, 0, E9, E11); GameRoad E12 = new GameRoad(5, 12, 0, E11, E13); GameRoad E14 = new GameRoad(5, 14, 0, E13, E15); GameRoad E16 = new GameRoad(5, 16, 0, E15, E17); GameRoad E18 = new GameRoad(5, 18, 0, E17, E19); GameRoad E20 = new GameRoad(5, 20, 0, E19, E21); GameRoad F1 = new GameRoad(6, 1, 0, E1, G1); GameRoad F5 = new GameRoad(6, 5, 0, E5, G5); GameRoad F9 = new GameRoad(6, 9, 0, E9, G9); GameRoad F13 = new GameRoad(6, 13, 0, E13, G13); GameRoad F17 = new GameRoad(6, 17, 0, E17, G17); GameRoad F21 = new GameRoad(6, 21, 0, E21, G21); GameRoad G2 = new GameRoad(7, 2, 0, G1, G3); GameRoad G4 = new GameRoad(7, 4, 0, G3, G5); GameRoad G6 = new GameRoad(7, 6, 0, G5, G7); GameRoad G8 = new GameRoad(7, 8, 0, G7, G9); GameRoad G10 = new GameRoad(7, 10, 0, G9, G11); GameRoad G12 = new GameRoad(7, 12, 0, G11, G13); GameRoad G14 = new GameRoad(7, 14, 0, G13, G15); GameRoad G16 = new GameRoad(7, 16, 0, G15, G17); GameRoad G18 = new GameRoad(7, 18, 0, G17, G19); GameRoad G20 = new GameRoad(7, 20, 0, G19, G21); GameRoad H3 = new GameRoad(8, 3, 0, G3, I3); GameRoad H7 = new GameRoad(8, 7, 0, G7, I7); GameRoad H11 = new GameRoad(8, 11, 0, G11, I11); GameRoad H15 = new GameRoad(8, 15, 0, G15, I15); GameRoad H19 = new GameRoad(8, 19, 0, G19, I19); GameRoad I4 = new GameRoad(9, 4, 0, I3, I5); GameRoad I6 = new GameRoad(9, 6, 0, I5, I7); GameRoad I8 = new GameRoad(9, 8, 0, I7, I9); GameRoad I10 = new GameRoad(9, 10, 0, I9, I11); GameRoad I12 = new GameRoad(9, 12, 0, I11, I13); GameRoad I14 = new GameRoad(9, 14, 0, I13, I15); GameRoad I16 = new GameRoad(9, 16, 0, I15, I17); GameRoad I18 = new GameRoad(9, 18, 0, I17, I19); GameRoad J5 = new GameRoad(10, 5, 0, I5, K5); GameRoad J9 = new GameRoad(10, 9, 0, I9, K9); GameRoad J13 = new GameRoad(10, 13, 0, I13, K13); GameRoad J17 = new GameRoad(10, 17, 0, I17, K17); GameRoad K6 = new GameRoad(11, 6, 0, K5, K7); GameRoad K8 = new GameRoad(11, 8, 0, K7, K9); GameRoad K10 = new GameRoad(11, 10, 0, K9, K11); GameRoad K12 = new GameRoad(11, 12, 0, K11, K13); GameRoad K14 = new GameRoad(11, 14, 0, K13, K15); GameRoad K16 = new GameRoad(11, 16, 0, K15, K17); //Board Array, array of all GameNodes and GameRoads boardArray = new object[12, 22]; boardArray[1, 5] = A5; boardArray[1, 6] = A6; boardArray[1, 7] = A7; boardArray[1, 8] = A8; boardArray[1, 9] = A9; boardArray[1, 10] = A10; boardArray[1, 11] = A11; boardArray[1, 12] = A12; boardArray[1, 13] = A13; boardArray[1, 14] = A14; boardArray[1, 15] = A15; boardArray[1, 16] = A16; boardArray[1, 17] = A17; boardArray[2, 5] = B5; boardArray[2, 9] = B9; boardArray[2, 13] = B13; boardArray[2, 17] = B17; boardArray[3, 3] = C3; boardArray[3, 4] = C4; boardArray[3, 5] = C5; boardArray[3, 6] = C6; boardArray[3, 7] = C7; boardArray[3, 8] = C8; boardArray[3, 9] = C9; boardArray[3, 10] = C10; boardArray[3, 11] = C11; boardArray[3, 12] = C12; boardArray[3, 13] = C13; boardArray[3, 14] = C14; boardArray[3, 15] = C15; boardArray[3, 16] = C16; boardArray[3, 17] = C17; boardArray[3, 18] = C18; boardArray[3, 19] = C19; boardArray[4, 3] = D3; boardArray[4, 7] = D7; boardArray[4, 11] = D11; boardArray[4, 15] = D15; boardArray[4, 19] = D19; boardArray[5, 1] = E1; boardArray[5, 2] = E2; boardArray[5, 3] = E3; boardArray[5, 4] = E4; boardArray[5, 5] = E5; boardArray[5, 6] = E6; boardArray[5, 7] = E7; boardArray[5, 8] = E8; boardArray[5, 9] = E9; boardArray[5, 10] = E10; boardArray[5, 11] = E11; boardArray[5, 12] = E12; boardArray[5, 13] = E13; boardArray[5, 14] = E14; boardArray[5, 15] = E15; boardArray[5, 16] = E16; boardArray[5, 17] = E17; boardArray[5, 18] = E18; boardArray[5, 19] = E19; boardArray[5, 20] = E20; boardArray[5, 21] = E21; boardArray[6, 1] = F1; boardArray[6, 5] = F5; boardArray[6, 9] = F9; boardArray[6, 13] = F13; boardArray[6, 17] = F17; boardArray[6, 21] = F21; boardArray[7, 1] = G1; boardArray[7, 2] = G2; boardArray[7, 3] = G3; boardArray[7, 4] = G4; boardArray[7, 5] = G5; boardArray[7, 6] = G6; boardArray[7, 7] = G7; boardArray[7, 8] = G8; boardArray[7, 9] = G9; boardArray[7, 10] = G10; boardArray[7, 11] = G11; boardArray[7, 12] = G12; boardArray[7, 13] = G13; boardArray[7, 14] = G14; boardArray[7, 15] = G15; boardArray[7, 16] = G16; boardArray[7, 17] = G17; boardArray[7, 18] = G18; boardArray[7, 19] = G19; boardArray[7, 20] = G20; boardArray[7, 21] = G21; boardArray[8, 3] = H3; boardArray[8, 7] = H7; boardArray[8, 11] = H11; boardArray[8, 15] = H15; boardArray[8, 19] = H19; boardArray[9, 3] = I3; boardArray[9, 4] = I4; boardArray[9, 5] = I5; boardArray[9, 6] = I6; boardArray[9, 7] = I7; boardArray[9, 8] = I8; boardArray[9, 9] = I9; boardArray[9, 10] = I10; boardArray[9, 11] = I11; boardArray[9, 12] = I12; boardArray[9, 13] = I13; boardArray[9, 14] = I14; boardArray[9, 15] = I15; boardArray[9, 16] = I16; boardArray[9, 17] = I17; boardArray[9, 18] = I18; boardArray[9, 19] = I19; boardArray[10, 5] = J5; boardArray[10, 9] = J9; boardArray[10, 13] = J13; boardArray[10, 17] = J17; boardArray[11, 5] = K5; boardArray[11, 6] = K6; boardArray[11, 7] = K7; boardArray[11, 8] = K8; boardArray[11, 9] = K9; boardArray[11, 10] = K10; boardArray[11, 11] = K11; boardArray[11, 12] = K12; boardArray[11, 13] = K13; boardArray[11, 14] = K14; boardArray[11, 15] = K15; boardArray[11, 16] = K16; boardArray[11, 17] = K17; break; } case "CustomGame": { break; } } }
//Purpose: Moves the Robber from its current location to moveToHere //Params: moveToHere - a GameHex where the robber is to be moved //Return: None public void setRobber(GameHex moveToHere) { GameHex currentRobber = findRobber(); foreach (GameHex gh in gameHexes) { //We can place it when we find it, but it can't be moved to where it already is if ((gh == moveToHere) && (gh != currentRobber)) { currentRobber.hasRobber = false; gh.hasRobber = true; return; } } }
// Purpose: Import 2D Sprites that make up the HUD and different menus that are opened up protected override void LoadContent() { //Sprites for the default HUD hudBackground = OurGame.Content.Load<Texture2D>(@"Textures\Hud\Hud_Background"); hudActions = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_Actions2"); hudResources = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_Resources"); hudLongests = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_Longests"); hudVictoryPoints = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_VictoryPoints"); //Sprites to show Dice roll hudDiceOne = OurGame.Content.Load<Texture2D>(@"Textures\Hud\Dice_One"); hudDiceTwo = OurGame.Content.Load<Texture2D>(@"Textures\Hud\Dice_Two"); hudDiceThree = OurGame.Content.Load<Texture2D>(@"Textures\Hud\Dice_Three"); hudDiceFour = OurGame.Content.Load<Texture2D>(@"Textures\Hud\Dice_Four"); hudDiceFive = OurGame.Content.Load<Texture2D>(@"Textures\Hud\Dice_Five"); hudDiceSix = OurGame.Content.Load<Texture2D>(@"Textures\Hud\Dice_Six"); //Sprites that are opened up after choosing different actions on the main HUD hudTradeMenu = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_TradingBlock"); hudAITradeMenu = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_aiTrade"); hudYearOfPlenty = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_RobberGiveaway"); hudBuildRoad = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_BuildRoad"); hudBuildSettlement = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_BuildSettlement"); hudBuildCity = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_BuildCity"); hudBuildDevCard = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_BuildDevCard"); hudCardPopup = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_CardPopup"); //The AI player HUD Information aiOne = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_MaleAI"); aiTwo = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_FemaleAI"); aiOneSteal = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_StealFrom1"); aiTwoSteal = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_StealFrom2"); aiAccept = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_Accept"); aiReject = OurGame.Content.Load<Texture2D>(@"Textures\Hud\HUD_Reject"); //Fill the developmentCards List with card textures developmentCards = new List<Texture2D>(); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Knight")); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_University")); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Palace")); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Library")); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Market")); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Chapel")); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_YearOfPlenty")); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Monopoly")); developmentCards.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_RoadBuilding")); //Monopoly textures monopolyTextures = new List<Texture2D>(); monopolyTextures.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Brick")); monopolyTextures.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Grain")); monopolyTextures.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Lumber")); monopolyTextures.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Wool")); monopolyTextures.Add(OurGame.Content.Load<Texture2D>(@"Textures\Cards\Card_Ore")); //Set the font for the text on the HUD largeFont = Content.Load<SpriteFont>(@"Fonts\hudlarge"); //Set Bools for draw actions drawDice = false; drawTrade = false; drawBuild = false; drawCards = false; //Set Bools for Hud Menus tradingMode = false; playedCard = false; turnCountZero = true; //Set Score Text Positions for humanPlayer brickTextPosition = new Vector2((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + 170, screenHeight - (TitleSafeArea.Bottom + 40)); wheatTextPosition = new Vector2((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + 234, screenHeight - (TitleSafeArea.Bottom + 40)); woodTextPosition = new Vector2((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + 295, screenHeight - (TitleSafeArea.Bottom + 40)); woolTextPosition = new Vector2((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + 358, screenHeight - (TitleSafeArea.Bottom + 40)); oreTextPosition = new Vector2((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + 420, screenHeight - (TitleSafeArea.Bottom + 40)); knightsTextPosition = new Vector2((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + 550, screenHeight - (TitleSafeArea.Bottom + 100)); roadsTextPosition = new Vector2((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + 550, screenHeight - (TitleSafeArea.Bottom + 50)); victoryPointTextPosition = new Vector2((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + 642, screenHeight - (TitleSafeArea.Bottom + 50)); //Set Score Text Positions for AIOne aiOneResourcesPos = new Vector2(TitleSafeArea.Left + 64, TitleSafeArea.Top + 162); aiOneDevCardsPos = new Vector2(TitleSafeArea.Left + 64, TitleSafeArea.Top + 195); aiOneKnightsPos = new Vector2(TitleSafeArea.Left + 114, TitleSafeArea.Top + 162); aiOneRoadsPos = new Vector2(TitleSafeArea.Left + 114, TitleSafeArea.Top + 195); aiOneVPPos = new Vector2(TitleSafeArea.Left + 90, TitleSafeArea.Top + 225); //Set Score Text Positions for AITwo aiTwoResourcesPos = new Vector2(screenWidth - (aiTwo.Width + TitleSafeArea.Right - 64), TitleSafeArea.Top + 162); aiTwoDevCardsPos = new Vector2(screenWidth - (aiTwo.Width + TitleSafeArea.Right - 64), TitleSafeArea.Top + 195); aiTwoKnightsPos = new Vector2(screenWidth - (aiTwo.Width + TitleSafeArea.Right - 114), TitleSafeArea.Top + 162); aiTwoRoadsPos = new Vector2(screenWidth - (aiTwo.Width + TitleSafeArea.Right - 114), TitleSafeArea.Top + 195); aiTwoVPPos = new Vector2(screenWidth - (aiTwo.Width + TitleSafeArea.Right - 90), TitleSafeArea.Top + 225); //Rectangles for Accept/Reject AI Icons aiOneResponse = new Rectangle(TitleSafeArea.Left + 150, TitleSafeArea.Top + 160, aiAccept.Width, aiAccept.Height); aiTwoResponse = new Rectangle(screenWidth - (TitleSafeArea.Right + 150 + aiAccept.Width), TitleSafeArea.Top + 160, aiAccept.Width, aiAccept.Height); playerRejects = new Rectangle(screenWidth / 5 + 20, screenHeight - (180 + TitleSafeArea.Bottom), aiReject.Width, aiReject.Height); //Rectangles for Steal from AI Icons aiOneStealPos = new Rectangle(TitleSafeArea.Left + 142, TitleSafeArea.Top + 160, aiOneSteal.Width, aiOneSteal.Height); aiTwoStealPos = new Rectangle(screenWidth - (TitleSafeArea.Right + 142 + aiTwoSteal.Width), TitleSafeArea.Top + 160, aiTwoSteal.Width, aiTwoSteal.Height); aiCanSteal = new List<Player>(); robberHex = new GameHex(); //Temporary Mouse Position information mouseXTextPosition = new Vector2(OurGame.width / 2 + 300, OurGame.height - (TitleSafeArea.Bottom + 40)); mouseYTextPosition = new Vector2(OurGame.width / 2 + 400, OurGame.height - (TitleSafeArea.Bottom + 40)); //Rectangles for main Hud Action Pieces diceRectangle = new Rectangle(screenWidth / 2 - 502, screenHeight - (hudActions.Height + TitleSafeArea.Bottom - 10), 60, 54); tradeRectangle = new Rectangle(screenWidth / 2 - 442, screenHeight - (hudActions.Height + TitleSafeArea.Bottom - 10), 60, 54); stopRectangle = new Rectangle(screenWidth / 2 - 502, screenHeight - (hudActions.Height + TitleSafeArea.Bottom - 64), 60, 54); buildRectangle = new Rectangle(screenWidth / 2 - 442, screenHeight - (hudActions.Height + TitleSafeArea.Bottom - 64), 60, 54); cardPopupRectangle = new Rectangle((screenWidth - hudBackground.Width) / 2 + TitleSafeArea.Left + hudActions.Width / 2 + hudResources.Width + hudLongests.Width + hudVictoryPoints.Width + 10, screenHeight - (hudCardPopup.Height + TitleSafeArea.Bottom - 10), hudCardPopup.Width - 10, hudCardPopup.Height - 15); //Rectangles for building cards roadCardRectangle = new Rectangle(screenWidth / 4, screenHeight - (240 + TitleSafeArea.Bottom), hudBuildRoad.Width, hudBuildRoad.Height); settleCardRectangle = new Rectangle(screenWidth / 4 + hudBuildRoad.Width + 10, screenHeight - (240 + TitleSafeArea.Bottom), hudBuildRoad.Width, hudBuildRoad.Height); cityCardRectangle = new Rectangle(screenWidth / 4 + hudBuildRoad.Width * 2 + 20, screenHeight - (240 + TitleSafeArea.Bottom), hudBuildRoad.Width, hudBuildRoad.Height); devCardRectangle = new Rectangle(screenWidth / 4 + hudBuildRoad.Width * 3 + 30, screenHeight - (240 + TitleSafeArea.Bottom), hudBuildRoad.Width, hudBuildRoad.Height); //Rectangles, text numbers, and text position vectors for trade menu tradeNumbers = new int[10]; tradeTextPos = new List<Vector2>(); tradeMenuText = new String[10]; increaseAmount = new List<Rectangle>(); decreaseAmount = new List<Rectangle>(); //Rectangles for the Up/Down buttons to increase or decrease the amount to trade for (int i = 0; i < 10; i++) { if (i < 5) { tradeTextPos.Add(new Vector2(screenWidth / 8 + 20, screenHeight - (60 - i * 34 + hudTradeMenu.Height + TitleSafeArea.Bottom))); increaseAmount.Add(new Rectangle(screenWidth / 8 + 47, screenHeight - (67 - i * 34 + hudTradeMenu.Height + TitleSafeArea.Bottom), 37, 17)); decreaseAmount.Add(new Rectangle(screenWidth / 8 + 47, screenHeight - (47 - i * 34 + hudTradeMenu.Height + TitleSafeArea.Bottom), 37, 13)); } else { tradeTextPos.Add(new Vector2(screenWidth / 8 + 192, screenHeight - (60 - (i - 5) * 34 + hudTradeMenu.Height + TitleSafeArea.Bottom))); increaseAmount.Add(new Rectangle(screenWidth / 8 + 138, screenHeight - (67 - (i - 5) * 34 + hudTradeMenu.Height + TitleSafeArea.Bottom), 40, 17)); decreaseAmount.Add(new Rectangle(screenWidth / 8 + 138, screenHeight - (47 - (i - 5) * 34 + hudTradeMenu.Height + TitleSafeArea.Bottom), 40, 13)); } tradeNumbers[i] = 0; } //rectangles for accept trade and bank trade acceptTrade = new Rectangle(screenWidth / 8 + 47, screenHeight - (hudTradeMenu.Height + TitleSafeArea.Bottom - 106), 38, 50); bankTrade = new Rectangle(screenWidth / 8 + 92, screenHeight - (hudTradeMenu.Height + TitleSafeArea.Bottom - 106), 38, 50); declineTrade = new Rectangle(screenWidth / 8 + 137, screenHeight - (hudTradeMenu.Height + TitleSafeArea.Bottom - 106), 38, 50); //Initialize aiTrade information aiTradeNumbers = new int[10]; aiTradeMenuText = new String[10]; aiOffering = ""; aiTradeTextPos = new List<Vector2>(); aiOfferingPos = new Vector2(screenWidth / 8 + 92, screenHeight - (115 + hudTradeMenu.Height + TitleSafeArea.Bottom)); for (int i = 0; i < 10; i++) { if (i < 5) { aiTradeTextPos.Add(new Vector2(screenWidth / 8 + 40, screenHeight - (60 - i * 34 + hudTradeMenu.Height + TitleSafeArea.Bottom))); } else { aiTradeTextPos.Add(new Vector2(screenWidth / 8 + 177, screenHeight - (60 - (i - 5) * 34 + hudTradeMenu.Height + TitleSafeArea.Bottom))); } aiTradeNumbers[i] = 0; } acceptAITrade = new Rectangle(screenWidth / 8 + 70, screenHeight - (hudTradeMenu.Height + TitleSafeArea.Bottom - 126), 30, 30); rejectAITrade = new Rectangle(screenWidth / 8 + 128, screenHeight - (hudTradeMenu.Height + TitleSafeArea.Bottom - 126), 30, 30); //YearOfPlenty Menu yopCounter = 0; yopNumbers = new int[5]; yopTextPos = new List<Vector2>(); yopMenuText = new String[5]; yopUp = new List<Rectangle>(); yopDown = new List<Rectangle>(); for (int i = 0; i < 15; i++) { yopTextPos.Add(new Vector2(6 * screenWidth / 8 + 70, screenHeight - (60 - i * 34 + hudYearOfPlenty.Height + TitleSafeArea.Bottom))); yopUp.Add(new Rectangle(6 * screenWidth / 8 + 102, screenHeight - (67 - i * 34 + hudYearOfPlenty.Height + TitleSafeArea.Bottom), 20, 17)); yopDown.Add(new Rectangle(6 * screenWidth / 8 + 102, screenHeight - (47 - i * 34 + hudYearOfPlenty.Height + TitleSafeArea.Bottom), 20, 13)); } yopAccept = new Rectangle(6 * screenWidth / 8 + 58, screenHeight - (hudYearOfPlenty.Height + TitleSafeArea.Bottom - 126), 50, 30); yopDecline = new Rectangle(6 * screenWidth / 8 + 120, screenHeight - (hudYearOfPlenty.Height + TitleSafeArea.Bottom - 126), 50, 30); //rectangles for devCards devCardRectangles = new List<Rectangle>(); devCardRectanglesOwned = new List<Rectangle>(); for (int i = 0; i < 9; i++) { devCardRectangles.Add(new Rectangle(screenWidth - 5 * developmentCards[i].Width + (i * developmentCards[i].Width / 2), screenHeight - (developmentCards[i].Height + TitleSafeArea.Bottom), developmentCards[i].Width / 2, developmentCards[i].Height / 2)); } monopolyRectangles = new List<Rectangle>(); for (int i = 0; i < 5; i++) { monopolyRectangles.Add(new Rectangle(screenWidth - 4 * monopolyTextures[i].Width + (i * monopolyTextures[i].Width / 2), screenHeight - (monopolyTextures[i].Height + TitleSafeArea.Bottom), monopolyTextures[i].Width / 2, monopolyTextures[i].Height / 2)); } amountGivePos = new Vector2((6 * screenWidth / 8 + 162), screenHeight - (114 + hudYearOfPlenty.Height + TitleSafeArea.Bottom)); }
//Update the mouse spot when left click is hit. (this will be altered, more of a test to see if left click worked) public override void Update(GameTime gameTime) { //Temporary Mouse Information write out mouseXText = "X: " + OurGame.mouseX.ToString(); mouseYText = "Y: " + OurGame.mouseY.ToString(); //OurGame.humanPlayer.SetBuildBools(); Point mouseClick = new Point( OurGame.mouseX, OurGame.mouseY ); //Mouse updates for hudActions menu //Updates the dice roll for the player if the dice menu button is pressed if ( OurGame.humanPlayer.canRollDice && diceRectangle.Contains(mouseClick) ) { OurGame.humanPlayer.canRollDice = false; drawDice = true; OurGame.gameDice.rollDice(); playingState.rolledDice = true; OurGame.humanPlayer.canTrade = true; OurGame.humanPlayer.canBuild = true; OurGame.humanPlayer.canEndTurn = true; } //Updates information if the trade menu button is pressed if (OurGame.humanPlayer.canTrade && tradeRectangle.Contains(mouseClick)) { drawDice = false; drawBuild = false; drawCards = false; playingState.buildingSettlement = false; playingState.buildingCity = false; playingState.buildingRoad = false; tradingMode = true; drawTrade = true; } //Updates information if the build menu button is pressed if (OurGame.humanPlayer.canBuild && buildRectangle.Contains(mouseClick)) { drawDice = false; drawTrade = false; drawCards = false; playingState.buildingSettlement = false; playingState.buildingCity = false; playingState.buildingRoad = false; if (!drawBuild) drawBuild = true; else drawBuild = false; } //Updates information if the endturn menu button is pressed if (OurGame.humanPlayer.canEndTurn && stopRectangle.Contains(mouseClick)) { drawDice = false; drawTrade = false; drawBuild = false; drawCards = false; playedCard = false; OurGame.humanPlayer.devCards.CopyTo(OurGame.humanPlayer.cardsAvailable, 0); playingState.turnWaitCounter = 0; playingState.rolledDice = false; playingState.buildingSettlement = false; playingState.buildingCity = false; playingState.buildingRoad = false; OurGame.humanPlayer.canEndTurn = false; OurGame.humanPlayer.canTrade = false; OurGame.humanPlayer.canBuild = false; playingState.humanPlayerTurn = false; playingState.aiTurn = true; } //Updates information if the card menu button is pressed if (playingState.humanPlayerTurn && cardPopupRectangle.Contains(mouseClick) && !playingState.gameStartMode) { drawDice = false; drawBuild = false; drawTrade = false; playingState.buildingSettlement = false; playingState.buildingCity = false; playingState.buildingRoad = false; drawCards = true; } //Mouse updates for buildCards //Updates the build bools if the buildCards are pressed if (OurGame.humanPlayer.canBuildRoad && roadCardRectangle.Contains(mouseClick) && drawBuild) { playingState.buildingRoad = true; } if (OurGame.humanPlayer.canBuildSettlement && settleCardRectangle.Contains(mouseClick) && drawBuild) { playingState.buildingSettlement = true; } if (OurGame.humanPlayer.canBuildCity && cityCardRectangle.Contains(mouseClick) && drawBuild) { playingState.buildingCity = true; } if (OurGame.humanPlayer.canBuildDevCard && devCardRectangle.Contains(mouseClick) && drawBuild) { playingState.BoughtDevCard(OurGame.humanPlayer); } //Controls the trade menu if (tradingMode) { bool test; for (int i = 0; i < 10; i++) { if (increaseAmount[i].Contains(mouseClick)) { test = testTradeIncrement(i, tradeNumbers[i]); if (test) tradeNumbers[i]++; } if (decreaseAmount[i].Contains(mouseClick)) { if (tradeNumbers[i] > 0) tradeNumbers[i]--; } } if (acceptTrade.Contains(mouseClick)) { tradingMode = false; drawTrade = false; for (int i = 0; i < 5; i++) { playingState.currentTrade.tradeOffer[i] = tradeNumbers[i]; playingState.currentTrade.tradeRequest[i] = tradeNumbers[i + 5]; } playingState.PlayerRequestedTrade(OurGame.humanPlayer); Array.Clear(tradeNumbers, 0, tradeNumbers.Length); } if (bankTrade.Contains(mouseClick)) { for (int i = 0; i < 5; i++) { playingState.currentTrade.tradeOffer[i] = tradeNumbers[i]; playingState.currentTrade.tradeRequest[i] = tradeNumbers[i + 5]; } if (playingState.currentTrade.isBankTradeValid(OurGame.humanPlayer)) { tradingMode = false; drawTrade = false; Array.Clear(tradeNumbers, 0, tradeNumbers.Length); } } if (declineTrade.Contains(mouseClick)) { tradingMode = false; drawTrade = false; Array.Clear(tradeNumbers, 0, tradeNumbers.Length); } OurGame.humanPlayer.SetBuildBools(); } //Controls the yearOfPlenty Menu if (playingState.yearOfPlentyMode) { for (int i = 0; i < 5; i++) { if (yopUp[i].Contains(mouseClick) && yopCounter < 2) { yopNumbers[i]++; yopCounter++; } if (yopDown[i].Contains(mouseClick)) { if (yopNumbers[i] > 0) { yopNumbers[i]--; yopCounter--; } } } if (yopAccept.Contains(mouseClick)) { yopCounter = 0; playingState.yearOfPlentyMode = false; OurGame.humanPlayer.devCards[6]--; OurGame.humanPlayer.cardsAvailable[6]--; playingState.currentTrade.yopRequest = yopNumbers; playingState.currentTrade.yopTrade(OurGame.humanPlayer); playedCard = true; Array.Clear(yopNumbers, 0, yopNumbers.Length); } if (yopDecline.Contains(mouseClick)) { yopCounter = 0; playingState.yearOfPlentyMode = false; Array.Clear(yopNumbers, 0, yopNumbers.Length); } OurGame.humanPlayer.SetBuildBools(); } //Control DevCards if (drawCards) { for (int i = 0; i < 9; i++) { if (OurGame.humanPlayer.cardsAvailable[i] > 0) { if (devCardRectangles[i].Contains(mouseClick) && !playedCard) { playingState.PlayDevCard(i, OurGame.humanPlayer); drawCards = false; } } } } //Control choosing which AI gets stolen from when robber moved if (playingState.chooseTheft) { robberHex = OurGame.gameBoard.findRobber(); aiCanSteal = OurGame.gameBoard.eligibleVictims(robberHex, OurGame, OurGame.humanPlayer); foreach (Player px in aiCanSteal) { if (px == OurGame.aiPlayer1) { if (aiOneStealPos.Contains(mouseClick)) { int stolenResource = OurGame.humanPlayer.stealRandomCard(OurGame.aiPlayer1); if (stolenResource != -1) OurGame.humanPlayer.incResource(stolenResource); OurGame.humanPlayer.canEndTurn = true; OurGame.humanPlayer.canBuild = true; OurGame.humanPlayer.canTrade = true; OurGame.humanPlayer.SetBuildBools(); playingState.movingRobber = false; playingState.chooseTheft = false; } } if (px == OurGame.aiPlayer2) { if (aiTwoStealPos.Contains(mouseClick)) { int stolenResource = OurGame.humanPlayer.stealRandomCard(OurGame.aiPlayer2); if (stolenResource != -1) OurGame.humanPlayer.incResource(stolenResource); OurGame.humanPlayer.canEndTurn = true; OurGame.humanPlayer.canBuild = true; OurGame.humanPlayer.canTrade = true; OurGame.humanPlayer.SetBuildBools(); playingState.movingRobber = false; playingState.chooseTheft = false; } } } } //control monopoly mode cards if (playingState.monopolyMode) { for (int i = 0; i < 5; i++) { if (monopolyRectangles[i].Contains(mouseClick)) { playingState.gameCard.MonopolyChosen(i, OurGame.humanPlayer); playingState.monopolyMode = false; } } } //control player reject or accept of trade offered to AI players if (playingState.aiResponded) { if (playingState.aiOneResponse) { if (playerRejects.Contains(mouseClick)) { playingState.aiResponded = false; } if (aiOneResponse.Contains(mouseClick)) { playingState.currentTrade.humanTradeWithAI(OurGame.humanPlayer, OurGame.aiPlayer1); playingState.aiResponded = false; } } if (playingState.aiTwoResponse) { if (playerRejects.Contains(mouseClick)) { playingState.aiResponded = false; } if (aiTwoResponse.Contains(mouseClick)) { playingState.currentTrade.humanTradeWithAI(OurGame.humanPlayer, OurGame.aiPlayer2); playingState.aiResponded = false; } } if (!playingState.aiOneResponse && !playingState.aiTwoResponse) { if (turnCountZero) { playingState.turnWaitCounter = 0; turnCountZero = false; } if (playingState.turnWaitCounter > 2) { playingState.aiResponded = false; turnCountZero = true; } } } //Control menu for when AI requests trade if (playingState.aiRequestsTradeFromHuman) { for (int i = 0; i < 5; i++) { aiTradeNumbers[i] = playingState.currentTrade.tradeOffer[i]; aiTradeNumbers[i + 5] = playingState.currentTrade.tradeRequest[i]; } for (int i = 0; i < 3; i++) { if (playingState.playerTurn == OurGame.players[i].playerNumber) { if (OurGame.players[i] == OurGame.aiPlayer1) aiOffering = "Jeff"; else if (OurGame.players[i] == OurGame.aiPlayer2) aiOffering = "Mary"; } } if (acceptAITrade.Contains(mouseClick)) { playingState.humanAcceptsTrade = true; playingState.humanResponded = true; playingState.aiRequestsTradeFromHuman = false; } if (rejectAITrade.Contains(mouseClick)) { playingState.humanAcceptsTrade = false; playingState.humanResponded = true; playingState.aiRequestsTradeFromHuman = false; } } //this controls the robber give away menu (uses year of plenty menu rectangles) if (playingState.robberGiveAway) { bool test; amountGive = OurGame.humanPlayer.totalResources / 2; for (int i = 0; i < 5; i++) { if (yopUp[i].Contains(mouseClick)) { test = testTradeIncrement(i, yopNumbers[i]); if (test) yopNumbers[i]++; } if (yopDown[i].Contains(mouseClick)) { if (yopNumbers[i] > 0) { yopNumbers[i]--; } } } if (yopAccept.Contains(mouseClick)) { bool isValid; playingState.currentTrade.yopRequest = yopNumbers; isValid = playingState.currentTrade.robberGiveAway(OurGame.humanPlayer); if (isValid) { playingState.robberGiveAway = false; if (playingState.humanPlayerTurn) playingState.movingRobber = true; Array.Clear(yopNumbers, 0, yopNumbers.Length); } } if (yopDecline.Contains(mouseClick)) { Array.Clear(yopNumbers, 0, yopNumbers.Length); } OurGame.humanPlayer.SetBuildBools(); OurGame.humanPlayer.ResourceSum(); } base.Update(gameTime); }