public void actionSpell(string spellName, int x, int y) { spelledPiece sp = new spelledPiece(); sp.spellName = spellName; sp.newID = pieceID; if (spellName == "Upgrade") { selectedPiece = chessMen[x, y]; string type = selectedPiece.GetType().ToString(); switch (type) { case "Queen": sp.pieceType = 1; break; case "Rook": sp.pieceType = 2; break; case "Bishop": sp.pieceType = 3; break; case "Knight": sp.pieceType = 4; break; case "Pawn": sp.pieceType = 5; break; } if (!selectedPiece.isItWhite) { sp.pieceType += 6; } sp.endSpellTurn = turnCount + 4; activeChessmen.Remove(selectedPiece.gameObject); Destroy(selectedPiece.gameObject); } else if (spellName == "Stun") { chessMen[x, y].enabled = false; sp.endSpellTurn = turnCount + 3; } else if (spellName == "Cover") { sp.endSpellTurn = turnCount + 6; } spawnSpellMan(spellName, x, y); sp.x = x; sp.y = y; spelledPieces.Add(sp); BoardHighlights.Instance.hideHighlights(); isSpellMove = false; }
public void moveChessPiece(int selectionX, int selectionY, int x, int y) { selectChessPiece(selectionX, selectionY); selectedPiece.GetComponent <Outline>().enabled = false; if (allowedMoves[x, y]) { startMoveAnim(x, y); ChessPieces c = chessMen[x, y]; if (c != null && c.isItWhite != isWhiteTurn) { if (c.GetType() == typeof(King)) { gameOver(); } activeChessmen.Remove(c.gameObject); Destroy(c.gameObject); } enPassantMove(x, y, c); if (selectedPiece.GetType() == typeof(Pawn)) { if (y == 7 || y == 0) { if (isWhiteTurn == playerIsWhite) { upgradePanel.SetActive(true); panelState(true); } isMoveRepeating = true; } if (selectedPiece.currentY == 1 && y == 3) { passantMove[0] = x; passantMove[1] = y - 1; } else if (selectedPiece.currentY == 6 && y == 4) { passantMove[0] = x; passantMove[1] = y + 1; } } if (selectedPiece.GetType() == typeof(King) && c != null) { castlingMove(x, y, c); isMoveRepeating = true; } chessMen[selectedPiece.currentX, selectedPiece.currentY] = null; selectedPiece.setPosition(x, y); if (selectedPiece.GetType() == typeof(King)) { selectedPiece.GetComponent <King>().everMoved = true; } else if (selectedPiece.GetType() == typeof(Rook)) { selectedPiece.GetComponent <Rook>().everMoved = true; } chessMen[x, y] = selectedPiece; if (!isMoveRepeating) { swapTurn(); } } else { selectedPiece = null; } BoardHighlights.Instance.hideHighlights(); isMoveRepeating = false; }