private void OnCheck(PSide side, ChessGame.EndGames endType) { // Display pop-up message "Check !" _popupText.text = (side == PSide.Black ? "Black" : "White") + " is checked!"; _popupText.gameObject.SetActive(true); _popupBehavior.StartPhaseOut(); }
} //game constructor public void ResetBoard() //set/reset board { active = true; //reset game fields selectedpiece = null; ischecked = new bool[2]; turn = PSide.White; turn_count = 1; //reset board PieceList.Clear(); TakenList.Clear(); Gameboard = new Peice[8, 8] { { new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Rook, PSide.Black, this), }, { new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Knight, PSide.Black, this), }, { new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Bishop, PSide.Black, this), }, { new Peice(PType.Queen, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Queen, PSide.Black, this), }, { new Peice(PType.King, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.King, PSide.Black, this), }, { new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Bishop, PSide.Black, this), }, { new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Knight, PSide.Black, this), }, { new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Rook, PSide.Black, this), }, }; //prepare moves for 1st turn foreach (Peice peice in getPeices(Gameboard, PSide.White)) { peice.UpdateMoves(); } }
//returns the proper world rotation for an object private Quaternion getWorldRot(Vector3 worldPos, Quaternion surfRot, PSide side) { //initial rotation to match side(as if placing it on the side of a cube) Quaternion startRot; //the axis that the start rot will be rotated from to align with the vector from the origin to the object's position //top is standard side so y rotation in surfrot cooresponds to spinning left or right Vector3 fromRot; //NOTE: Euler rotation order is important, and unity does x, y, then z rotation switch (side) { case PSide.TOP: fromRot = Vector3.up; startRot = Quaternion.Euler(0, 0, 0); //final! break; case PSide.BOTTOM: fromRot = Vector3.down; startRot = Quaternion.Euler(180, 0, 0); break; case PSide.RIGHT: fromRot = Vector3.right; startRot = Quaternion.Euler(-90, -90, 0); //could be any other combination of 90 idk break; case PSide.LEFT: fromRot = Vector3.left; startRot = Quaternion.Euler(-90, 90, 0); //could be any other combination of 90 idk break; case PSide.FRONT: fromRot = Vector3.forward; startRot = Quaternion.Euler(-90, 180, 0); //WHAT ORDER DO THE COMPONENTS ROTATE IN?, oh got it(refer to comment above) break; case PSide.BACK: fromRot = Vector3.back; startRot = Quaternion.Euler(-90, 0, 0); break; default: //will never happen hopefully.......,......wwww fromRot = Vector3.zero; startRot = Quaternion.Euler(0, 0, 0); break; } //rotation from the normal of the side to the normal of the surface //think of it like sticking a squerer in the object at a 90 degree angle and then aligning that squerer with //the vector that stretches from the origin through the object's position Quaternion sphereRot = Quaternion.FromToRotation(fromRot, worldPos); //multiplying Quaternions adds the rotations to each other and order matters //to figure out the order, i used trial and error but should probably figure out what the order means //basically, this rotates the object how it would be in a standard 3d system(surfRot), then //rotates it 90 or 180 degress to properly align with its side as if it were on the surface of a cube, then //rotates it from the normal of its cube side to the normal of the part of the planet it is on return(sphereRot * startRot * surfRot); }
public float u, v; //grid point on that side public SurfacePos(PSide s, float upos, float vpos) { side = s; u = upos; v = vpos; x = y = 0; //remove later }
private void OnEndGame(PSide side, ChessGame.EndGames endType) { // Display message accordingly to end type switch (endType) { case ChessGame.EndGames.Checkmate: _popupText.text = (side == PSide.Black ? "Black" : "White") + " is mated!"; GetPieceGameObject(ChessGame.getKing(_currentGame.Gameboard, side)).GetComponent <Animator>().SetTrigger("Mated"); break; case ChessGame.EndGames.Draw: _popupText.text = "Players agreed to a draw!"; break; case ChessGame.EndGames.Stalemate: _popupText.text = "It's a stalemate!"; break; default: _popupText.text = "This shouldn't happen. WTF man..."; break; } _popupText.gameObject.SetActive(true); _popupBehavior.StartPhaseOut(); }
internal static List<Peice> getPeices(Peice[,] board, PSide side) { List<Peice> sideList = new List<Peice>(); foreach (Peice peice in board) { if (peice != null && peice.MySide == side) { sideList.Add(peice); } } return sideList; }
internal static PSide altSide(PSide side) { if (side == PSide.White) { return(PSide.Black); } else { return(PSide.White); } }
internal static Point getKing(Peice[,] board, PSide side) { for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { if (board[x, y] != null && board[x, y].MySide == side && board[x, y].MyType == Peices.PType.King) { return new Point(x, y); } } } throw new Exception("Searched for king on board for " + side.ToString() + " side, not present"); }
internal static List <Peice> getPeices(Peice[,] board, PSide side) { List <Peice> sideList = new List <Peice>(); foreach (Peice peice in board) { if (peice != null && peice.MySide == side) { sideList.Add(peice); } } return(sideList); }
internal static Point getKing(Peice[,] board, PSide side) { for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { if (board[x, y] != null && board[x, y].MySide == side && board[x, y].MyType == Peices.PType.King) { return(new Point(x, y)); } } } throw new Exception("Searched for king on board for " + side.ToString() + " side, not present"); }
public void OnEndGame(PSide side, ChessGame.EndGames endType) { PlaySound(Sounds.endgame); switch (endType) { case (ChessGame.EndGames.Checkmate): { MessageBox.Show(null, side.ToString() + " has been checkmated!", "Game over", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } case (ChessGame.EndGames.Draw): { MessageBox.Show(null, "Game drawn, 50/50", "Game over", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } case (ChessGame.EndGames.Stalemate): { MessageBox.Show(null, "StaleMate, 50/50", "Game over", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } btn_reset.Enabled = true; }
//returns the mid unit from midTUs at index u,v and creates one if necessary private TransportUnit buildMid(int i, int j, PSide side) { TransportUnit mu = null; SurfaceUnit su = new SurfaceUnit(side, i, j); //Debug.Log(su); if (!midTUs.TryGetValue(su, out mu)) { mu = new TransportUnit(); mu.indexI = i; mu.indexJ = j; midTUs.Add(su, mu); indexList.Add(mu); } return(mu); }
public void Taken_Paint(PaintEventArgs e, PSide mySide) { Graphics g = e.Graphics; int count_y = 0; int count_x = 0; foreach (Peice peice in myGame.TakenList) { if (peice.MySide == mySide) { g.DrawImage(peice_images[(int)peice.MySide, (int)peice.MyType], new Point(count_x * 55, count_y * 55)); count_y++; if (count_y > 8) { count_y = 0; count_x++; } } } }
} //Draw game public bool MakeMove(Point toPoint) { if (selectedpiece == null) { return(false); } if (selectedpiece.myMoves.Any(mov => mov.movPoint == toPoint)) //Is selected move for peice valid? { bool activemove = false; //Move from chosen point Move mov = GetMove(toPoint).Value; //Move piece Peice lastoccup; if (mov.moveType == MoveTypes.enpass) { lastoccup = GetPeice(mov.ensidePoint); } else { lastoccup = Gameboard[toPoint.X, toPoint.Y]; } movePeice(Gameboard, selectedpiece.MyLocation, mov); //Transform pawn if (selectedpiece.MyType == PType.Pawn) { activemove = true; if (PAWNTRANFORM && (int)altSide(turn) * 7 == toPoint.Y) { selectedpiece.ChangeType(GetPieceTransform()); } } //Move events if (OnPieceMove != null) { OnPieceMove(new Tuple <Peice, Point>(selectedpiece, toPoint)); } //Take events if (lastoccup != null) { PieceList.Remove(lastoccup); TakenList.Add(lastoccup); activemove = true; if (OnPieceTaken != null) { OnPieceTaken(lastoccup); } } //Aftermove update for piece selectedpiece.AfterMove(); //Update inactive move counter if (!activemove) { inactive_count++; } else { inactive_count = 0; } } else { return(false); } turn_count++; ischecked = new bool[2]; inattacksquares[(int)turn].Clear(); //Update for next turn, calculate possible moves turn = altSide(turn); int movecount = 0; foreach (Peice peice in getPeices(Gameboard, turn)) { movecount += peice.UpdateMoves(); } //Display endgame messege if (ischecked[(int)turn] && movecount != 0) //Checked { if (OnCheck != null) { OnCheck(turn, EndGames.Check); } } else if (ischecked[(int)turn] && movecount == 0) //Chekmated { if (OnEndGame != null) { OnEndGame(turn, EndGames.Checkmate); } ; active = false; } else if (!ischecked[(int)turn] && movecount == 0) //Stalemated { if (OnEndGame != null) { OnEndGame(turn, EndGames.Stalemate); } active = false; } //Game continues for next turn selectedpiece = null; return(true); } //Play turn, move to point
public bool IsInCheck(PSide side) { return(ischecked[(int)side]); }
} //Draw game public bool MakeMove(Point toPoint) { if (selectedpiece == null) { return false; } if (selectedpiece.myMoves.Any(mov => mov.movPoint == toPoint)) //Is selected move for peice valid? { bool activemove = false; //Move from chosen point Move mov = GetMove(toPoint).Value; //Move piece Peice lastoccup; if (mov.moveType == MoveTypes.enpass) { lastoccup = GetPeice(mov.ensidePoint); } else { lastoccup = Gameboard[toPoint.X, toPoint.Y]; } movePeice(Gameboard, selectedpiece.MyLocation, mov); //Transform pawn if (selectedpiece.MyType == PType.Pawn) { activemove = true; if (PAWNTRANFORM && (int)altSide(turn) * 7 == toPoint.Y) { selectedpiece.ChangeType(GetPieceTransform()); } } //Move events if (OnPieceMove != null) { OnPieceMove(new Tuple<Peice, Point>(selectedpiece, toPoint)); } //Take events if (lastoccup != null) { PieceList.Remove(lastoccup); TakenList.Add(lastoccup); activemove = true; if (OnPieceTaken != null) { OnPieceTaken(lastoccup); } } //Aftermove update for piece selectedpiece.AfterMove(); //Update inactive move counter if (!activemove) { inactive_count++; } else { inactive_count = 0; } } else { return false; } turn_count++; ischecked = new bool[2]; inattacksquares[(int)turn].Clear(); //Update for next turn, calculate possible moves turn = altSide(turn); int movecount = 0; foreach (Peice peice in getPeices(Gameboard, turn)) { movecount += peice.UpdateMoves(); } //Display endgame messege if (ischecked[(int)turn] && movecount != 0) //Checked { if (OnCheck != null) { OnCheck(turn, EndGames.Check); } } else if (ischecked[(int)turn] && movecount == 0) //Chekmated { if (OnEndGame != null) { OnEndGame(turn, EndGames.Checkmate); }; active = false; } else if (!ischecked[(int)turn] && movecount == 0) //Stalemated { if (OnEndGame != null) { OnEndGame(turn, EndGames.Stalemate); } active = false; } //Game continues for next turn selectedpiece = null; return true; } //Play turn, move to point
internal static PSide altSide(PSide side) { if (side == PSide.White) { return PSide.Black; } else { return PSide.White; } }
public void OnEndGame(PSide side, ChessGame.EndGames endType) { PlaySound(Sounds.endgame); switch(endType) { case (ChessGame.EndGames.Checkmate): { MessageBox.Show(null, side.ToString() + " has been checkmated!", "Game over", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } case (ChessGame.EndGames.Draw): { MessageBox.Show(null, "Game drawn, 50/50", "Game over", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } case (ChessGame.EndGames.Stalemate): { MessageBox.Show(null, "StaleMate, 50/50", "Game over", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } } btn_reset.Enabled = true; }
} //game constructor public void ResetBoard() //set/reset board { active = true; //reset game fields selectedpiece = null; ischecked = new bool[2]; turn = PSide.White; turn_count = 1; //reset board PieceList.Clear(); TakenList.Clear(); if (!is960) { Gameboard = new Peice[8, 8] { { new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Rook, PSide.Black, this), }, { new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Knight, PSide.Black, this), }, { new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Bishop, PSide.Black, this), }, { new Peice(PType.Queen, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Queen, PSide.Black, this), }, { new Peice(PType.King, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.King, PSide.Black, this), }, { new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Bishop, PSide.Black, this), }, { new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Knight, PSide.Black, this), }, { new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(PType.Rook, PSide.Black, this), }, }; } //if it is 960 else { //get our types in an array to swap in PType[] pTypes = { PType.Rook, PType.Knight, PType.Bishop, PType.Queen, PType.King, PType.Bishop, PType.Knight, PType.Rook };; Random rng = new Random(); //randomly swap places int rand = rng.Next(960); for (int i = 0; i < rand; i++) { int first = rng.Next(7); int second = rng.Next(7); //first PType p1 = pTypes[first]; //second PType p2 = pTypes[second]; //swap pTypes[first] = p2; pTypes[second] = p1; } Gameboard = new Peice[8, 8] { { new Peice(pTypes[0], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[0], PSide.Black, this), }, { new Peice(pTypes[1], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[1], PSide.Black, this), }, { new Peice(pTypes[2], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[2], PSide.Black, this), }, { new Peice(pTypes[3], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[3], PSide.Black, this), }, { new Peice(pTypes[4], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[4], PSide.Black, this), }, { new Peice(pTypes[5], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[5], PSide.Black, this), }, { new Peice(pTypes[6], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[6], PSide.Black, this), }, { new Peice(pTypes[7], PSide.White, this), new Peice(PType.Pawn, PSide.White, this), null, null, null, null, new Peice(PType.Pawn, PSide.Black, this), new Peice(pTypes[7], PSide.Black, this), }, }; } //prepare moves for 1st turn foreach (Peice peice in getPeices(Gameboard, PSide.White)) { peice.UpdateMoves(); } }
public Peice(PType myType_init, PSide mySide_init, ChessGame myGame_init) { myType = myType_init; mySide = mySide_init; myGame = myGame_init; myGame.PieceList.Add(this); }
public bool IsInCheck(PSide side) { return ischecked[(int)side]; }
//builds a level 2 street of length from startMid within curLarge transport unit private void buildLev2(TULarge curLarge, TransportUnit startMid, int length, PSide side) { //the max and min indexes that the street can be built to(stay within the large unit) //move out of this function so it is not recalculated every time int maxI = (curLarge.indexI + 1) * largeTUWidth - 1; int minI = (curLarge.indexI) * largeTUWidth; int maxJ = (curLarge.indexJ + 1) * largeTUWidth - 1; int minJ = (curLarge.indexJ) * largeTUWidth; //the last mid unit to build away from TransportUnit lastMid = startMid; Dir lastDir; for (int i = 0; i < length; i++) { //the direction to build //NOTE: modify later to not build back from the same direction Dir dir = (Dir)(curLarge.rng.Next(1, 5)); //the index of the new mid unit to modify int curix = lastMid.indexI; int curiy = lastMid.indexJ; if (dir == Dir.RIGHT) { curix++; if (curix > maxI) { lastMid.conRight = true; lastMid.RightLev = 2; break; } } if (dir == Dir.LEFT) { curix--; if (curix < minI) { break; } } if (dir == Dir.UP) { curiy++; if (curiy > maxJ) { lastMid.conUp = true; lastMid.UpLev = 2; break; } } if (dir == Dir.DOWN) { curiy--; if (curiy < minJ) { break; } } //build (or just retrieve) the mid unit at the new indexes TransportUnit curMid = buildMid(curix, curiy, side); //set its conpoint if it has not already been set curMid.setConPoint(new Vector2((curix + (float)curLarge.rng.NextDouble()) * midTUWidth, (curiy + (float)curLarge.rng.NextDouble()) * midTUWidth)); //MyDebug.placeMarker(UnitConverter.getWP(new SurfacePos(PSide.TOP, curMid.conPoint.x, curMid.conPoint.y), 10000, 1024), 10); //connect on level 2 connectUnits(curMid, lastMid, 2); lastMid = curMid; } }
public int u, v; //grid point on that side public SurfaceUnit(PSide s, int upos, int vpos) { side = s; u = upos; v = vpos; }
//builds a street from the center of a large unit to the edge in the given direction private void buildMidCurve(TULarge lu, Vector2 outsideConPoint, Dir dir, TransportUnit powMid, PSide side) //powmid is the mid unit that contains the large's conpoint { int gix = 0, giy = 0; //goal index x and y of the goal mid unit float outSlope = GridMath.findSlope(lu.conPoint, outsideConPoint); //find the average slope from this conPoint to the outsideConPoint Debug.DrawLine(UnitConverter.getWP(new SurfacePos(PSide.TOP, lu.conPoint.x, lu.conPoint.y), 10000, sideLength), UnitConverter.getWP(new SurfacePos(PSide.TOP, outsideConPoint.x, outsideConPoint.y), 10000, sideLength), Color.blue, Mathf.Infinity); //determine the goal mid unit if (dir == Dir.RIGHT) { //find the index of the goal mid unit float goalPosX = (lu.indexI + 1) * sideLengthLarge; //the x value of the very right side of the large unit in mid units float goalPosY = GridMath.findY(goalPosX, lu.conPoint, outSlope); //the y value on the line between teh two conpoints GridMath.findMidIndexfromPoint(new Vector2(goalPosX - 0.5f, goalPosY), midTUWidth, out gix, out giy); TransportUnit goalMid = buildMid(gix, giy, side); goalMid.conRight = true; goalMid.RightLev = 1; //Debug.DrawLine(UnitConverter.getWP(new SurfacePos(PSide.TOP, lu.conPoint.x, lu.conPoint.y), 10000, 1024), // UnitConverter.getWP(new SurfacePos(PSide.TOP, goalPosX, goalPosY), 10000, 1024), Color.blue, Mathf.Infinity); } else if (dir == Dir.LEFT) { //find the index of the goal mid unit float goalPosX = (lu.indexI) * sideLengthLarge; //the x value of the very right side of the large unit in mid units float goalPosY = GridMath.findY(goalPosX, lu.conPoint, outSlope); //the y value on the line between teh two conpoints GridMath.findMidIndexfromPoint(new Vector2(goalPosX + 0.5f, goalPosY), midTUWidth, out gix, out giy); //buildMid(gix, giy, side).conLeft=true; } else if (dir == Dir.UP) { //find the index of the goal mid unit float goalPosY = (lu.indexJ + 1) * sideLengthLarge; //the x value of the very right side of the large unit in mid units float goalPosX = GridMath.findX(goalPosY, lu.conPoint, outSlope); //the y value on the line between teh two conpoints GridMath.findMidIndexfromPoint(new Vector2(goalPosX, goalPosY - 0.5f), midTUWidth, out gix, out giy); TransportUnit goalMid = buildMid(gix, giy, side); goalMid.conUp = true; goalMid.UpLev = 1; } else if (dir == Dir.DOWN) { //find the index of the goal mid unit float goalPosY = (lu.indexJ) * sideLengthLarge; //the x value of the very right side of the large unit in mid units float goalPosX = GridMath.findX(goalPosY, lu.conPoint, outSlope); //the y value on the line between teh two conpoints GridMath.findMidIndexfromPoint(new Vector2(goalPosX, goalPosY + 0.5f), midTUWidth, out gix, out giy); } //the x and y index of the mid unit last created in the loop(starts as if pows were last created) //int lastix = powIndexX, lastiy = powIndexY; TransportUnit lastMid = powMid; while (true) { //the difference in indexes between the current and goal mid units int xdif = gix - lastMid.indexI; int ydif = giy - lastMid.indexJ; //the direction to move in this loop iteration(1=x 2=y) int movedir; //if they are both not on the goal index, pick a random one to change if (xdif != 0 && ydif != 0) { movedir = lu.rng.NextDouble() > 0.5 ? 1:2; } else if (xdif != 0) { movedir = 1; } else if (ydif != 0) { movedir = 2; } else //if they are both zero we are done maybe? { break; //? } //the index of the mid unit to be created int curix = lastMid.indexI, curiy = lastMid.indexJ; //if moving in the x direction if (movedir == 1) { if (xdif > 0) { curix++; } else { curix--; } } else //movedir==2 { if (ydif > 0) { curiy++; } else { curiy--; } } //create or retrieve the new mid unit TransportUnit curMid = buildMid(curix, curiy, side); //set its conpoint if it has not already been set curMid.setConPoint(new Vector2((curix + (float)lu.rng.NextDouble()) * midTUWidth, (curiy + (float)lu.rng.NextDouble()) * midTUWidth)); //MyDebug.placeMarker(UnitConverter.getWP(new SurfacePos(PSide.TOP, curMid.conPoint.x, curMid.conPoint.y), 10000, 1024), 5); connectUnits(curMid, lastMid, 1); lastMid = curMid; } }
} //game constructor public void ResetBoard() //set/reset board { active = true; //reset game fields selectedpiece = null; ischecked = new bool[2]; turn = PSide.White; turn_count = 1; //reset board PieceList.Clear(); TakenList.Clear(); Gameboard = new Peice[8, 8] { {new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this),null,null,null,null,new Peice(PType.Pawn, PSide.Black, this),new Peice(PType.Rook, PSide.Black, this),}, {new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this),null,null,null,null,new Peice(PType.Pawn, PSide.Black, this),new Peice(PType.Knight, PSide.Black, this),}, {new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this),null,null,null,null,new Peice(PType.Pawn, PSide.Black, this),new Peice(PType.Bishop, PSide.Black, this),}, {new Peice(PType.Queen, PSide.White, this), new Peice(PType.Pawn, PSide.White, this),null,null,null,null,new Peice(PType.Pawn, PSide.Black, this),new Peice(PType.Queen, PSide.Black, this),}, {new Peice(PType.King, PSide.White, this), new Peice(PType.Pawn, PSide.White, this),null,null,null,null,new Peice(PType.Pawn, PSide.Black, this),new Peice(PType.King, PSide.Black, this),}, {new Peice(PType.Bishop, PSide.White, this), new Peice(PType.Pawn, PSide.White, this),null,null,null,null,new Peice(PType.Pawn, PSide.Black, this),new Peice(PType.Bishop, PSide.Black, this),}, {new Peice(PType.Knight, PSide.White, this), new Peice(PType.Pawn, PSide.White, this),null,null,null,null,new Peice(PType.Pawn, PSide.Black, this),new Peice(PType.Knight, PSide.Black, this),}, {new Peice(PType.Rook, PSide.White, this), new Peice(PType.Pawn, PSide.White, this),null,null,null,null,new Peice(PType.Pawn, PSide.Black, this),new Peice(PType.Rook, PSide.Black, this),}, }; //prepare moves for 1st turn foreach (Peice peice in getPeices(Gameboard, PSide.White)) { peice.UpdateMoves(); } }