private void MoveChessman(int x, int y) { if (allowedMoves[x, y]) { Chessman c = Chessmans[x, y]; if (c != null && c.isWhite != isWhiteTurn) { //Capture if (c.GetType() == typeof(King)) { //end game gameOver = true; UIManager.Instance.GameOverSeq(); return; } activeChessman.Remove(c.gameObject); //Update emotions of other chessmans c.UpdateEmotions(c, selectedChessman, activeChessman); Destroy(c.gameObject); } //Promotion of Pawn - > Queen //Todo: Promote Pieces via UI if (selectedChessman.GetType() == typeof(Pawn)) { if (y == 7 && isWhiteTurn) { activeChessman.Remove(selectedChessman.gameObject); Destroy(selectedChessman.gameObject); spawnChessman(1, x, 7, "White Queen"); selectedChessman = Chessmans[x, y]; } else if (y == 0 && !isWhiteTurn) { activeChessman.Remove(selectedChessman.gameObject); Destroy(selectedChessman.gameObject); spawnChessman(7, x, 0, "Black Queen"); activeChessman.Remove(c.gameObject); selectedChessman = Chessmans[x, y]; } } //Setting the selected chessman from possible chessman array to null because we are taking it out of stack //after moving it to position x, y, we set the chessman back to all possible chessmans //After making the movement we flip the value of isWhiteTurn to indicate end of turn Chessmans[selectedChessman.CurrentX, selectedChessman.CurrentY] = null; selectedChessman.transform.position = GetTileCenter(x, y); selectedChessman.SetPosition(x, y); Chessmans[x, y] = selectedChessman; isWhiteTurn = !isWhiteTurn; numTurns += 1; UIManager.Instance.CascadeSidebar(); updateCam(); } //Reset the selected material to original material selectedChessman.GetComponent <MeshRenderer>().material = previousMat; UIManager.Instance.CascadeSidebar(); //If move is not possible, then deselect the chessman selectedChessman = null; BoardHighlights.Instance.Hidehilights(); }