def mapbatbac
return false if $BTEST
return false if $game_map.battleback1_name!=""
return false if $game_map.battleback2_name!=""
return true
end
class Spriteset_Battle
def initialize
create_viewports
if mapbatbac
create_tilemap
create_parallax
create_characters
create_shadow
create_weather
end
create_battleback1
create_battleback2
create_enemies
create_actors
create_pictures
create_timer
update
end
def dispose
if mapbatbac
dispose_tilemap
dispose_parallax
dispose_characters
dispose_shadow
dispose_weather
end
dispose_battleback1
dispose_battleback2
dispose_enemies
dispose_actors
dispose_pictures
dispose_timer
dispose_viewports
end
def update
if mapbatbac
update_tileset
update_tilemap
update_parallax
update_characters
update_shadow
update_weather
end
update_battleback1
update_battleback2
update_enemies
update_actors
update_pictures
update_timer
update_viewports
end
def create_characters
@character_sprites = []
$game_map.events.values.each do |event|
@character_sprites.push(Sprite_Character.new(@viewport1, event))
end
$game_map.vehicles.each do |vehicle|
@character_sprites.push(Sprite_Character.new(@viewport1, vehicle))
end
@map_id = $game_map.map_id
end
def update_characters
refresh_characters if @map_id != $game_map.map_id
@character_sprites.each {|sprite| sprite.update }
end
def dispose_characters
@character_sprites.each {|sprite| sprite.dispose }
end
def create_tilemap
@tilemap = Tilemap.new(@viewport1)
@tilemap.map_data = $game_map.data
load_tileset
end
def load_tileset
@tileset = $game_map.tileset
@tileset.tileset_names.each_with_index do |name, i|
@tilemap.bitmaps[i] = Cache.tileset(name)
end
@tilemap.flags = @tileset.flags
end
def create_parallax
@parallax = Plane.new(@viewport1)
@parallax.z = -100
end
def create_shadow
@shadow_sprite = Sprite.new(@viewport1)
@shadow_sprite.bitmap = Cache.system("Shadow")
@shadow_sprite.ox = @shadow_sprite.bitmap.width / 2
@shadow_sprite.oy = @shadow_sprite.bitmap.height
@shadow_sprite.z = 180
end
def create_weather
@weather = Spriteset_Weather.new(@viewport2)
end
def dispose_tilemap
@tilemap.dispose
end
def dispose_parallax
@parallax.bitmap.dispose if @parallax.bitmap
@parallax.dispose
end
def dispose_shadow
@shadow_sprite.dispose
end
def dispose_weather
@weather.dispose
end
def update_tileset
if @tileset != $game_map.tileset
load_tileset
refresh_characters
end
end
def update_tilemap
@tilemap.map_data = $game_map.data
@tilemap.ox = $game_map.display_x * 32
@tilemap.oy = $game_map.display_y * 32
@tilemap.update
end
def update_parallax
if @parallax_name != $game_map.parallax_name
@parallax_name = $game_map.parallax_name
@parallax.bitmap.dispose if @parallax.bitmap
@parallax.bitmap = Cache.parallax(@parallax_name)
Graphics.frame_reset
end
@parallax.ox = $game_map.parallax_ox(@parallax.bitmap)
@parallax.oy = $game_map.parallax_oy(@parallax.bitmap)
end
def update_shadow
airship = $game_map.airship
@shadow_sprite.x = airship.screen_x
@shadow_sprite.y = airship.screen_y + airship.altitude
@shadow_sprite.opacity = airship.altitude * 8
@shadow_sprite.update
end
def update_weather
@weather.type = $game_map.screen.weather_type
@weather.power = $game_map.screen.weather_power
@weather.ox = $game_map.display_x * 32
@weather.oy = $game_map.display_y * 32
@weather.update
end
end