#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
# 处理地图画面活动块和元件的类。本类在
# Scene_Map 类的内部使用。
#==============================================================================
# 增加多重雾设定 2011 08 10
# 相关脚本:·Game_Map
# 附加一层雾方式:在进入地图前运行脚本
#
# #第一个雾
# extra_fog = [雾图片名,色调偏移,x速度,y速度,缩放(百分比),透明度(0~255),混合方式(0正常,1加法,2减法)]
# $game_map.extra_fogs.push(extra_fog)
# #第一个雾
# extra_fog = [雾图片名,色调偏移,x速度,y速度,缩放,透明度,混合方式]
# $game_map.extra_fogs.push(extra_fog)
######以此类推
#例: 下面脚本添加了两个交叉运动的雾
#extra_fog = ["Clouds",0,2,10,200,64,0]
#$game_map.extra_fogs.push(extra_fog)
#extra_fog = ["Clouds",0,10,2,200,64,0]
#$game_map.extra_fogs.push(extra_fog)
#
# 不使用雾时请在退出地图前调用$game_map.extra_fogs.clear,否则雾会带到下一个地图
class Spriteset_Map
attr_reader :viewport1
attr_reader :viewport2
attr_reader :viewport3
attr_reader :viewport4
attr_reader :character_sprites
attr_accessor :picture_sprites
attr_accessor :panorama
attr_reader :sub_spritesets
# 锁定远景的地图编号(编号为2、8、10的地图远景会锁定)
SCROLL_FREEZE_PANORAMA_IDS = [2]
SCROLLY_FREEZE_PANORAMA_IDS = [337,357] #锁定Y轴
DOUBLE_PANORAMA_IDS = [209]
AUTO_SCROLLY_PANORAMA_IDS = [362,365]
#——说明:如果自动滚动和锁定都包括了某张地图,则该地图不滚动。
#——如果自动滚动和锁定都没有包括某图,则还是会使用默认效果。
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 480)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4 = Viewport.new(0, 0, 640, 480) #####
@viewport2.z = 200
@viewport3.z = 5000
@viewport4.z = 20005
# 生成元件地图
@tilemap = Tilemap.new(@viewport1)
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
@tilemap.map_data = $game_map.data
@tilemap.priorities = $game_map.priorities
# 生成远景平面
@panorama = Plane.new(@viewport1)
@panorama.z = -1000
#-----------------------
$panorama2 = Plane.new(@viewport1)
$panorama2.z = -500
#-----------------------
# 生成雾平面
@fog = [Plane.new(@viewport1)]
@fog[0].z = 3000
@fog_name = []
@fog_hue = []
unless $game_map.extra_fogs.nil?
for i in 0...$game_map.extra_fogs.size
fog_set = $game_map.extra_fogs[i]
fog = Plane.new(@viewport1)
fog.z = 30000
@fog.push(fog)
end
end
# 生成角色活动块
@character_sprites = []
for i in $game_map.events.keys.sort
sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
@character_sprites.push(sprite)
end
#if $game_switches[988] == true #海战开关
#$player = (Sprite_Player.new(@viewport1, $game_player))
#@character_sprites.push(Sprite_Player.new(@viewport1, $game_player))
#else
@character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
#end
#####人物跟随
begin
setup_actor_character_sprites($game_party.characters)
rescue
end
# 生成天气
@weather = RPG::Weather.new(@viewport1)
# 生成图片
@picture_sprites = []
#for i in 1..50
# @picture_sprites.push(Sprite_Picture.new(@viewport2,
# $game_screen.pictures[i]))
#end
for i in 1..24
@picture_sprites.push(Sprite_Picture.new(@viewport2,
$game_screen.pictures[i]))
end
for i in 25..50
@picture_sprites.push(Sprite_Picture.new(@viewport4,
$game_screen.pictures[i]))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
@sub_spritesets = []
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def check_fullscreen
if $game_map.fullscreen or $game_variables[GAME_END_VARIABLE] > 0
@sub_spritesets[0] = Spriteset_UI.new(0,120,false,-1) if @sub_spritesets[0].nil?
@sub_spritesets[1] = Spriteset_UI.new(160,120,false,-1) if @sub_spritesets[1].nil?
@sub_spritesets[2] = Spriteset_UI.new(160,0,false,-1) if @sub_spritesets[2].nil?
else
unless @sub_spritesets.empty?
@sub_spritesets[0].dispose unless @sub_spritesets[0].nil?
@sub_spritesets[1].dispose unless @sub_spritesets[1].nil?
@sub_spritesets[2].dispose unless @sub_spritesets[2].nil?
@sub_spritesets = []
end
end
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 释放元件地图
@tilemap.tileset.dispose
for i in 0..6
@tilemap.autotiles[i].dispose
end
@tilemap.dispose
# 释放远景平面
@panorama.dispose
# 释放雾平面
for fog in @fog
fog.dispose
end
# 释放角色活动块
for sprite in @character_sprites
sprite.dispose
end
# 释放天候
@weather.dispose
# 释放图片
for sprite in @picture_sprites
sprite.dispose
end
# 释放flash
for sprite in $map_flash
sprite.dispose unless sprite.nil?
end
$map_flash = []
# 释放计时器块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
#$player.dispose if ($game_switches[988] == true)
for ss in @sub_spritesets
unless ss.nil?
ss.dispose
end
end
end
#-------------------------------------
def abs(x)
if x < 0 # 如果 x 小于 0 的话,
return -x # 结束函数,返回值 -x。
else # 除此之外,
return x # 结束函数,返回值 x。
end # 分歧结束。
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
#============================
#地图图块可更改设置
if $game_map.new_tileset == true
@tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
@tilemap.priorities = $game_map.priorities
for i in 0..6
autotile_name = $game_map.autotile_names[i]
@tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
end
$game_map.new_tileset = false
end
#======================
# 远景与现在的情况有差异发情况下
if @panorama_name != $game_map.panorama_name or
@panorama_hue != $game_map.panorama_hue
@panorama_name = $game_map.panorama_name
@panorama_hue = $game_map.panorama_hue
if @panorama.bitmap != nil
@panorama.bitmap.dispose
@panorama.bitmap = nil
end
if @panorama_name != ""
@panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue)
#-------------------------------------------------------------------------
if DOUBLE_PANORAMA_IDS.include?($game_map.map_id)
$panorama2.bitmap = RPG::Cache.panorama(@panorama_name+"_2", @panorama_hue)
end
#-------------------------------------------------------------------------
end
Graphics.frame_reset
end
# 雾与现在的情况有差异的情况下
for i in 0...($game_map.extra_fogs.size+1)
if @fog[i].nil?
fog = Plane.new(@viewport1)
fog.z = 3000
@fog[i] = fog
end
if @fog_name[i] != $game_map.fog_name(i) or @fog_hue[i] != $game_map.fog_hue(i)
@fog_name[i] = $game_map.fog_name(i)
@fog_hue[i] = $game_map.fog_hue(i)
if @fog[i].bitmap != nil
@fog[i].bitmap.dispose
@fog[i].bitmap = nil
end
if @fog_name[i] != ""
@fog[i].bitmap = RPG::Cache.fog(@fog_name[i], @fog_hue[i])
unless CUSTOM_FOG_Z[@fog_name[i]].nil?
@fog[i].z = CUSTOM_FOG_Z[@fog_name[i]]
end
end
Graphics.frame_reset
end
end
# 雾与现在的情况有差异的情况下
for i in ($game_map.extra_fogs.size+1)...@fog.size
unless @fog[i].nil?
@fog[i].dispose
end
@fog[i] = nil
Graphics.frame_reset
end
if @fog.size > ($game_map.extra_fogs.size+1)
@fog.compact!
end
# 刷新元件地图
@tilemap.ox = $game_map.display_x / 4
@tilemap.oy = $game_map.display_y / 4
@tilemap.update
# 刷新远景平面
@panorama.ox = $game_map.display_x / 8
@panorama.oy = $game_map.display_y / 8
# ===================================
if SCROLL_FREEZE_PANORAMA_IDS.include?($game_map.map_id)
@panorama.ox = 0
@panorama.oy = 0
elsif SCROLLY_FREEZE_PANORAMA_IDS.include?($game_map.map_id)
@panorama.ox = $game_map.display_x / 18 +$game_map.panorama_ox
@panorama.oy = 0
elsif AUTO_SCROLLY_PANORAMA_IDS.include?($game_map.map_id)
@panorama.ox = $game_map.display_x / 4
@panorama.oy = -$game_map.panorama_oy
else
@panorama.ox = $game_map.display_x / 8 +$game_map.panorama_ox
@panorama.oy = $game_map.display_y / 8 +$game_map.panorama_oy
end
#-------------------------------
#----------
if DOUBLE_PANORAMA_IDS.include?($game_map.map_id)
$panorama2.ox = $game_map.display_x / 6
$panorama2.oy = $game_map.display_y / 6
end
# ===================================
#----------
# 刷新雾平面
for i in 0...($game_map.extra_fogs.size+1)
@fog[i].zoom_x = $game_map.fog_zoom(i) / 100.0
@fog[i].zoom_y = $game_map.fog_zoom(i) / 100.0
@fog[i].opacity = $game_map.fog_opacity(i)
@fog[i].blend_type = $game_map.fog_blend_type(i)
@fog[i].ox = $game_map.display_x / 4 + $game_map.fog_ox(i)
@fog[i].oy = $game_map.display_y / 4 + $game_map.fog_oy(i)
@fog[i].tone = $game_map.fog_tone(i)
end
# 刷新角色活动块
for sprite in @character_sprites
sprite.update
end
# 刷新天候图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.ox = $game_map.display_x / 4
@weather.oy = $game_map.display_y / 4
@weather.update
# 刷新图片
for sprite in @picture_sprites
sprite.update
end
# 刷新flash
for sprite in $map_flash
sprite.update unless sprite.nil?
end
#$player.dispose if ($game_switches[988] == true)
# 刷新计时器块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport3.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport3.update
# 800*600
check_fullscreen
for ss in @sub_spritesets
unless ss.nil?
ss.update
end
end
end
end