public bool CanEndTurn(Robber oRobber) { if (oRobberMenu == null && oYearOfPlentymenu == null && oMonopolyMenu == null && oRoadBuildingMenu == null && oKnightMenu == null && bRollMade == true && oRobber.bMoveRobber == false && oRobber.bPickedUp == false) { return(true); } return(false); }
public BasicGame(Camera oCamera) { //XNACS1Base.World.SetBackgroundTexture(null); //XNACS1Base.World.SetBackgroundColor(new Color(88, 177, 223)); XNACS1Base.World.SetBackgroundTexture("Background"); oCamera.bAllowMovement = true; oStats = new Stats(); Random rand = new Random(); oHexes = new Hex[5, 5]; int nCount = 0; Road[] oTempRoads = new Road[75]; Vector2 oRobberStartingLocation = new Vector2(); Vector2 oRobberStartingHex = new Vector2(); #region Create and Place Hexes for (int y = 0; y < 5; y++) { for (int x = 4; x > -1; x--) { //Vector2 oVect; //version 1 //float fYPos = Global.PixelSize(80); //float fXPos = Global.PixelSize(88); //version 2 float fYPos = 9.01f; float fXPos = 9.72f; if ((y == 0 || y == 4) && x >= 3) { continue; } else if ((y == 1 || y == 3) && x >= 4) { continue; } Vector2 oVect = new Vector2(32f + x * fXPos, 35f - (y * fYPos) + x * (fYPos / 2)); if (y > 2) { oVect += new Vector2(fXPos, (fYPos / 2)); } if (y > 3) { oVect += new Vector2(fXPos, (fYPos / 2)); } #region Resource Type int nRand; do { nRand = rand.Next() % 6; }while (nResourceCounts[nRand] == 0); nResourceCounts[nRand]--; string sType; if (nRand == 0) { sType = "wool"; } else if (nRand == 1) { sType = "lumber"; } else if (nRand == 2) { sType = "ore"; } else if (nRand == 3) { sType = "grain"; } else if (nRand == 4) { sType = "brick"; } else { sType = "empty"; } #endregion #region Roll Number int nNumber = 0; if (sType != "empty") { do { nNumber = rand.Next() % 11 + 2; }while (nNumber == 7 || nNumber == 0 || nNumberCounts[nNumber] == 0); nNumberCounts[nNumber]--; } #endregion oHexes[x, y] = new Hex(oVect, nNumber, sType, x + "," + y); if (sType == "empty") { oHexes[x, y].bRobber = true; oRobberStartingLocation = oHexes[x, y].Center; oRobberStartingHex = new Vector2(x, y); } } } #endregion for (int x = 0; x < oTempRoads.Count(); x++) { oTempRoads[x] = new Road(x, new Vector2(x * 1.5f, 0)); } for (int x = 0; x < oTempIntersections.Count(); x++) { oTempIntersections[x] = new Intersection(x); } #region Connect Buildings oHexes[0, 0].oIntersections[0] = oTempIntersections[2]; oHexes[0, 0].oIntersections[1] = oTempIntersections[1]; oHexes[0, 0].oIntersections[2] = oTempIntersections[0]; oHexes[0, 0].oIntersections[3] = oTempIntersections[8]; oHexes[0, 0].oIntersections[4] = oTempIntersections[9]; oHexes[0, 0].oIntersections[5] = oTempIntersections[10]; oHexes[1, 0].oIntersections[0] = oTempIntersections[4]; oHexes[1, 0].oIntersections[1] = oTempIntersections[3]; oHexes[1, 0].oIntersections[2] = oTempIntersections[2]; oHexes[1, 0].oIntersections[3] = oTempIntersections[10]; oHexes[1, 0].oIntersections[4] = oTempIntersections[11]; oHexes[1, 0].oIntersections[5] = oTempIntersections[12]; oHexes[2, 0].oIntersections[0] = oTempIntersections[6]; oHexes[2, 0].oIntersections[1] = oTempIntersections[5]; oHexes[2, 0].oIntersections[2] = oTempIntersections[4]; oHexes[2, 0].oIntersections[3] = oTempIntersections[12]; oHexes[2, 0].oIntersections[4] = oTempIntersections[13]; oHexes[2, 0].oIntersections[5] = oTempIntersections[14]; oHexes[0, 1].oIntersections[0] = oTempIntersections[9]; oHexes[0, 1].oIntersections[1] = oTempIntersections[8]; oHexes[0, 1].oIntersections[2] = oTempIntersections[7]; oHexes[0, 1].oIntersections[3] = oTempIntersections[17]; oHexes[0, 1].oIntersections[4] = oTempIntersections[18]; oHexes[0, 1].oIntersections[5] = oTempIntersections[19]; oHexes[1, 1].oIntersections[0] = oTempIntersections[11]; oHexes[1, 1].oIntersections[1] = oTempIntersections[10]; oHexes[1, 1].oIntersections[2] = oTempIntersections[9]; oHexes[1, 1].oIntersections[3] = oTempIntersections[19]; oHexes[1, 1].oIntersections[4] = oTempIntersections[20]; oHexes[1, 1].oIntersections[5] = oTempIntersections[21]; oHexes[2, 1].oIntersections[0] = oTempIntersections[13]; oHexes[2, 1].oIntersections[1] = oTempIntersections[12]; oHexes[2, 1].oIntersections[2] = oTempIntersections[11]; oHexes[2, 1].oIntersections[3] = oTempIntersections[21]; oHexes[2, 1].oIntersections[4] = oTempIntersections[22]; oHexes[2, 1].oIntersections[5] = oTempIntersections[23]; oHexes[3, 1].oIntersections[0] = oTempIntersections[15]; oHexes[3, 1].oIntersections[1] = oTempIntersections[14]; oHexes[3, 1].oIntersections[2] = oTempIntersections[13]; oHexes[3, 1].oIntersections[3] = oTempIntersections[23]; oHexes[3, 1].oIntersections[4] = oTempIntersections[24]; oHexes[3, 1].oIntersections[5] = oTempIntersections[25]; oHexes[0, 2].oIntersections[0] = oTempIntersections[18]; oHexes[0, 2].oIntersections[1] = oTempIntersections[17]; oHexes[0, 2].oIntersections[2] = oTempIntersections[16]; oHexes[0, 2].oIntersections[3] = oTempIntersections[27]; oHexes[0, 2].oIntersections[4] = oTempIntersections[28]; oHexes[0, 2].oIntersections[5] = oTempIntersections[29]; oHexes[1, 2].oIntersections[0] = oTempIntersections[20]; oHexes[1, 2].oIntersections[1] = oTempIntersections[19]; oHexes[1, 2].oIntersections[2] = oTempIntersections[18]; oHexes[1, 2].oIntersections[3] = oTempIntersections[29]; oHexes[1, 2].oIntersections[4] = oTempIntersections[30]; oHexes[1, 2].oIntersections[5] = oTempIntersections[31]; oHexes[2, 2].oIntersections[0] = oTempIntersections[22]; oHexes[2, 2].oIntersections[1] = oTempIntersections[21]; oHexes[2, 2].oIntersections[2] = oTempIntersections[20]; oHexes[2, 2].oIntersections[3] = oTempIntersections[31]; oHexes[2, 2].oIntersections[4] = oTempIntersections[32]; oHexes[2, 2].oIntersections[5] = oTempIntersections[33]; oHexes[3, 2].oIntersections[0] = oTempIntersections[24]; oHexes[3, 2].oIntersections[1] = oTempIntersections[23]; oHexes[3, 2].oIntersections[2] = oTempIntersections[22]; oHexes[3, 2].oIntersections[3] = oTempIntersections[33]; oHexes[3, 2].oIntersections[4] = oTempIntersections[34]; oHexes[3, 2].oIntersections[5] = oTempIntersections[35]; oHexes[4, 2].oIntersections[0] = oTempIntersections[26]; oHexes[4, 2].oIntersections[1] = oTempIntersections[25]; oHexes[4, 2].oIntersections[2] = oTempIntersections[24]; oHexes[4, 2].oIntersections[3] = oTempIntersections[35]; oHexes[4, 2].oIntersections[4] = oTempIntersections[36]; oHexes[4, 2].oIntersections[5] = oTempIntersections[37]; oHexes[0, 3].oIntersections[0] = oTempIntersections[30]; oHexes[0, 3].oIntersections[1] = oTempIntersections[29]; oHexes[0, 3].oIntersections[2] = oTempIntersections[28]; oHexes[0, 3].oIntersections[3] = oTempIntersections[38]; oHexes[0, 3].oIntersections[4] = oTempIntersections[39]; oHexes[0, 3].oIntersections[5] = oTempIntersections[40]; oHexes[1, 3].oIntersections[0] = oTempIntersections[32]; oHexes[1, 3].oIntersections[1] = oTempIntersections[31]; oHexes[1, 3].oIntersections[2] = oTempIntersections[30]; oHexes[1, 3].oIntersections[3] = oTempIntersections[40]; oHexes[1, 3].oIntersections[4] = oTempIntersections[41]; oHexes[1, 3].oIntersections[5] = oTempIntersections[42]; oHexes[2, 3].oIntersections[0] = oTempIntersections[34]; oHexes[2, 3].oIntersections[1] = oTempIntersections[33]; oHexes[2, 3].oIntersections[2] = oTempIntersections[32]; oHexes[2, 3].oIntersections[3] = oTempIntersections[42]; oHexes[2, 3].oIntersections[4] = oTempIntersections[43]; oHexes[2, 3].oIntersections[5] = oTempIntersections[44]; oHexes[3, 3].oIntersections[0] = oTempIntersections[36]; oHexes[3, 3].oIntersections[1] = oTempIntersections[35]; oHexes[3, 3].oIntersections[2] = oTempIntersections[34]; oHexes[3, 3].oIntersections[3] = oTempIntersections[44]; oHexes[3, 3].oIntersections[4] = oTempIntersections[45]; oHexes[3, 3].oIntersections[5] = oTempIntersections[46]; oHexes[0, 4].oIntersections[0] = oTempIntersections[41]; oHexes[0, 4].oIntersections[1] = oTempIntersections[40]; oHexes[0, 4].oIntersections[2] = oTempIntersections[39]; oHexes[0, 4].oIntersections[3] = oTempIntersections[47]; oHexes[0, 4].oIntersections[4] = oTempIntersections[48]; oHexes[0, 4].oIntersections[5] = oTempIntersections[49]; oHexes[1, 4].oIntersections[0] = oTempIntersections[43]; oHexes[1, 4].oIntersections[1] = oTempIntersections[42]; oHexes[1, 4].oIntersections[2] = oTempIntersections[41]; oHexes[1, 4].oIntersections[3] = oTempIntersections[49]; oHexes[1, 4].oIntersections[4] = oTempIntersections[50]; oHexes[1, 4].oIntersections[5] = oTempIntersections[51]; oHexes[2, 4].oIntersections[0] = oTempIntersections[45]; oHexes[2, 4].oIntersections[1] = oTempIntersections[44]; oHexes[2, 4].oIntersections[2] = oTempIntersections[43]; oHexes[2, 4].oIntersections[3] = oTempIntersections[51]; oHexes[2, 4].oIntersections[4] = oTempIntersections[52]; oHexes[2, 4].oIntersections[5] = oTempIntersections[53]; #endregion #region Connect Buildings (Old) //oHexes[0, 0].oIntersections[0].oBuilding = oTempBuildings[2]; //oHexes[0, 0].oIntersections[1].oBuilding = oTempBuildings[1]; //oHexes[0, 0].oIntersections[2].oBuilding = oTempBuildings[0]; //oHexes[0, 0].oIntersections[3].oBuilding = oTempBuildings[8]; //oHexes[0, 0].oIntersections[4].oBuilding = oTempBuildings[9]; //oHexes[0, 0].oIntersections[5].oBuilding = oTempBuildings[10]; //oHexes[1, 0].oIntersections[0].oBuilding = oTempBuildings[4]; //oHexes[1, 0].oIntersections[1].oBuilding = oTempBuildings[3]; //oHexes[1, 0].oIntersections[2].oBuilding = oTempBuildings[2]; //oHexes[1, 0].oIntersections[3].oBuilding = oTempBuildings[10]; //oHexes[1, 0].oIntersections[4].oBuilding = oTempBuildings[11]; //oHexes[1, 0].oIntersections[5].oBuilding = oTempBuildings[12]; //oHexes[2, 0].oIntersections[0].oBuilding = oTempBuildings[6]; //oHexes[2, 0].oIntersections[1].oBuilding = oTempBuildings[5]; //oHexes[2, 0].oIntersections[2].oBuilding = oTempBuildings[4]; //oHexes[2, 0].oIntersections[3].oBuilding = oTempBuildings[12]; //oHexes[2, 0].oIntersections[4].oBuilding = oTempBuildings[13]; //oHexes[2, 0].oIntersections[5].oBuilding = oTempBuildings[14]; //oHexes[0, 1].oIntersections[0].oBuilding = oTempBuildings[9]; //oHexes[0, 1].oIntersections[1].oBuilding = oTempBuildings[8]; //oHexes[0, 1].oIntersections[2].oBuilding = oTempBuildings[7]; //oHexes[0, 1].oIntersections[3].oBuilding = oTempBuildings[17]; //oHexes[0, 1].oIntersections[4].oBuilding = oTempBuildings[18]; //oHexes[0, 1].oIntersections[5].oBuilding = oTempBuildings[19]; //oHexes[1, 1].oIntersections[0].oBuilding = oTempBuildings[11]; //oHexes[1, 1].oIntersections[1].oBuilding = oTempBuildings[10]; //oHexes[1, 1].oIntersections[2].oBuilding = oTempBuildings[9]; //oHexes[1, 1].oIntersections[3].oBuilding = oTempBuildings[19]; //oHexes[1, 1].oIntersections[4].oBuilding = oTempBuildings[20]; //oHexes[1, 1].oIntersections[5].oBuilding = oTempBuildings[21]; //oHexes[2, 1].oIntersections[0].oBuilding = oTempBuildings[13]; //oHexes[2, 1].oIntersections[1].oBuilding = oTempBuildings[12]; //oHexes[2, 1].oIntersections[2].oBuilding = oTempBuildings[11]; //oHexes[2, 1].oIntersections[3].oBuilding = oTempBuildings[21]; //oHexes[2, 1].oIntersections[4].oBuilding = oTempBuildings[22]; //oHexes[2, 1].oIntersections[5].oBuilding = oTempBuildings[23]; //oHexes[3, 1].oIntersections[0].oBuilding = oTempBuildings[15]; //oHexes[3, 1].oIntersections[1].oBuilding = oTempBuildings[14]; //oHexes[3, 1].oIntersections[2].oBuilding = oTempBuildings[13]; //oHexes[3, 1].oIntersections[3].oBuilding = oTempBuildings[23]; //oHexes[3, 1].oIntersections[4].oBuilding = oTempBuildings[24]; //oHexes[3, 1].oIntersections[5].oBuilding = oTempBuildings[25]; //oHexes[0, 2].oIntersections[0].oBuilding = oTempBuildings[18]; //oHexes[0, 2].oIntersections[1].oBuilding = oTempBuildings[17]; //oHexes[0, 2].oIntersections[2].oBuilding = oTempBuildings[16]; //oHexes[0, 2].oIntersections[3].oBuilding = oTempBuildings[27]; //oHexes[0, 2].oIntersections[4].oBuilding = oTempBuildings[28]; //oHexes[0, 2].oIntersections[5].oBuilding = oTempBuildings[29]; //oHexes[1, 2].oIntersections[0].oBuilding = oTempBuildings[20]; //oHexes[1, 2].oIntersections[1].oBuilding = oTempBuildings[19]; //oHexes[1, 2].oIntersections[2].oBuilding = oTempBuildings[18]; //oHexes[1, 2].oIntersections[3].oBuilding = oTempBuildings[29]; //oHexes[1, 2].oIntersections[4].oBuilding = oTempBuildings[30]; //oHexes[1, 2].oIntersections[5].oBuilding = oTempBuildings[31]; //oHexes[2, 2].oIntersections[0].oBuilding = oTempBuildings[22]; //oHexes[2, 2].oIntersections[1].oBuilding = oTempBuildings[21]; //oHexes[2, 2].oIntersections[2].oBuilding = oTempBuildings[20]; //oHexes[2, 2].oIntersections[3].oBuilding = oTempBuildings[31]; //oHexes[2, 2].oIntersections[4].oBuilding = oTempBuildings[32]; //oHexes[2, 2].oIntersections[5].oBuilding = oTempBuildings[33]; //oHexes[3, 2].oIntersections[0].oBuilding = oTempBuildings[24]; //oHexes[3, 2].oIntersections[1].oBuilding = oTempBuildings[23]; //oHexes[3, 2].oIntersections[2].oBuilding = oTempBuildings[22]; //oHexes[3, 2].oIntersections[3].oBuilding = oTempBuildings[33]; //oHexes[3, 2].oIntersections[4].oBuilding = oTempBuildings[34]; //oHexes[3, 2].oIntersections[5].oBuilding = oTempBuildings[35]; //oHexes[4, 2].oIntersections[0].oBuilding = oTempBuildings[26]; //oHexes[4, 2].oIntersections[1].oBuilding = oTempBuildings[25]; //oHexes[4, 2].oIntersections[2].oBuilding = oTempBuildings[24]; //oHexes[4, 2].oIntersections[3].oBuilding = oTempBuildings[35]; //oHexes[4, 2].oIntersections[4].oBuilding = oTempBuildings[36]; //oHexes[4, 2].oIntersections[5].oBuilding = oTempBuildings[37]; //oHexes[0, 3].oIntersections[0].oBuilding = oTempBuildings[30]; //oHexes[0, 3].oIntersections[1].oBuilding = oTempBuildings[29]; //oHexes[0, 3].oIntersections[2].oBuilding = oTempBuildings[28]; //oHexes[0, 3].oIntersections[3].oBuilding = oTempBuildings[38]; //oHexes[0, 3].oIntersections[4].oBuilding = oTempBuildings[39]; //oHexes[0, 3].oIntersections[5].oBuilding = oTempBuildings[40]; //oHexes[1, 3].oIntersections[0].oBuilding = oTempBuildings[32]; //oHexes[1, 3].oIntersections[1].oBuilding = oTempBuildings[31]; //oHexes[1, 3].oIntersections[2].oBuilding = oTempBuildings[30]; //oHexes[1, 3].oIntersections[3].oBuilding = oTempBuildings[40]; //oHexes[1, 3].oIntersections[4].oBuilding = oTempBuildings[41]; //oHexes[1, 3].oIntersections[5].oBuilding = oTempBuildings[42]; //oHexes[2, 3].oIntersections[0].oBuilding = oTempBuildings[34]; //oHexes[2, 3].oIntersections[1].oBuilding = oTempBuildings[33]; //oHexes[2, 3].oIntersections[2].oBuilding = oTempBuildings[32]; //oHexes[2, 3].oIntersections[3].oBuilding = oTempBuildings[42]; //oHexes[2, 3].oIntersections[4].oBuilding = oTempBuildings[43]; //oHexes[2, 3].oIntersections[5].oBuilding = oTempBuildings[44]; //oHexes[3, 3].oIntersections[0].oBuilding = oTempBuildings[36]; //oHexes[3, 3].oIntersections[1].oBuilding = oTempBuildings[35]; //oHexes[3, 3].oIntersections[2].oBuilding = oTempBuildings[34]; //oHexes[3, 3].oIntersections[3].oBuilding = oTempBuildings[44]; //oHexes[3, 3].oIntersections[4].oBuilding = oTempBuildings[45]; //oHexes[3, 3].oIntersections[5].oBuilding = oTempBuildings[46]; //oHexes[0, 4].oIntersections[0].oBuilding = oTempBuildings[41]; //oHexes[0, 4].oIntersections[1].oBuilding = oTempBuildings[40]; //oHexes[0, 4].oIntersections[2].oBuilding = oTempBuildings[39]; //oHexes[0, 4].oIntersections[3].oBuilding = oTempBuildings[47]; //oHexes[0, 4].oIntersections[4].oBuilding = oTempBuildings[48]; //oHexes[0, 4].oIntersections[5].oBuilding = oTempBuildings[49]; //oHexes[1, 4].oIntersections[0].oBuilding = oTempBuildings[43]; //oHexes[1, 4].oIntersections[1].oBuilding = oTempBuildings[42]; //oHexes[1, 4].oIntersections[2].oBuilding = oTempBuildings[41]; //oHexes[1, 4].oIntersections[3].oBuilding = oTempBuildings[49]; //oHexes[1, 4].oIntersections[4].oBuilding = oTempBuildings[50]; //oHexes[1, 4].oIntersections[5].oBuilding = oTempBuildings[51]; //oHexes[2, 4].oIntersections[0].oBuilding = oTempBuildings[45]; //oHexes[2, 4].oIntersections[1].oBuilding = oTempBuildings[44]; //oHexes[2, 4].oIntersections[2].oBuilding = oTempBuildings[43]; //oHexes[2, 4].oIntersections[3].oBuilding = oTempBuildings[51]; //oHexes[2, 4].oIntersections[4].oBuilding = oTempBuildings[52]; //oHexes[2, 4].oIntersections[5].oBuilding = oTempBuildings[53]; #endregion #region Connect Nearby Buildings for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { if ((y == 0 || y == 4) && x >= 3) { continue; } else if ((y == 1 || y == 3) && x >= 4) { continue; } oHexes[x, y].oIntersections[0].oNearbyBuildings[1] = oHexes[x, y].oIntersections[5]; oHexes[x, y].oIntersections[0].oNearbyBuildings[2] = oHexes[x, y].oIntersections[1]; oHexes[x, y].oIntersections[1].oNearbyBuildings[1] = oHexes[x, y].oIntersections[0]; oHexes[x, y].oIntersections[1].oNearbyBuildings[2] = oHexes[x, y].oIntersections[2]; oHexes[x, y].oIntersections[2].oNearbyBuildings[0] = oHexes[x, y].oIntersections[1]; oHexes[x, y].oIntersections[2].oNearbyBuildings[1] = oHexes[x, y].oIntersections[3]; oHexes[x, y].oIntersections[3].oNearbyBuildings[0] = oHexes[x, y].oIntersections[2]; oHexes[x, y].oIntersections[3].oNearbyBuildings[1] = oHexes[x, y].oIntersections[4]; oHexes[x, y].oIntersections[4].oNearbyBuildings[0] = oHexes[x, y].oIntersections[5]; oHexes[x, y].oIntersections[4].oNearbyBuildings[2] = oHexes[x, y].oIntersections[3]; oHexes[x, y].oIntersections[5].oNearbyBuildings[0] = oHexes[x, y].oIntersections[0]; oHexes[x, y].oIntersections[5].oNearbyBuildings[2] = oHexes[x, y].oIntersections[4]; } } #endregion #region Connect Nearby Buildings (Old) //for (int y = 0; y < 5; y++) //{ // for (int x = 0; x < 5; x++) // { // if ((y == 0 || y == 4) && x >= 3) // continue; // else if ((y == 1 || y == 3) && x >= 4) // continue; // oHexes[x, y].oIntersections[0].oNearbyBuildings[1] = oHexes[x, y].oIntersections[5].oBuilding; // oHexes[x, y].oIntersections[0].oNearbyBuildings[2] = oHexes[x, y].oIntersections[1].oBuilding; // oHexes[x, y].oIntersections[1].oNearbyBuildings[1] = oHexes[x, y].oIntersections[0].oBuilding; // oHexes[x, y].oIntersections[1].oNearbyBuildings[2] = oHexes[x, y].oIntersections[2].oBuilding; // oHexes[x, y].oIntersections[2].oNearbyBuildings[0] = oHexes[x, y].oIntersections[1].oBuilding; // oHexes[x, y].oIntersections[2].oNearbyBuildings[1] = oHexes[x, y].oIntersections[3].oBuilding; // oHexes[x, y].oIntersections[3].oNearbyBuildings[0] = oHexes[x, y].oIntersections[2].oBuilding; // oHexes[x, y].oIntersections[3].oNearbyBuildings[1] = oHexes[x, y].oIntersections[4].oBuilding; // oHexes[x, y].oIntersections[4].oNearbyBuildings[0] = oHexes[x, y].oIntersections[5].oBuilding; // oHexes[x, y].oIntersections[4].oNearbyBuildings[2] = oHexes[x, y].oIntersections[3].oBuilding; // oHexes[x, y].oIntersections[5].oNearbyBuildings[0] = oHexes[x, y].oIntersections[0].oBuilding; // oHexes[x, y].oIntersections[5].oNearbyBuildings[2] = oHexes[x, y].oIntersections[4].oBuilding; // if (x != 0) // { // oHexes[x - 1, y].oIntersections[0].oNearbyBuildings[0] = oHexes[x, y].oIntersections[1].oBuilding; // oHexes[x, y].oIntersections[2].oNearbyBuildings[2] = oHexes[x - 1, y].oIntersections[1].oBuilding; // oHexes[x - 1, y].oIntersections[5].oNearbyBuildings[1] = oHexes[x, y].oIntersections[4].oBuilding; // oHexes[x, y].oIntersections[3].oNearbyBuildings[2] = oHexes[x - 1, y].oIntersections[4].oBuilding; // } // if (y < 2) // { // oHexes[x, y].oIntersections[3].oNearbyBuildings[2] = oHexes[x, y + 1].oIntersections[2].oBuilding; // oHexes[x, y + 1].oIntersections[1].oNearbyBuildings[0] = oHexes[x, y].oIntersections[2].oBuilding; // oHexes[x, y].oIntersections[4].oNearbyBuildings[1] = oHexes[x, y + 1].oIntersections[5].oBuilding; // oHexes[x, y + 1].oIntersections[0].oNearbyBuildings[0] = oHexes[x, y].oIntersections[5].oBuilding; // if ((x == 2 && y == 0) || (x == 3 && y == 1)) // { // oHexes[x, y].oIntersections[5].oNearbyBuildings[1] = oHexes[x + 1, y + 1].oIntersections[0].oBuilding; // oHexes[x + 1, y + 1].oIntersections[1].oNearbyBuildings[0] = oHexes[x, y].oIntersections[0].oBuilding; // } // } // else if (y > 2) // { // oHexes[x, y].oIntersections[1].oNearbyBuildings[0] = oHexes[x + 1, y - 1].oIntersections[2].oBuilding; // oHexes[x + 1, y - 1].oIntersections[3].oNearbyBuildings[2] = oHexes[x, y].oIntersections[2].oBuilding; // oHexes[x, y].oIntersections[0].oNearbyBuildings[0] = oHexes[x + 1, y - 1].oIntersections[5].oBuilding; // oHexes[x + 1, y - 1].oIntersections[4].oNearbyBuildings[1] = oHexes[x, y].oIntersections[5].oBuilding; // if (x == 0) // { // oHexes[x, y].oIntersections[2].oNearbyBuildings[2] = oHexes[x, y - 1].oIntersections[3].oBuilding; // oHexes[x, y - 1].oIntersections[4].oNearbyBuildings[1] = oHexes[x, y].oIntersections[3].oBuilding; // } // } // } //} //for (int y = 0; y < 2; y++) //{ // for (int x = 0; x < 5; x++) // { // if ((y == 0 || y == 4) && x >= 3) // continue; // else if ((y == 1 || y == 3) && x >= 4) // continue; // if (x == 0) // { // oHexes[x, y].oIntersections[3].oNearbyBuildings[2] = oHexes[x, y + 1].oIntersections[1].oNearbyBuildings[2]; // oHexes[x, y + 1].oIntersections[1].oNearbyBuildings[0] = oHexes[x, y].oIntersections[3].oNearbyBuildings[0]; // oHexes[x, y].oIntersections[4].oNearbyBuildings[1] = oHexes[x, y + 1].oIntersections[0].oNearbyBuildings[1]; // oHexes[x, y + 1].oIntersections[0].oNearbyBuildings[0] = oHexes[x, y].oIntersections[4].oNearbyBuildings[0]; // } // } //} #endregion #region Connect Nearby Roads for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { if (oHexes[x, y] != null) { int nStartingID; // the first id to be used for a row int nOffset; // offset between the first id on top of a hex and below for each row int[] nOffset2 = new int[5] { 12, 15, 16, 14, 10 }; // starting id for each row if (y == 0) { nStartingID = 0; } else if (y == 1) { nStartingID = 10; } else if (y == 2) { nStartingID = 23; } else if (y == 3) { nStartingID = 40; } else { nStartingID = 55; } // building id offset for each row if (y == 0) { nOffset = 12; } else if (y == 1) { nOffset = 15; } else if (y == 2) { nOffset = 16; } else if (y == 3) { nOffset = 14; } else { nOffset = 11; } oHexes[x, y].oIntersections[2].oNearbyRoads[1] = oTempRoads[nStartingID + (x * 3)]; oHexes[x, y].oIntersections[2].oNearbyRoads[0] = oTempRoads[nStartingID + 1 + (x * 3)]; oHexes[x, y].oIntersections[1].oNearbyRoads[2] = oTempRoads[nStartingID + 1 + (x * 3)]; oHexes[x, y].oIntersections[1].oNearbyRoads[1] = oTempRoads[nStartingID + 2 + (x * 3)]; oHexes[x, y].oIntersections[0].oNearbyRoads[2] = oTempRoads[nStartingID + 2 + (x * 3)]; oHexes[x, y].oIntersections[0].oNearbyRoads[1] = oTempRoads[nStartingID + 3 + (x * 3)]; oHexes[x, y].oIntersections[5].oNearbyRoads[0] = oTempRoads[nStartingID + 3 + (x * 3)]; oHexes[x, y].oIntersections[5].oNearbyRoads[2] = oTempRoads[nStartingID + nOffset + 2 + (x * 3)]; oHexes[x, y].oIntersections[4].oNearbyRoads[0] = oTempRoads[nStartingID + nOffset + 2 + (x * 3)]; oHexes[x, y].oIntersections[4].oNearbyRoads[2] = oTempRoads[nStartingID + nOffset + (x * 3)]; oHexes[x, y].oIntersections[3].oNearbyRoads[1] = oTempRoads[nStartingID + nOffset + (x * 3)]; oHexes[x, y].oIntersections[3].oNearbyRoads[0] = oTempRoads[nStartingID + (x * 3)]; if ((y == 0 && x > 0) || // left (y == 1 && x > 0) || (y == 2 && x > 0) || (y > 2)) { oHexes[x, y].oIntersections[2].oNearbyRoads[2] = oTempRoads[nStartingID - 1 + (x * 3)]; } if (y > 0) // top left { oHexes[x, y].oIntersections[1].oNearbyRoads[0] = oTempRoads[nStartingID - nOffset2[y - 1] + 2 + (x * 3)]; } if ((y == 0 && x < 2) || // top right (y == 1 && x < 3) || (y == 2 && x < 4) || (y > 2)) { oHexes[x, y].oIntersections[0].oNearbyRoads[0] = oTempRoads[nStartingID + 4 + (x * 3)]; } if ((y < 2) || // right (y == 2 && x < 4) || (y == 3 && x < 3) || (y == 4 && x < 2)) { oHexes[x, y].oIntersections[5].oNearbyRoads[1] = oTempRoads[nStartingID + nOffset + 3 + (x * 3)]; } if (y < 4) // bottom right { oHexes[x, y].oIntersections[4].oNearbyRoads[1] = oTempRoads[nStartingID + nOffset + 1 + (x * 3)]; } if ((y < 2) || // bottom left (y == 2 && x > 0) || (y == 3 && x > 0) || (y == 4 && x > 0)) { oHexes[x, y].oIntersections[3].oNearbyRoads[2] = oTempRoads[nStartingID + nOffset - 1 + (x * 3)]; } } } } #endregion #region Create Intersections for (int y = 0; y < 5; y++) { for (int x = 4; x > -1; x--) { if (oHexes[x, y] != null) { oHexes[x, y].CreateIntersections(); for (int z = 0; z < 6; z++) { oHexes[x, y].oIntersections[z].PositionStructures(z); } } } } #endregion #region Create Ports int[] nHexEdges = { 0, 1, 2, 3, 4, 5, 6, 14, 15, 25, 26, 37, 36, 46, 45, 53, 52, 51, 50, 49, 48, 47, 39, 38, 28, 27, 16, 17, 7, 8 }; int[] nPortCount = { 1, 1, 1, 1, 1, 4 }; int nPosition = rand.Next() % 6; int nPortType; do { nPosition += 3; if (nPosition > (nHexEdges.Count() - 1)) { nPosition = nPosition - (nHexEdges.Count() - 1); } do { nPortType = rand.Next() % 6; }while (nPortCount[nPortType] == 0); nPortCount[nPortType]--; oTempIntersections[nHexEdges[nPosition]].nPortType = nPortType; if (nPosition + 1 > (nHexEdges.Count() - 1)) { nPosition = 0; } oTempIntersections[nHexEdges[nPosition + 1]].nPortType = nPortType; }while ((nPortCount[0] + nPortCount[1] + nPortCount[2] + nPortCount[3] + nPortCount[4] + nPortCount[5]) > 0); for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { if (oHexes[x, y] != null) { oHexes[x, y].PositionPorts(); } } } #endregion #region Count Used Roads // for (int y = 0; y < 5; y++) // { // for (int x = 0; x < 5; x++) // { // if (oHexes[x, y] != null) // { // for (int z = 0; z < 6; z++) // { // for (int a = 0; a < 3; a++) // { // if (oHexes[x, y].oIntersections[z].oNearbyRoads[a] != null) // { // oHexes[x, y].oIntersections[z].oNear // //oTempIntersections[nHexEdges[nPosition]].Visible = true; //byRoads[a].nUsed++; // oHexes[x, y].oIntersections[ //z].oNearbyRoads[a].Label = "" + oHexes[x, y].oIntersections[z].oNearbyRoads[a].nUsed; // } // } // } // } // } // } #endregion #region Count Used Buildings //for (int y = 0; y < 5; y++) //{ // for (int x = 0; x < 5; x++) // { // if (oHexes[x, y] != null) // { // for (int z = 0; z < 6; z++) // { // for (int a = 0; a < 3; a++) // { // if (oHexes[x, y].oIntersections[z].oNearbyBuildings[a] != null) // { // oHexes[x, y].oIntersections[z].oNearbyBuildings[a].nUsed++; // oHexes[x, y].oIntersections[z].oNearbyBuildings[a].Label = "" + oHexes[x, y].oIntersections[z].oNearbyBuildings[a].nUsed; // } // } // } // } // } //} //for (int y = 0; y < 5; y++) //{ // for (int x = 0; x < 5; x++) // { // if (oHexes[x, y] != null) // { // for (int z = 0; z < 6; z++) // { // for (int a = 0; a < 3; a++) // { // if (oHexes[x, y].oIntersections[z].oNearbyBuildings[a] != null) // oHexes[x, y].oIntersections[z].oNearbyBuildings[a].nUsed = 0; // } // } // } // } //} #endregion #region Delete Unused Roads oTempRoads[67].RemoveFromAutoDrawSet(); oTempRoads[70].RemoveFromAutoDrawSet(); oTempRoads[73].RemoveFromAutoDrawSet(); #endregion // test data oHexes[1, 3].oIntersections[1].nOwner = 0; oHexes[1, 1].oIntersections[2].nOwner = 0; oHexes[1, 2].oIntersections[3].nOwner = 0; oHexes[1, 3].oIntersections[1].eState = Intersection.STATE.SETTLEMENT; oHexes[1, 1].oIntersections[2].eState = Intersection.STATE.SETTLEMENT; oHexes[1, 2].oIntersections[3].eState = Intersection.STATE.SETTLEMENT; oHexes[1, 3].oIntersections[1].Visible = true; oHexes[1, 1].oIntersections[2].Visible = true; oHexes[1, 2].oIntersections[3].Visible = true; oRobber = new Robber(oRobberStartingLocation, oRobberStartingHex); oHUD = new HUD(oStats); oHUD.ShowCards(oStats.oPlayers[0].nCards, oCamera); //oChatMenu = new ChatMenu(oCamera); }
public void Update(Cursor oCursor, Camera oCamera, Stats oStats, Hex[,] oHexes, Robber oRobber) { Random oRandom = new Random(); oKeyState = Keyboard.GetState(); //XNACS1Base.EchoToTopStatus("HUD:" + oPickedUpCard); #region Year of Plenty Menu (test) (F3) if (oYearOfPlentymenu == null && oKeyState.IsKeyDown(Keys.F3)) { oYearOfPlentymenu = new YearOfPlentyMenu(); RedrawCards(oStats, oCamera); } if (oYearOfPlentymenu != null) { oYearOfPlentymenu.Update(oCursor, oCamera, this, oStats.oPlayers[0]); if (oYearOfPlentymenu.bFinished == true) { oYearOfPlentymenu.Clear(); oYearOfPlentymenu = null; } } #endregion #region Monopoly Menu (test) (F4) if (oMonopolyMenu == null && oKeyState.IsKeyDown(Keys.F4)) { oMonopolyMenu = new MonopolyMenu(); RedrawCards(oStats, oCamera); } if (oMonopolyMenu != null) { oMonopolyMenu.Update(oCursor, oCamera, this, oStats.oPlayers); if (oMonopolyMenu.bFinished == true) { oMonopolyMenu.Clear(); oMonopolyMenu = null; } } #endregion #region Road Building Menu (test) (F5) if (oRoadBuildingMenu == null && oKeyState.IsKeyDown(Keys.F5)) { oRoadBuildingMenu = new RoadBuildingMenu(); RedrawCards(oStats, oCamera); } if (oRoadBuildingMenu != null) { oRoadBuildingMenu.Update(oCursor, oCamera, this, oStats.oPlayers); if (oRoadBuildingMenu.bFinished == true) { oRoadBuildingMenu.Clear(); oRoadBuildingMenu = null; } } #endregion #region Knight Menu (test) (F6) if (oKnightMenu == null && oKeyState.IsKeyDown(Keys.F6)) { oKnightMenu = new KnightMenu(); RedrawCards(oStats, oCamera); } if (oKnightMenu != null) { oKnightMenu.Update(oCursor, oCamera, this, oStats.oPlayers, oRobber); if (oKnightMenu.bFinished == true) { oKnightMenu.Clear(); oKnightMenu = null; } } #endregion #region Statistics Menues (F7-F9) // button press if (MenuState == eMenuState.NONE) { if (oKeyState.IsKeyDown(Keys.F7)) { MenuState = eMenuState.TURN_RECORDS; } else if (oKeyState.IsKeyDown(Keys.F8)) { MenuState = eMenuState.RESOURCE_GRAPHS; } else if (oKeyState.IsKeyDown(Keys.F9)) { MenuState = eMenuState.TABLE; } } // update if (oStatisticsMenu1 != null) { eMenuState oCurrent = oStatisticsMenu1.Update(oCamera, oCursor); if (oCurrent != eMenuState.NO_CHANGE) { oStatisticsMenu1.Clear(); oStatisticsMenu1 = null; MenuState = oCurrent; } } else if (oStatisticsMenu2 != null) { eMenuState oCurrent = oStatisticsMenu2.Update(oCamera, oCursor); if (oCurrent != eMenuState.NO_CHANGE) { oStatisticsMenu2.Clear(); oStatisticsMenu2 = null; MenuState = oCurrent; } } else if (oStatisticsMenu3 != null) { eMenuState oCurrent = oStatisticsMenu3.Update(oCamera, oCursor); if (oCurrent != eMenuState.NO_CHANGE) { oStatisticsMenu3.Clear(); oStatisticsMenu3 = null; MenuState = oCurrent; } } // create if (MenuState == eMenuState.TURN_RECORDS && oStatisticsMenu1 == null) { oStatisticsMenu1 = new StatisticsMenu1(oStats, oCamera); } else if (MenuState == eMenuState.RESOURCE_GRAPHS && oStatisticsMenu2 == null) { oStatisticsMenu2 = new StatisticsMenu2(oStats, oCamera); } else if (MenuState == eMenuState.TABLE && oStatisticsMenu3 == null) { oStatisticsMenu3 = new StatisticsMenu3(oStats, oCamera); } #endregion #region HUD Follow Camera // hud this.Center = oCamera.oCenter + oHUDDisplacement; // cards for (int x = 0; x < oCards.Count(); x++) { for (int y = 0; y < oCards[x].Count(); y++) { oCards[x][y].Center = oCardDisplacements[x][y] + oCamera.oCenter; } } // buttons for (int x = 0; x < oButtons.Count(); x++) { oButtons[x].Center = oButtonDisplacement[x] + oCamera.oCenter; } #endregion #region Update Small HUDs for (int x = 0; x < oSmallHUDs.Count(); x++) { oSmallHUDs[x].Update(oCamera, oCursor, oStats, this); oSmallHUDs[x].nScores[0] = oStats.oPlayers[x + 1].nVictoryPoints; oSmallHUDs[x].nScores[1] = oStats.oPlayers[x + 1].nArmyCount; oSmallHUDs[x].nScores[2] = oStats.oPlayers[x + 1].nLongestRoad; oSmallHUDs[x].nScores[3] = oStats.oPlayers[x + 1].nDevelopmentCardCount; oSmallHUDs[x].nScores[4] = oStats.oPlayers[x + 1].nResourceCardCount; } #endregion #region Road Button (Left Click), Cancel Building (Right Click) if (oCursor.LeftClick() == true && oButtons[0].Collided(oCursor.oHitbox)) { XNACS1Base.PlayACue("ButtonClick"); if (oStats.oPlayers[oStats.nCurrentPlayer].CanBuildRoad() || oStats.oPlayers[oStats.nCurrentPlayer].nFreeRoads > 0) { oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.ROAD; ChangeSelectedButton(oStats); } } else if (oCursor.RightClick()) { oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.NONE; ChangeSelectedButton(oStats); } #endregion #region Settlement Button Click if (oCursor.LeftClick() == true && oButtons[1].Collided(oCursor.oHitbox)) { XNACS1Base.PlayACue("ButtonClick"); if (oStats.oPlayers[oStats.nCurrentPlayer].CanBuildSettlement()) { oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.SETTLEMENT; ChangeSelectedButton(oStats); } } #endregion #region City Button Click if (oCursor.LeftClick() == true && oButtons[2].Collided(oCursor.oHitbox)) { XNACS1Base.PlayACue("ButtonClick"); if (oStats.oPlayers[oStats.nCurrentPlayer].CanBuildCity()) { oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.CITY; ChangeSelectedButton(oStats); } } #endregion #region Development Card Button Click if (oCursor.LeftClick() == true && oButtons[3].Collided(oCursor.oHitbox)) { XNACS1Base.PlayACue("ButtonClick"); if (oStats.oPlayers[oStats.nCurrentPlayer].CanGetDevelopment(oStats.nResourceCardsLeft)) { oStats.oPlayers[oStats.nCurrentPlayer].GetDevelopment(oStats.nResourceCardsLeft, this); oStats.oPlayers[oStats.nCurrentPlayer].eCurrentlyBuilding = Player.CurrentlyBuilding.NONE; ChangeSelectedButton(oStats); ShowCards(oStats.oPlayers[oStats.nCurrentPlayer].nCards, oCamera); } } #endregion #region Dice Button Click if (oCursor.LeftClick() == true && oButtons[4].Collided(oCursor.oHitbox) && bRollMade == false) { XNACS1Base.PlayACue("ButtonClick"); oButtons[4].TextureTintColor = oUnselectedColor; //bRollMade = true; int nRoll1 = oRandom.Next() % 6 + 1; int nRoll2 = oRandom.Next() % 6 + 1; nCurrentRoll = nRoll1 + nRoll2; oDice[0].SetTextureSpriteAnimationFrames(nRoll1, 0, nRoll1, 0, 1, SpriteSheetAnimationMode.AnimateForward); oDice[1].SetTextureSpriteAnimationFrames(nRoll2, 1, nRoll2, 1, 1, SpriteSheetAnimationMode.AnimateForward); oStats.AddRollRecord(nCurrentRoll - 2); if (nCurrentRoll == 7 && bRobberEnabled == true) { oRobber.ShowMessage(); oRobber.bMoveRobber = true; oStats.oPlayers[0].UpdateCardCount(); if (oStats.oPlayers[0].nResourceCardCount > 7) { oRobberMenu = new RobberMenu(oStats.oPlayers[0].nResourceCardCount); RedrawCards(oStats, oCamera); } } int[] nResourceRecord = new int[22]; nResourceRecord[20] = nCurrentRoll; nResourceRecord[21] = oStats.nCurrentTurn; for (int x = 0; x < 5; x++) // give resources to players { for (int y = 0; y < 5; y++) { if (oHexes[x, y] != null) { oHexes[x, y].GiveResources(nCurrentRoll, oStats, nResourceRecord); } } } oStats.AddTurnRecord(nResourceRecord); ShowCards(oStats.oPlayers[0].nCards, oCamera); } #endregion #region Trade Button Click if (oCursor.LeftClick() == true && oButtons[5].Collided(oCursor.oHitbox)) { XNACS1Base.PlayACue("ButtonClick"); oTradeMenu = new TradeMenu(); RedrawCards(oStats, oCamera); } #endregion #region End Turn Button Click if (CanEndTurn(oRobber)) { oButtons[6].TextureTintColor = oOriginalColor; if (oCursor.LeftClick() == true && oButtons[6].Collided(oCursor.oHitbox) && bRollMade == true) { XNACS1Base.PlayACue("ButtonClick"); oButtons[4].TextureTintColor = oOriginalColor; bRollMade = false; oStats.PassTurn(); oTurnNumber.Label = "" + oStats.nCurrentTurn; oCurrentPlayer.Label = "" + oStats.oPlayers[oStats.nCurrentPlayer].sName; } } else { oButtons[6].TextureTintColor = oUnselectedColor; } #endregion #region Trade Menu if (oTradeMenu != null) { oTradeMenu.Update(oCamera, oCursor, this, oStats); if (oTradeMenu.bFinished == true) { oTradeMenu.Clear(); oTradeMenu = null; } } #endregion #region Robber Menu if (oRobberMenu != null) { oRobberMenu.Update(oCamera, oCursor, this); if (oRobberMenu.bFinished == true) { oRobberMenu.Clear(); oRobberMenu = null; } } #endregion #region Pick Up Card/Card Follow Cursor // move picked up card if (oPickedUpCard != null) { oPickedUpCard.Center = oCursor.oHitbox.Center; if (oCursor.IsLeftMouseDown() == false) { if (oTradeMenu != null && oCursor.oHitbox.Collided(oTradeMenu) || oRobberMenu != null && oCursor.oHitbox.Collided(oRobberMenu)) { oStats.oPlayers[0].nCards[nPickedUpCard]--; } oPickedUpCard = null; nPickedUpCard = -1; ShowCards(oStats.oPlayers[0].nCards, oCamera); } } // pick up the card if (oCursor.LeftClick() == true && oPickedUpCard == null) { for (int x = 0; x < oCards.Count(); x++) { if (oCards[x].Count > 0 && oCursor.oHitbox.Collided(oCards[x][oCards[x].Count - 1]) == true) { oPickedUpCard = oCards[x][oCards[x].Count - 1]; nPickedUpCard = x; if (oPickedUpCard.Visible == false) { oPickedUpCard.Visible = true; oCards[x][0].Label = "" + (oCards[x].Count - 1); } } } } #endregion for (int x = 0; x < oDice.Count(); x++) { oDice[x].Center = oCamera.oCenter + oDiceDisplacement[x]; } oTurnNumber.Center = oCamera.oCenter + oTurnNumberDisplacement; oCurrentPlayer.Center = oCamera.oCenter + oCurrentPlayerDisplacement; }
public void Update(Cursor oCursor, Camera oCamera, HUD oHUD, Player[] oPlayers, Robber oRobber) { if (eState == State.MENU) { #region Accept Button if (oCursor.LeftClick()) { if (oButtons[0].Collided(oCursor.oHitbox)) { //bFinished = true; Hide(); oRobber.bMoveRobber = true; oPlayers[0].eCurrentlyBuilding = Player.CurrentlyBuilding.ROAD_BUILDING; eState = State.MOVING_ROBBER; oMessage = new XNACS1Rectangle(new Vector2(), fMessageWidth, fMessageHeight); oMessage.Color = new Color(0, 0, 0, 150); oMessage.Label = "Move the robber"; oMessage.LabelColor = Color.White; } } #endregion #region Cancel Button if (oCursor.LeftClick()) { if (oCursor.oHitbox.Collided(oButtons[1])) { bFinished = true; } } #endregion } else if (eState == State.MOVING_ROBBER) { if (oRobber.bMoveRobber == false && oRobber.bPickedUp == false) { oMessage.Label = "Rob a player"; eState = State.ROBBING_PLAYER; } } else if (eState == State.ROBBING_PLAYER) { if (oPlayers[0].bCanBeRobbed == false && oPlayers[1].bCanBeRobbed == false && oPlayers[2].bCanBeRobbed == false && oPlayers[3].bCanBeRobbed == false) { bFinished = true; } } AlignWithCamera(oCamera); }