mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-15 15:52:34 +00:00
TileMap parser can now load spawn locations, added construction yard building, added particle emitters, added smoke sprite and svg.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class IMICRTS
|
||||
class TiledMap
|
||||
attr_reader :width, :height, :tile_size
|
||||
attr_reader :layers, :tilesets
|
||||
attr_reader :layers, :tilesets, :spawnpoints
|
||||
def initialize(map_file)
|
||||
@xml = Nokogiri::XML(File.read("#{IMICRTS::ASSETS_PATH}/#{map_file}"))
|
||||
|
||||
@@ -10,6 +10,7 @@ class IMICRTS
|
||||
|
||||
@layers = []
|
||||
@tilesets = []
|
||||
@spawnpoints = []
|
||||
|
||||
@tiles = []
|
||||
|
||||
@@ -33,6 +34,15 @@ class IMICRTS
|
||||
@xml.search("//layer").each do |layer|
|
||||
@layers << Layer.new(layer)
|
||||
end
|
||||
|
||||
@xml.search("//objectgroup").each do |objectgroup|
|
||||
if objectgroup.attr("name") == "spawns"
|
||||
objectgroup.children.each do |object|
|
||||
next unless object.attr("name") && object.attr("name").downcase.strip == "spawn"
|
||||
@spawnpoints << SpawnPoint.new(object)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_tile(tile_id)
|
||||
@@ -121,5 +131,14 @@ class IMICRTS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class SpawnPoint
|
||||
attr_reader :x, :y
|
||||
def initialize(xml_object)
|
||||
@x, @y = Integer(xml_object.attr("x")), Integer(xml_object.attr("y"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user