示例#1
0
 private Board ParseBoard(string p)
 {
     Board board = new Board();
     p = p.Trim().Replace(" ", "");
     List<Tile> tiles = new List<Tile>();
     int row = 1;
     foreach (string rowString in p.Split('\n'))
     {
         int column = 1;
         foreach (char c in rowString)
         {
             if (c >= '1' && c <= '3')
             {
                 tiles.Add(new Tile(board) { Row = row, Column = column, Fish = c - '0' });
             }
             else if (c == 'R')
             {
                 tiles.Add(new Tile(board) { Row = row, Column = column, Fish = 1, Penguin = 1 });
             }
             else if (c == 'B')
             {
                 tiles.Add(new Tile(board) { Row = row, Column = column, Fish = 1, Penguin = 2 });
             }
             column++;
         }
         row++;
     }
     board.Tiles = new ObservableCollection<Tile>(tiles);
     return board;
 }
示例#2
0
 public Tile(Board board)
 {
     this.board = board;
     SelectCommand = new RelayCommand(Select);
 }