private void addChessPieceToBoard(string pieceType, GameObject newPiece) { ChessPiece attachedScript = null; //Add the new chess piece to the chessGameBoard[,] 2D array of ChessPiece if (pieceType == "King") { attachedScript = newPiece.gameObject.GetComponentInChildren <King>(); chessgame.AddChessPiece(attachedScript); } else if (pieceType == "Queen") { attachedScript = newPiece.gameObject.GetComponentInChildren <Queen>(); chessgame.AddChessPiece(attachedScript); } else if (pieceType == "Rook") { attachedScript = newPiece.gameObject.GetComponentInChildren <Rook>(); chessgame.AddChessPiece(attachedScript); } else if (pieceType == "Bishop") { attachedScript = newPiece.gameObject.GetComponentInChildren <Bishop>(); chessgame.AddChessPiece(attachedScript); } else if (pieceType == "Knight") { attachedScript = newPiece.gameObject.GetComponentInChildren <Knight>(); chessgame.AddChessPiece(attachedScript); } else if (pieceType == "Pawn") { attachedScript = newPiece.gameObject.GetComponentInChildren <Pawn>(); chessgame.AddChessPiece(attachedScript); } else { Debug.LogError("Incorrect piecetype was passed in!"); } }