#==============================================================================
# ■ Spriteset_ActionMap
#==============================================================================
class Spriteset_ActionMap < Spriteset_Map
#--------------------------------------------------------------------------
# ● 对象初始化
#--------------------------------------------------------------------------
def initialize
@act_sprites = []
@act_sprites.push(Sprite_MiniGauge.new)
create_viewports
create_tilemap
create_parallax
create_characters
create_weather
create_pictures
create_timer
update
for i in 0...16
@act_sprites.push(Sprite_MiniMessage.new(nil, $game_action_map.messages[i]))
end
for i in 0...ACT::PL_BULLET_MAX
@act_sprites.push(Sprite_Bullet.new(@viewport2, $game_action_map.pl_bullets[i]))
end
for i in 0...ACT::EN_BULLET_MAX
@act_sprites.push(Sprite_Bullet.new(@viewport2, $game_action_map.en_bullets[i]))
end
for i in 0...ACT::EFFECT_MAX
@act_sprites.push(Sprite_Effect.new(@viewport2, $game_action_map.effects[i]))
end
end
#--------------------------------------------------------------------------
# ● 生成视区
#--------------------------------------------------------------------------
def create_viewports
@viewport1 = Viewport.new(0, 0, 544, 416)
@viewport2 = Viewport.new(0, 0, 544, 416)
@viewport3 = Viewport.new(0, 0, 544, 416)
@viewport4 = Viewport.new(0, 0, 544, 416)
@viewport2.z = 200
@viewport3.z = 5000
@viewport4.z = 10
end
#--------------------------------------------------------------------------
# ● 生成图块地图
#--------------------------------------------------------------------------
def create_tilemap
@tilemap = Tilemap.new(@viewport1)
@tilemap.bitmaps[0] = Cache.system("TileA1")
@tilemap.bitmaps[1] = Cache.system("TileA2")
@tilemap.bitmaps[2] = Cache.system("TileA3")
@tilemap.bitmaps[3] = Cache.system("TileA4")
@tilemap.bitmaps[4] = Cache.system("TileA5")
@tilemap.bitmaps[5] = Cache.system("TileB")
@tilemap.bitmaps[6] = Cache.system("TileC")
@tilemap.bitmaps[7] = Cache.system("TileD")
@tilemap.bitmaps[8] = Cache.system("TileE")
@tilemap.map_data = $game_action_map.data
@tilemap.passages = $game_action_map.passages
end
#--------------------------------------------------------------------------
# ● 生成远景
#--------------------------------------------------------------------------
def create_parallax
@parallax = Plane.new(@viewport1)
@parallax.z = -1000
@parallax2 = Plane.new(@viewport1)
@parallax2.z = 3000
@parallax3 = Plane.new(@viewport1)
@parallax3.z = -2000
end
#--------------------------------------------------------------------------
# ● 生成角色的精灵
#--------------------------------------------------------------------------
def create_characters
@character_sprites = []
for i in $game_action_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_action_map.events[i])
@character_sprites.push(sprite)
end
for vehicle in $game_map.vehicles
sprite = Sprite_Character.new(@viewport1, vehicle)
@character_sprites.push(sprite)
end
@character_sprites.push(Sprite_Character.new(@viewport1, $game_action_player))
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 create_pictures
@picture_sprites = []
for i in 1..20
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_action_map.screen.pictures[i]))
end
end
#--------------------------------------------------------------------------
# ● 生成计时器活动块
#--------------------------------------------------------------------------
def create_timer
@timer_sprite = Sprite_Timer.new(@viewport2)
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
dispose_tilemap
dispose_parallax
dispose_characters
dispose_weather
dispose_pictures
dispose_timer
dispose_viewports
for sprite in @act_sprites do sprite.dispose end
end
#--------------------------------------------------------------------------
# ● 释放元件图
#--------------------------------------------------------------------------
def dispose_tilemap
@tilemap.dispose
end
#--------------------------------------------------------------------------
# ● 释放远景
#--------------------------------------------------------------------------
def dispose_parallax
@parallax.dispose
@parallax2.dispose
@parallax3.dispose
end
#--------------------------------------------------------------------------
# ● 释放角色活动块
#--------------------------------------------------------------------------
def dispose_characters
for sprite in @character_sprites
sprite.dispose
end
end
#--------------------------------------------------------------------------
# ● 释放飞行船阴影活动块
#--------------------------------------------------------------------------
def dispose_shadow
@shadow_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 释放天气
#--------------------------------------------------------------------------
def dispose_weather
@weather.dispose
end
#--------------------------------------------------------------------------
# ● 释放位图活动块
#--------------------------------------------------------------------------
def dispose_pictures
for sprite in @picture_sprites
sprite.dispose
end
end
#--------------------------------------------------------------------------
# ● 释放计时器活动块
#--------------------------------------------------------------------------
def dispose_timer
@timer_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 释放视区
#--------------------------------------------------------------------------
def dispose_viewports
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
end
#--------------------------------------------------------------------------
# ● 帧更新
#--------------------------------------------------------------------------
def update
update_tilemap
update_parallax
update_characters
update_weather
update_pictures
update_timer
update_viewports
if @act_sprites != nil
for sprite in @act_sprites do sprite.update end
end
end
#--------------------------------------------------------------------------
# ● 图块地图的更新
#--------------------------------------------------------------------------
def update_tilemap
@tilemap.ox = $game_action_map.display_x / 8
@tilemap.oy = $game_action_map.display_y / 8
@tilemap.update
end
#--------------------------------------------------------------------------
# ● 更新远景
#--------------------------------------------------------------------------
def update_parallax
if @parallax_name != $game_action_map.parallax_name
@parallax_name = $game_action_map.parallax_name
if @parallax.bitmap != nil
@parallax.bitmap.dispose
@parallax2.bitmap.dispose
@parallax3.bitmap.dispose
@parallax2.bitmap = nil
@parallax.bitmap = nil
@parallax3.bitmap = nil
end
if @parallax_name != ""
@parallax.bitmap = Cache.parallax(@parallax_name)
@parallax2.bitmap = Cache.parallax(@parallax_name+"_2")
@parallax3.bitmap = Cache.parallax(@parallax_name+"_3")
end
Graphics.frame_reset
end
@parallax.ox = $game_action_map.calc_parallax_x(@parallax.bitmap) /8
@parallax.oy = $game_action_map.calc_parallax_y(@parallax.bitmap) /8
@parallax2.ox = @parallax.ox
@parallax2.oy = @parallax.oy
@parallax3.ox = $game_action_map.calc_parallax_x(@parallax.bitmap) / 16
@parallax3.oy = $game_action_map.calc_parallax_y(@parallax.bitmap) / 16
end
#--------------------------------------------------------------------------
# ● 更新角色脚本
#--------------------------------------------------------------------------
def update_characters
for sprite in @character_sprites
sprite.update if sprite.character.update_flag
end
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_action_map.screen.weather_type
@weather.max = $game_action_map.screen.weather_max
@weather.ox = $game_action_map.display_x / 8
@weather.oy = $game_action_map.display_y / 8
@weather.update
end
#--------------------------------------------------------------------------
# ● 刷新活动块位图
#--------------------------------------------------------------------------
def update_pictures
for sprite in @picture_sprites
sprite.update
end
end
#--------------------------------------------------------------------------
# ● 刷新计时器位图
#--------------------------------------------------------------------------
def update_timer
@timer_sprite.update
end
#--------------------------------------------------------------------------
# ● 视口更新
#--------------------------------------------------------------------------
def update_viewports
@viewport1.tone = $game_action_map.screen.tone
@viewport1.ox = $game_action_map.screen.shake
@viewport2.color = $game_action_map.screen.flash_color
@viewport3.color.set(0, 0, 0, 255 - $game_action_map.screen.brightness)
@viewport1.update
@viewport2.update
@viewport3.update
end
end