public void Start(IPlayer player1, IPlayer player2) { if (player1.Side == player2.Side) { throw new GameException("Players should have different sides"); } if (Status == GameStatus.Started) { throw new GameException("Game is already started"); } _players = new IPlayer[] { player1, player2 }; _winnerIndex = -1; _history.Clear(); _board = _boardBuilder.Build(); _history.AddLast(new History { Board = Board, Side = CurrentPlayer.Side, Turn = 0 }); _currentHistoryItem = _history.Last; _turn = 0; Status = GameStatus.Started; _isRunning = true; _runningTask = Task.Factory.StartNew(async() => await GameLoop(), CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default) .Unwrap(); }
private void Start() { _ui = new UI.Core.UI(); _forceCalculator = new ForceCalculator(); _selector = new Selector3D(); _pusher = new Pusher(); _boardBuilder = new BoardBuilder(); _inputHandler = new MouseInputHandler(); _board = _boardBuilder.Build(); _turnSwitcher = new TurnSwitcher(_board); _playerAI = new PlayerAI( _inputHandler, _board ); InitUIHandler(); _inputHandler.OnDownEvent += OnDownEventHandler; _inputHandler.OnUpEvent += OnUpEventHandler; _turnSwitcher.MoveCompleteEvent += MoveCompleteEventHandler; _board.CheckersIsEmty += CheckersIsEmtyEventHandler; foreach (var checker in _board.CheckersWhite.Concat(_board.CheckersBlack)) { var checker1 = checker; checker1.SelectEvent += () => SelectEventHandler(checker1); checker1.BouncingBorderEvent += () => BouncingBorderEventHandler(checker1); } _ui.SelectYourColourText(); }
public Game(IRules rulesProvider, IBoardBuilder boardBuilder, IGameStatistics gameStatistics) { _rulesProvider = rulesProvider; _boardBuilder = boardBuilder; _history = new LinkedList <History>(); _gameStatistics = gameStatistics; UndoMove = new UndoGameMove(this); RedoMove = new RedoGameMove(this); StopMove = new StopGameMove(this); _board = _boardBuilder.Build(); }
public Board(IBoardBuilder builder) { if (builder == null) throw new ArgumentNullException(nameof(builder)); builder.Build(); Tiles = builder.Tiles; Vertices = builder.Vertices; Edges = builder.Edges; Harbors = builder.Harbors; Robber = new Robber(Tiles.Single(t => t.Rawmaterial == MaterialType.Unsourced)); }
public void Start() { // Создание строителя шахматной доски. // Создание доски. // Создание объектов для выбора фигур и ячеек. _boardBuilder = new BoardBuilder(); _board = _boardBuilder.Build(); _selector = new Selector(); // Подписка на события фигур и клеток игрового поля SubscribeToCells(); SubscribeToFigures(); // Первыми ходят белые ActiveFiguresColor = FigureColor.WHITE; }
public BoardMoveTest() { boardBuilder = new BoardBuilder(); _board = boardBuilder.Build(8, 8, 5); }