コード例 #1
0
 private void Redraw(IGameHandler handler)
 {
     handler.Clear();
     foreach (var cell in _cells.AsEnumerable())
     {
         int i = cell.Key.Item1 - _players[0].ViewportLeft;
         int j = cell.Key.Item2 - _players[0].ViewportTop;
         if (0 > i || i >= CellsCount || 0 > j || j >= CellsCount)
         {
             continue;
         }
         if (cell.Value == CellType.X)
         {
             handler.DrawX(i, j);
         }
         else
         {
             handler.DrawZero(i, j);
         }
     }
 }
コード例 #2
0
 private void UpdateCell(int i, int j, string playerId, IGameHandler handler)
 {
     if (_isFirstPlayerTurn && _players[0].PlayerId == playerId &&
         CheckMovePermissibility(i, j, handler))
     {
         _cells[i, j] = CellType.Zero;
         handler.DrawZero(i - _players[0].ViewportLeft, j - _players[0].ViewportTop);
         _isFirstPlayerTurn = false;
     }
     else if (!_isFirstPlayerTurn && _players[1].PlayerId == playerId &&
              CheckMovePermissibility(i, j, handler))
     {
         _cells[i, j] = CellType.X;
         handler.DrawX(i - _players[0].ViewportLeft, j - _players[0].ViewportTop);
         _isFirstPlayerTurn = true;
     }
     else
     {
         handler.BroadcastMessage(true, "Please, wait... it's not your turn");
     }
 }