public static GameObject InstantiatePieceAndPlaceOnSquare(string name, PieceControllerType type, ColorsEnum color, string destinationSquare) { GameObject newPiece = Utils.CreatePieceGameObject(name, type, color); Square square = Board.SquareMapping[destinationSquare]; Utils.PlaceOnObject(newPiece, square.gameObject); return(newPiece); }
public static GameObject CreatePieceGameObject(string name, PieceControllerType type, ColorsEnum color) { GameObject newGameObject = new GameObject(name); newGameObject.AddComponent <Piece>(); Piece PieceComponent = newGameObject.GetComponent <Piece>(); PieceComponent.IPiece = PieceFactory.createInstance(type); PieceComponent.Type = type; PieceComponent.SetColor(color); return(newGameObject); }
public static IPiece createInstance(PieceControllerType pieceType) { IPiece piece; switch (pieceType) { case PieceControllerType.QUEEN: piece = new Queen(); break; case PieceControllerType.KING: piece = new King(); break; case PieceControllerType.ROOK: piece = new Rook(); break; case PieceControllerType.KNIGHT: piece = new Knight(); break; case PieceControllerType.BISHOP: piece = new Bishop(); break; case PieceControllerType.PAWN: piece = new Pawn(); break; default: piece = null; break; } return(piece); }