public void SetupPieces(BoardEngine <ChessPieceEntity> engine) { foreach (var action in _toBePlaced) { action(engine); } }
public void SetupPieces(BoardEngine <ChessPieceEntity> engine) { for (var rank = 7; rank >= 0; rank--) { for (var file = 0; file < 8; file++) { var chr = _board[file, rank]; if (_chessPieceEntityFactory.ValidPieces.Contains(chr.ToString().ToUpper())) { var entity = _chessPieceEntityFactory.Create( ChessPieceNameMapper.FromChar(chr), char.IsUpper(chr) ? Colours.White : Colours.Black ); var location = BoardLocation.At(file + 1, rank + 1); engine.AddPiece(entity, location); if (chr.ToString().ToUpper() == "E") { ((PawnEntity)entity).TwoStep = true; } } else if (chr != ' ' && chr != '.' && chr != '\0') { Throw.InvalidPiece(chr); } } } }
void InstantiateBoard() { // Making the deck deck = MakeStack(new Vector3(0f, -3f, 0f) - 3 * cellwidth, true, false, true); // Making the individual stacks. foreach (CellPos i in lastCell.Range()) { cells[i] = MakeStack(firstcellpos + i * cellsize, true, true, true); } // Initializing the holding cells. for (int i = 0; i < 4; i++) { holdingStacks[i] = MakeStack(new Vector3(0f, -3f, 0f) + i * cellwidth, true, true, false); } // Making the cards for (int i = 0; i < deckColors.Count; i++) { for (int j = 0; j < deckColorNumbers[i]; j++) { MakeCard(deckColors[i], deck); } } board = new BoardEngine(new CellPos(columns, rows)); }
public GameBoard(ContainerControl boardContainer) { BoardEngine = new BoardEngine(); int fieldSize = boardContainer.Width / BoardEngine.GetBoardSize(); BoardInterface = new BoardInterface(boardContainer, fieldSize, EventHandler); InitBoard(); }
private void AddPawns(BoardEngine <ChessPieceEntity> engine) { foreach (var colour in new[] { Colours.White, Colours.Black }) { for (int x = 1; x <= engine.Width; x++) { engine.AddPiece(CreatePawn(colour), BoardLocation.At(x, colour == Colours.White ? 2 : 7)); } } }
// Start is called before the first frame update void Start() { boardEngine = new BoardEngine(); boardEngine.ThingMoved += ThingMovedHandler; boardEngine.RoundCompleted += RoundCompletedHandler; boardEngine.GameEnded += GameEndedHandler; boardEngine.DebugMessageEvent += DebugMessageHandler; var levelInfo = LevelInfo.CurrentLevelInfo; LoadLevelAndStart(levelInfo); }
public ChessGame( IBoardEngineProvider <ChessPieceEntity> boardEngineProvider, ICheckDetectionService checkDetectionService, IBoardSetup <ChessPieceEntity> setup, Colours whoseTurn = Colours.White) { _engine = boardEngineProvider.Provide(setup, (int)whoseTurn); _checkDetectionService = checkDetectionService; _engine.CurrentPlayer = (int)whoseTurn; CheckState = _checkDetectionService.Check(BoardState); }
protected void InitBoard() { var boardState = BoardEngine.GetBoardState(); for (int i = 0; i < boardState.GetBoardSize(); i++) { for (int j = 0; j < boardState.GetBoardSize(); j++) { InitField(boardState, i, j); } } ChangeState(new ChooseMoveState(this)); }
void Awake() { if (instanceBoardEngine == null) { instanceBoardEngine = this; } else if (instanceBoardEngine != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); boardControllerInstance = GetComponent <BoardController>(); InitGame(); }
private void AddMajorPieces(BoardEngine <ChessPieceEntity> engine) { foreach (var rank in new[] { 1, 8 }) { var colour = rank == 1 ? Colours.White : Colours.Black; engine.AddPiece(CreateRook(colour), $"A{rank}".ToBoardLocation()); engine.AddPiece(CreateKnight(colour), $"B{rank}".ToBoardLocation()); engine.AddPiece(CreateBishop(colour), $"C{rank}".ToBoardLocation()); engine.AddPiece(CreateQueen(colour), $"D{rank}".ToBoardLocation()); engine.AddPiece(CreateKing(colour), $"E{rank}".ToBoardLocation()); engine.AddPiece(CreateBishop(colour), $"F{rank}".ToBoardLocation()); engine.AddPiece(CreateKnight(colour), $"G{rank}".ToBoardLocation()); engine.AddPiece(CreateRook(colour), $"H{rank}".ToBoardLocation()); } }
public void ResetGame() { BoardEngine = new BoardEngine(); BoardInterface.ResetGame(); InitBoard(); }
public void SetupPieces(BoardEngine <ChessPieceEntity> engine) { AddPawns(engine); AddMajorPieces(engine); }