public void RemoveTile(Tile tile)
 {
     if (tile != null && tiles.Contains(tile))
     {
         tiles.Remove(tile);
         tile.TileChanged -= tile_TileChanged;
         if (TileChanged != null)
         {
             TileChanged(tile, new EventArgs());
         }
     }
 }
 public void AddTile(Tile tile)
 {
     if (tile != null && !tiles.Contains(tile))
     {
         tiles.Add(tile);
         tile.TileChanged += tile_TileChanged;
         if (ActiveTile == null)
         { ActiveTile = tile; }
         if (TileChanged != null)
         { TileChanged(tile, new EventArgs()); }
     }
 }
 private static BigMapAndTileSet DoDeserialize(Stream input, TileSet currentTileSet)
 {
     SerializedMap serialized = Serializer.Deserialize<SerializedMap>(input);
     BigMapAndTileSet result = new BigMapAndTileSet();
     BigMap map = new BigMap();
     map.ClearLayers();
     result.Map = map;
     result.TileSet = new TileSet();
     List<Tile> tileList = new List<Tile>();
     if (serialized.Tiles != null && serialized.Tiles.Count > 0)
     {
         result.TileSet.TileWidth = serialized.TileWidth;
         result.TileSet.TileHeight = serialized.TileHeight;
         foreach (byte[] image in serialized.Tiles)
         {
             Tile tile = new Tile();
             tile.FullImage = LoadImage(image);
             tileList.Add(tile);
             result.TileSet.AddTile(tile);
         }
     }
     else if (currentTileSet != null)
     {
         result.TileSet = currentTileSet;
         foreach (Tile tile in currentTileSet.Tiles)
         { tileList.Add(tile); }
     }
     foreach (MapLayer layer in serialized.Layers)
     {
         RapidTestMapMaker.MapLayer newLayer = new RapidTestMapMaker.MapLayer();
         newLayer.IsWall = layer.IsWall;
         map.AddLayer(newLayer);
         foreach (MapChunk chunk in layer.Chunks)
         {
             int l = chunk.X;
             int t = chunk.Y;
             int r = l + chunk.Width;
             int b = t + chunk.Height;
             int h = chunk.Height;
             IList<int> data = chunk.Data;
             for (int x = l; x < r; x++)
             {
                 for (int y = t; y < b; y++)
                 {
                     int index = data[((x - l) * h) + (y - t)];
                     if (index != -1)
                     {
                         while (index >= tileList.Count)
                         {
                             Tile missingTile = new Tile();
                             tileList.Add(missingTile);
                             result.TileSet.AddTile(missingTile);
                         }
                         newLayer[x, y] = tileList[index];
                     }
                 }
             }
         }
     }
     return result;
 }
Exemple #4
0
 private Tile LoadTile(String imageFileName)
 {
     Tile result = new Tile();
     try
     {
         Bitmap temp = (Bitmap)Bitmap.FromFile(imageFileName);
         temp.SetResolution(96, 96);
         result.FullImage = temp;
     }
     catch (Exception e)
     {
         int a = 5;
     }
     return result;
 }