예제 #1
0
파일: TileSet.cs 프로젝트: RossM/Mapdoodle
        public Tile GetDefaultTile(TerrainKind terrain, int layer)
        {
            BorderKind        terrainId = terrain.LayerTerrainId[layer];
            Grid <BorderKind> g         = new Grid <BorderKind>(2, 2);

            g[0, 0] = g[0, 1] = g[1, 0] = g[1, 1] = terrainId;

            return(GetTile(null, 0, 0, g, false, null));
        }
예제 #2
0
 private static bool IncompatibleTerrain(TerrainKind terrain1, TerrainKind terrain2)
 {
     for (int layer = 0; layer < 4; layer++)
     {
         if (terrain1.LayerTerrainId[layer] != BorderKind.Null &&
             terrain2.LayerTerrainId[layer] != BorderKind.Null &&
             terrain1.LayerTerrainId[layer] != terrain2.LayerTerrainId[layer])
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
 private void PaintSynthetic(Graphics target, int layer, int x, int y, int destX, int destY)
 {
     // No tile. Synthesize one
     for (int subX = 0; subX <= 1; subX++)
     {
         for (int subY = 0; subY <= 1; subY++)
         {
             TerrainKind squareKind = state.GetSquareKind(x + subX - 1, y + subY - 1);
             Tile        defaultTile = tileSet.GetDefaultTile(squareKind, layer);
             int         sourceX, sourceY, sourceWidth, sourceHeight;
             if (subX == 0)
             {
                 sourceX     = 0;
                 sourceWidth = tileSet.TileXOffset;
             }
             else
             {
                 sourceX     = tileSet.TileXOffset;
                 sourceWidth = tileSet.TileWidth - tileSet.TileXOffset;
             }
             if (subY == 0)
             {
                 sourceY      = 0;
                 sourceHeight = tileSet.TileYOffset;
             }
             else
             {
                 sourceY      = tileSet.TileYOffset;
                 sourceHeight = tileSet.TileHeight - tileSet.TileYOffset;
             }
             Rectangle rect = new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight);
             if (defaultTile != null)
             {
                 defaultTile.DrawToGraphics(target, destX, destY, rect);
             }
         }
     }
     target.DrawRectangle(new Pen(Color.FromArgb(255, 255, 0, 0)),
                          new Rectangle(destX, destY, tileSet.TileWidth - 1, tileSet.TileWidth - 1));
 }
예제 #4
0
 public void SetSquareKind(int squareX, int squareY, TerrainKind terrain)
 {
     squareKinds[squareX, squareY] = terrain;
 }
예제 #5
0
 public TerrainBrush(TerrainKind terrain)
 {
     this.terrain = terrain;
 }
예제 #6
0
 private static void SetTerrainBase(MapState mapState, int squareX, int squareY, TerrainKind terrain)
 {
     mapState.SetSquareKind(squareX, squareY, terrain);
 }