public void moveChessMan(int x, int y) { if (allowedMove[x, y]) { chessMan c = chessMens [x, y]; if (c != null && c.isWhite != isWhiteTurn) { // if (c.GetType() == typeof(king)) // { // //End Game // return ; // } activePrefabs.Remove(c.gameObject); Destroy(c.gameObject); } chessMens[chessManSelected.currentX, chessManSelected.currentY] = null; chessManSelected.transform.position = GetTileCenter(x, y); chessManSelected.setPosition(x, y); isWhiteTurn = !isWhiteTurn; chessMens[x, y] = chessManSelected; } boardHilghtlLight.isntance.HideHightLighte(); chessManSelected = null; }
public void selectedChesman(int x, int y) { if (chessMens[x, y] == null) { return; } if (chessMens[x, y].isWhite != isWhiteTurn) { return; } allowedMove = chessMens[x, y].poisibleMove(); chessManSelected = chessMens [x, y]; boardHilghtlLight.isntance.HightLightAllowedMove(allowedMove); }
public override bool[,] poisibleMove() { bool[,] r = new bool[8, 8]; chessMan c, c2; if (isWhite) { //D R if (currentX != 0 && currentX != 7) { chessMan chessMan = chessManager.instance.chessMens[currentX - 1, currentY + 1]; c = chessMan; if (c != null && c.isWhite != isWhite) { r[currentX - 1, currentY + 1] = true; } } //D L if (currentX != 0 && currentX != 7) { c = chessManager.instance.chessMens[currentX + 1, currentY + 1]; if (c != null && c.isWhite != isWhite) { r[currentX + 1, currentY + 1] = true; } } //Move if (currentX != 0 && currentX != 7) { c = chessManager.instance.chessMens[currentX, currentY + 1]; if (c == null) { r[currentX, currentY + 1] = true; } } // Frist Move if (currentY == 1) { c = chessManager.instance.chessMens[currentX, currentY + 1]; c2 = chessManager.instance.chessMens[currentX, currentY + 2]; if (c == null) { r[currentX, currentY + 1] = true; } if (c2 == null) { r[currentX, currentY + 2] = true; } } } else { //D R if (currentX != 0 && currentX != 7) { c = chessManager.instance.chessMens[currentX - 1, currentY - 1]; if (c != null && c.isWhite != isWhite) { r[currentX - 1, currentY - 1] = true; } } //D L if (currentX != 0 && currentX != 7) { c = chessManager.instance.chessMens[currentX + 1, currentY - 1]; if (c != null && c.isWhite != isWhite) { r[currentX + 1, currentY - 1] = true; } } //Move if (currentX != 0 && currentX != 7) { c = chessManager.instance.chessMens[currentX, currentY - 1]; if (c == null) { r[currentX, currentY - 1] = true; } } // Frist Move if (currentY == 6) { c = chessManager.instance.chessMens[currentX, currentY - 1]; c2 = chessManager.instance.chessMens[currentX, currentY - 2]; if (c == null) { r[currentX, currentY - 1] = true; } if (c2 == null) { r[currentX, currentY - 2] = true; } } } return(r); }