Example #1
0
File: Tile.cs Project: MK4H/MHUrho
 /// <summary>
 /// Creates an instance of a tile based on the data stored in <paramref name="storedTile"/>.
 /// </summary>
 /// <param name="storedTile">The stored data of the tile.</param>
 /// <param name="map">The map the tile will be part of.</param>
 protected Tile(StTile storedTile, IMap map)
 {
     this.MapArea = new IntRect(storedTile.TopLeftPosition.X,
                                storedTile.TopLeftPosition.Y,
                                storedTile.TopLeftPosition.X + 1,
                                storedTile.TopLeftPosition.Y + 1);
     this.TopLeftHeight = storedTile.Height;
     this.Map           = map;
     units = null;
 }
Example #2
0
File: Tile.cs Project: MK4H/MHUrho
            /// <summary>
            /// Stores the <paramref name="tile"/> in an instance of <see cref="StTile"/> for serialization.
            /// </summary>
            /// <param name="tile">The tile to save.</param>
            /// <returns>Data of the tile stored in an instance of <see cref="StTile"/>.</returns>
            public static StTile Save(Tile tile)
            {
                var storedTile = new StTile
                {
                    TopLeftPosition = tile.TopLeft.ToStIntVector2(),
                    Height          = tile.TopLeftHeight,
                    TileTypeID      = tile.Type.ID,
                    BuildingID      = tile.Building?.ID ?? 0
                };

                foreach (var unit in tile.Units)
                {
                    storedTile.UnitIDs.Add(unit.ID);
                }


                return(storedTile);
            }
Example #3
0
File: Tile.cs Project: MK4H/MHUrho
 /// <summary>
 /// Creates a loader that loads a tile from data stored in <paramref name="storedTile"/>.
 /// </summary>
 /// <param name="level">The level the tile is part of.</param>
 /// <param name="map">The map the tile is part of.</param>
 /// <param name="storedTile">Stored data of the tile.</param>
 public Loader(LevelManager level, Map map, StTile storedTile)
 {
     this.level      = level;
     this.map        = map;
     this.storedTile = storedTile;
 }
Example #4
0
File: Tile.cs Project: MK4H/MHUrho
 /// <summary>
 /// Returns a loader that will load the tile from the <paramref name="storedTile"/>.
 /// </summary>
 /// <param name="level">The level the tile is part of.</param>
 /// <param name="map">The map the tile is part of.</param>
 /// <param name="storedTile">The stored data of the tile.</param>
 /// <returns>The loader that will load the tile from the stored data.</returns>
 public static ITileLoader GetLoader(LevelManager level, Map map, StTile storedTile)
 {
     return(new Loader(level, map, storedTile));
 }