public void AddWaterProperty() { Tileset.AddProperties(new TileProperties() { Name = "Water", GravityMult = 0.4f }); }
public void AddBlockProperty() { Tileset.AddProperties(new TileProperties() { Name = "Block", Blocking = true, ResistX = 0.5f }); }
public void AddIceProperty() { Tileset.AddProperties(new TileProperties() { Name = "Ice", ResistX = 0.95f, DragX = 0.5f }); }
public void AddConveyorLeftProperty() { Tileset.AddProperties(new TileProperties() { Name = "Left Conveyor", ResistX = 0.5f, PushX = -0.1f }); }
public void AddLadderProperty() { Tileset.AddProperties(new TileProperties() { Name = "Ladder", ResistX = 0.5f, Climbable = true }); }
public void AddSpikeProperty() { Tileset.AddProperties(new TileProperties() { Name = "Spike", Blocking = true, Lethal = true }); }
public Tileset Load(FilePath path) { var tileset = new Tileset(); tileset.FilePath = path; var doc = XDocument.Load(path.Absolute); var reader = doc.Element("Tileset"); if (reader == null) throw new Exception("The specified tileset definition file does not contain a Tileset tag."); var sheetPath = FilePath.FromRelative(reader.Attribute("tilesheet").Value, path.BasePath); tileset.ChangeSheetPath(sheetPath.Absolute); int size; if (!int.TryParse(reader.Attribute("tilesize").Value, out size)) throw new Exception("The tileset definition does not contain a valid tilesize attribute."); tileset.TileSize = size; var propParent = reader.Element("TileProperties"); if (propParent != null) { foreach (XElement propNode in propParent.Elements("Properties")) { var prop = new TileProperties(propNode); tileset.AddProperties(prop); } } foreach (XElement tileNode in reader.Elements("Tile")) { int id = int.Parse(tileNode.Attribute("id").Value); string name = tileNode.Attribute("name").Value; var spriteNode = tileNode.Element("Sprite"); if (spriteNode == null) throw new GameXmlException(tileNode, "All Tile tags must contain a Sprite tag."); var sprite = LoadSprite(spriteNode); var tileSprite = new TileSprite(tileset, sprite); Tile tile = new Tile(id, tileSprite); string propName = "Default"; XAttribute propAttr = tileNode.Attribute("properties"); if (propAttr != null) propName = propAttr.Value; tile.Properties = tileset.GetProperties(propName); tile.Sprite.Play(); tileset.Add(tile); } return tileset; }
public void AddSandProperty() { Tileset.AddProperties(new TileProperties() { Name = "Quicksand", ResistX = 0.2f, DragX = 0.2f, GravityMult = 3, Sinking = 0.2f }); }
public Tileset Load(FilePath path) { var tileset = new Tileset(); tileset.FilePath = path; var doc = XDocument.Load(path.Absolute); var reader = doc.Element("Tileset"); if (reader == null) { throw new Exception("The specified tileset definition file does not contain a Tileset tag."); } var sheetPath = FilePath.FromRelative(reader.Attribute("tilesheet").Value, path.BasePath); tileset.ChangeSheetPath(sheetPath.Absolute); int size; if (!int.TryParse(reader.Attribute("tilesize").Value, out size)) { throw new Exception("The tileset definition does not contain a valid tilesize attribute."); } tileset.TileSize = size; var propParent = reader.Element("TileProperties"); if (propParent != null) { foreach (XElement propNode in propParent.Elements("Properties")) { var prop = new TileProperties(propNode); tileset.AddProperties(prop); } } foreach (XElement tileNode in reader.Elements("Tile")) { int id = int.Parse(tileNode.Attribute("id").Value); string name = tileNode.Attribute("name").Value; var spriteNode = tileNode.Element("Sprite"); if (spriteNode == null) { throw new GameXmlException(tileNode, "All Tile tags must contain a Sprite tag."); } var sprite = LoadSprite(spriteNode); var tileSprite = new TileSprite(tileset, sprite); Tile tile = new Tile(id, tileSprite); string propName = "Default"; XAttribute propAttr = tileNode.Attribute("properties"); if (propAttr != null) { propName = propAttr.Value; } tile.Properties = tileset.GetProperties(propName); tile.Sprite.Play(); tileset.Add(tile); } return(tileset); }