public ScreenLayer(ScreenLayerInfo info, StageHandler stage, IEntityRespawnTracker respawnTracker) { this._info = info; this._stage = stage; this._respawnTracker = respawnTracker; this._squares = new MapSquare[info.Tiles.Height][]; for (int y = 0; y < info.Tiles.Height; y++) { this._squares[y] = new MapSquare[info.Tiles.Width]; for (int x = 0; x < info.Tiles.Width; x++) { try { Tile tile = info.Tiles.TileAt(x, y); if (tile == null) throw new Exception(); this._squares[y][x] = new MapSquare(this, tile, x, y, info.Tiles.Tileset.TileSize); } catch { throw new GameRunException(string.Format("There's an error in stage {0}, screen file {1}.scn.\nThere's a unrecognized tile number somewhere.", stage.Info.Name, info.Name)); } } } }
public ScreenLayer(ScreenLayerInfo info, StageHandler stage, IEntityRespawnTracker respawnTracker) { this._info = info; this._stage = stage; this._respawnTracker = respawnTracker; this._squares = new MapSquare[info.Tiles.Height][]; for (int y = 0; y < info.Tiles.Height; y++) { this._squares[y] = new MapSquare[info.Tiles.Width]; for (int x = 0; x < info.Tiles.Width; x++) { try { Tile tile = info.Tiles.TileAt(x, y); this._squares[y][x] = new MapSquare(this, tile, x, y, info.Tiles.Tileset.TileSize); } catch { throw new GameRunException("There's an error in screen file " + info.Name + ".scn,\nthere's a bad tile number somewhere."); } } } }
private void SaveLayer(ScreenLayerInfo layer, XmlTextWriter writer) { writer.WriteStartElement("Overlay"); writer.WriteAttributeString("name", layer.Name); writer.WriteAttributeString("x", layer.Tiles.BaseX.ToString()); writer.WriteAttributeString("y", layer.Tiles.BaseY.ToString()); if (layer.Foreground) writer.WriteAttributeString("foreground", layer.Foreground.ToString()); if (layer.Parallax) writer.WriteAttributeString("parallax", layer.Parallax.ToString()); foreach (var entity in layer.Entities) _entityWriter.Write(entity, writer); foreach (var keyframe in layer.Keyframes) SaveKeyframe(keyframe, writer); writer.WriteEndElement(); }
private ScreenLayerInfo LoadScreenLayer(XElement node, string stagePath, string name, Tileset tileset, int tileStartX, int tileStartY, bool foreground) { var tileFilePath = Path.Combine(stagePath, name + ".scn"); var tileArray = LoadTiles(tileFilePath); var tileLayer = new TileLayer(tileArray, tileset, tileStartX, tileStartY); var keyframes = new List<ScreenLayerKeyframe>(); foreach (var keyframeNode in node.Elements("Keyframe")) { var frame = LoadScreenLayerKeyFrame(keyframeNode); keyframes.Add(frame); } var layer = new ScreenLayerInfo(name, tileLayer, foreground, keyframes); foreach (XElement entity in node.Elements("Entity")) { EntityPlacement info = _entityReader.Load(entity); layer.AddEntity(info); } return layer; }