void Start() { _board = new DT_BD(); }
// Eventually will be given a text file with placements. public void Init() { _data = new DT_BD(8); _squares = new Square[8, 8]; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { Vector2 pos = transform.position; // manually shifting the boxes around by pixel. Pivot is center, hence the 32. pos.x -= 256 - 32; pos.x += 64 * x; pos.y -= 256 - 32; pos.y += 64 * y; if (_data._Squares[x, y]._COL == SQUARE_COLOUR.WHITE) { // spawn a light square here. _squares[x, y] = Instantiate(PF_LightSquare, pos, transform.rotation); } else { // spawn a dark square here. _squares[x, y] = Instantiate(PF_DarkSquare, pos, transform.rotation); } _squares[x, y]._d._pos.x = x; _squares[x, y]._d._pos.y = y; _squares[x, y]._d._uInfo = 0; // no piece type, no piece colour if (y == 0) { _squares[x, y]._d._uInfo |= PieceInfo._white; if (x == 0 || x == 7) { _squares[x, y]._d._uInfo |= PieceInfo._rook; } else if (x == 1 || x == 6) { _squares[x, y]._d._uInfo |= PieceInfo._knight; } else if (x == 2 || x == 5) { _squares[x, y]._d._uInfo |= PieceInfo._bishop; } else if (x == 3) { _squares[x, y]._d._uInfo |= PieceInfo._queen; } else if (x == 4) { _squares[x, y]._d._uInfo |= PieceInfo._king; } } if (y == 1) { _squares[x, y]._d._uInfo |= PieceInfo._white; _squares[x, y]._d._uInfo |= PieceInfo._pawn; } if (y == 6) { _squares[x, y]._d._uInfo |= PieceInfo._black; _squares[x, y]._d._uInfo |= PieceInfo._pawn; } if (y == 7) { _squares[x, y]._d._uInfo |= PieceInfo._black; if (x == 0 || x == 7) { _squares[x, y]._d._uInfo |= PieceInfo._rook; } else if (x == 1 || x == 6) { _squares[x, y]._d._uInfo |= PieceInfo._knight; } else if (x == 2 || x == 5) { _squares[x, y]._d._uInfo |= PieceInfo._bishop; } else if (x == 3) { _squares[x, y]._d._uInfo |= PieceInfo._queen; } else if (x == 4) { _squares[x, y]._d._uInfo |= PieceInfo._king; } } } } RenderBoard(); }