// Start is called before the first frame update void Awake() { //collider = GetComponent<Collider>(); invButton = GameObject.FindObjectOfType <InvButton>(); if (invButton == null) { Debug.Log("Error: InvButton not found"); } _inventoryObj = GameObject.FindObjectOfType <inventoryObj>(); chessBox = GameObject.FindObjectOfType <ChessBox>(); kingCollider = gameObject.transform.Find("King Puzzle Collider").gameObject; knightCollider = gameObject.transform.Find("Knight Puzzle Collider").gameObject; kingAnswer = gameObject.transform.Find("King Answer").gameObject; knightAnswer = gameObject.transform.Find("Knight Answer").gameObject; if (kingCollider == null || knightCollider == null) { Debug.Log("Error: ChessBoard Colliders not found"); } }
public void RefreshFigures() { foreach (var box in boxes) { if (getChessBoxByPicBox(box).isFigureOn()) { ChessBox currentBox = getChessBoxByPicBox(box); switch (currentBox.Figure.getFigureType()) { case "Pawn": if (currentBox.Figure.isWhite) { box.Image = Image.FromFile("pawnWhite.agd"); } else { box.Image = Image.FromFile("pawnBlack.agd"); } break; case "Rook": if (currentBox.Figure.isWhite) { box.Image = Image.FromFile("rookWhite.agd"); } else { box.Image = Image.FromFile("rookBlack.agd"); } break; case "Queen": if (currentBox.Figure.isWhite) { box.Image = Image.FromFile("queenWhite.agd"); } else { box.Image = Image.FromFile("queenBlack.agd"); } break; case "King": if (currentBox.Figure.isWhite) { box.Image = Image.FromFile("kingWhite.agd"); } else { box.Image = Image.FromFile("kingBlack.agd"); } break; case "Bishop": if (currentBox.Figure.isWhite) { box.Image = Image.FromFile("bishopWhite.agd"); } else { box.Image = Image.FromFile("bishopBlack.agd"); } break; case "Knight": if (currentBox.Figure.isWhite) { box.Image = Image.FromFile("knightWhite.agd"); } else { box.Image = Image.FromFile("knightBlack.agd"); } break; default: box.Image = null; break; } } else { box.Image = null; } } }
public void StandardChess_InitialSetup_BoardIsSetProperly_AssertTrue() { ChessBoard board = new ChessBoard(); ChessBox[,] testBoard = new ChessBox[2, 8]; char c = 'A'; bool isWhite = true; for (int x = 0; x < 8; x++) { testBoard[0, x] = new ChessBox(c, 1, isWhite); c++; if (c != 'H') { isWhite = !isWhite; } } c = 'A'; for (int x = 0; x < 8; x++) { testBoard[1, x] = new ChessBox(c, 8, isWhite); c++; if (c != 'H') { isWhite = !isWhite; } } testBoard[0, 0].Figure = new Rook('A', 1, false); testBoard[0, 1].Figure = new Knight('B', 1, false); testBoard[0, 2].Figure = new Bishop('C', 1, false); testBoard[0, 3].Figure = new Queen('D', 1, false); testBoard[0, 4].Figure = new King('E', 1, false); testBoard[0, 5].Figure = new Bishop('F', 1, false); testBoard[0, 6].Figure = new Knight('G', 1, false); testBoard[0, 7].Figure = new Rook('H', 1, false); testBoard[1, 0].Figure = new Rook('A', 8, true); testBoard[1, 1].Figure = new Knight('B', 8, true); testBoard[1, 2].Figure = new Bishop('C', 8, true); testBoard[1, 3].Figure = new Queen('D', 8, true); testBoard[1, 4].Figure = new King('E', 8, true); testBoard[1, 5].Figure = new Bishop('F', 8, true); testBoard[1, 6].Figure = new Knight('G', 8, true); testBoard[1, 7].Figure = new Rook('H', 8, true); board.placeBlackFigures(true); board.placeWhiteFigures(true); for (int x = 0; x < 8; x++) { if (testBoard[0, x].Figure.GetType() != board.Boxes[0, x].Figure.GetType()) { Assert.IsTrue(false); } } for (int x = 0; x < 8; x++) { if (testBoard[1, x].Figure.GetType() != board.Boxes[7, x].Figure.GetType()) { Assert.IsTrue(false); } } Assert.IsTrue(true); }