示例#1
0
文件: Board.cs 项目: craigvenz/SGM3M
 // Violation of SRP?
 public static Board CreateEmptyBoard(int w, int h)
 {
     Board b = new Board(w, h);
     for (int x = 0; x < b.Size.Width; x++)
         for (int y = 0; y < b.Size.Height; y++)
             b._data[x,y]=(Tile)new EmptyTile();
     return b;
 }
示例#2
0
 // candidate for strategy pattern
 public void Generate(Board target)
 {
     for (int x = 0; x < target.Size.Width; x++)
     {
         for (int y = 0; y < target.Size.Height; y++)
         {
             Tile z=null;
             switch ((TileTypes)_random.Next((int)TileTypes.Normal, (int)TileTypes.Special))
             {
                 case TileTypes.Normal:
                     z = (Tile)new NormalTile();
                     break;
                 case TileTypes.Special:
                     z=(Tile)new SpecialTile();
                     break;
             }
             target.SetDataAt(x,y, z);
         }
     }
 }