#============================================================================== # ■ Game_Temp #------------------------------------------------------------------------------ #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン # スタンスは $game_temp で参照されます。 #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ● 公開インスタンス変数追加 #-------------------------------------------------------------------------- attr_accessor :fog_front # フォグ 前面配置フラグ attr_accessor :fog_initialize # フォグ 初期化フラグ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias base_initialize initialize def initialize base_initialize @fog_front = true @fog_initialize = true end end #============================================================================== # ■ Spriteset_Map #------------------------------------------------------------------------------ #  マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは # Scene_Map クラスの内部で使用されます。 #============================================================================== class Spriteset_Map #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias :base_update :update def update base_update # フォグプレーンを更新 if $game_temp.fog_front @fog.z = 3000 else @fog.z = 1 end end end #============================================================================== # ■ Spriteset_Battle #------------------------------------------------------------------------------ #  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ # スの内部で使用されます。 #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :base_initialize :initialize def initialize base_initialize # フォグプレーンを作成 @fog = Plane.new(@viewport1) # フレーム更新 update end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- alias :base_dispose :dispose def dispose base_dispose # フォグプレーンを解放 @fog.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias :base_update :update def update if @fog != nil base_update # フォグが現在のものと異なる場合 if @fog_name != $scene.fog_name or @fog_hue != $scene.fog_hue @fog_name = $scene.fog_name @fog_hue = $scene.fog_hue if @fog.bitmap != nil @fog.bitmap.dispose @fog.bitmap = nil end if @fog_name != "" @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue) end Graphics.frame_reset end # フォグプレーンを更新 if $game_temp.fog_front @fog.z = 3000 else @fog.z = 1 end @fog.zoom_x = $scene.fog_zoom / 100.0 @fog.zoom_y = $scene.fog_zoom / 100.0 @fog.opacity = $scene.fog_opacity @fog.blend_type = $scene.fog_blend_type @fog.ox = $scene.fog_ox @fog.oy = $scene.fog_oy @fog.tone = $scene.fog_tone end end end #============================================================================== # ■ Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_System クラ # スや Game_Event クラスの内部で使用されます。 #============================================================================== class Interpreter #-------------------------------------------------------------------------- # ● 注釈イベントの実行 #-------------------------------------------------------------------------- if self.class.method_defined?("command_108") alias :base_command_108 :command_108 def command_108 if @parameters[0] == "フォグを前に表示" $game_temp.fog_front = true return true end if @parameters[0] == "フォグを後ろに表示" $game_temp.fog_front = false return true end if @parameters[0] == "フォグを初期化する" $game_temp.fog_initialize = true return true end if @parameters[0] == "フォグを初期化しない" $game_temp.fog_initialize = false return true end base_command_108 end end #-------------------------------------------------------------------------- # ● マップの設定変更 #-------------------------------------------------------------------------- def command_204 case @parameters[0] when 0 # パノラマ $game_map.panorama_name = @parameters[1] $game_map.panorama_hue = @parameters[2] when 1 # フォグ unless $game_temp.in_battle $game_map.fog_name = @parameters[1] $game_map.fog_hue = @parameters[2] $game_map.fog_opacity = @parameters[3] $game_map.fog_blend_type = @parameters[4] $game_map.fog_zoom = @parameters[5] $game_map.fog_sx = @parameters[6] $game_map.fog_sy = @parameters[7] else # 戦闘中も実行可能にする $scene.fog_name = @parameters[1] $scene.fog_hue = @parameters[2] $scene.fog_opacity = @parameters[3] $scene.fog_blend_type = @parameters[4] $scene.fog_zoom = @parameters[5] $scene.fog_sx = @parameters[6] $scene.fog_sy = @parameters[7] end when 2 # バトルバック $game_map.battleback_name = @parameters[1] $game_temp.battleback_name = @parameters[1] end # 継続 return true end #-------------------------------------------------------------------------- # ● フォグの色調変更 #-------------------------------------------------------------------------- def command_205 # 色調変更を開始 unless $game_temp.in_battle $game_map.start_fog_tone_change(@parameters[0], @parameters[1] * 2) else # 戦闘中も実行可能にする $scene.start_fog_tone_change(@parameters[0], @parameters[1] * 2) end # 継続 return true end #-------------------------------------------------------------------------- # ● フォグの不透明度変更 #-------------------------------------------------------------------------- def command_206 # 不透明度変更を開始 unless $game_temp.in_battle $game_map.start_fog_opacity_change(@parameters[0], @parameters[1] * 2) else $scene.start_fog_opacity_change(@parameters[0], @parameters[1] * 2) end # 継続 return true end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 公開インスタンス変数追加 #-------------------------------------------------------------------------- attr_accessor :fog_name # フォグ ファイル名 attr_accessor :fog_hue # フォグ 色相 attr_accessor :fog_opacity # フォグ 不透明度 attr_accessor :fog_blend_type # フォグ ブレンド方法 attr_accessor :fog_zoom # フォグ 拡大率 attr_accessor :fog_sx # フォグ SX attr_accessor :fog_sy # フォグ SY attr_reader :fog_ox # フォグ 原点 X 座標 attr_reader :fog_oy # フォグ 原点 Y 座標 attr_reader :fog_tone # フォグ 色調 #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- alias :base_main :main def main # フォグの各情報を初期化 if $game_temp.fog_initialize @fog_name = $game_map.fog_name @fog_hue = $game_map.fog_hue @fog_opacity = $game_map.fog_opacity @fog_blend_type = $game_map.fog_blend_type @fog_zoom = $game_map.fog_zoom @fog_sx = $game_map.fog_sx @fog_sy = $game_map.fog_sy else @fog_name = "" @fog_hue = 0 @fog_opacity = 0 @fog_blend_type = 0 @fog_zoom = 100 @fog_sx = 0 @fog_sy = 0 end @fog_ox = 0 @fog_oy = 0 @fog_tone = Tone.new(0, 0, 0, 0) @fog_tone_target = Tone.new(0, 0, 0, 0) @fog_tone_duration = 0 @fog_opacity_duration = 0 @fog_opacity_target = 0 base_main end #-------------------------------------------------------------------------- # ● フレーム更新(再定義) #-------------------------------------------------------------------------- alias :base_update :update def update # フォグのスクロール処理 @fog_ox -= @fog_sx / 8.0 @fog_oy -= @fog_sy / 8.0 # フォグの色調変更処理 if @fog_tone_duration >= 1 d = @fog_tone_duration target = @fog_tone_target @fog_tone.red = (@fog_tone.red * (d - 1) + target.red) / d @fog_tone.green = (@fog_tone.green * (d - 1) + target.green) / d @fog_tone.blue = (@fog_tone.blue * (d - 1) + target.blue) / d @fog_tone.gray = (@fog_tone.gray * (d - 1) + target.gray) / d @fog_tone_duration -= 1 end # フォグの不透明度変更処理 if @fog_opacity_duration >= 1 d = @fog_opacity_duration @fog_opacity = (@fog_opacity * (d - 1) + @fog_opacity_target) / d @fog_opacity_duration -= 1 end base_update end #-------------------------------------------------------------------------- # ● フォグの色調変更の開始 # tone : 色調 # duration : 時間 #-------------------------------------------------------------------------- def start_fog_tone_change(tone, duration) @fog_tone_target = tone.clone @fog_tone_duration = duration if @fog_tone_duration == 0 @fog_tone = @fog_tone_target.clone end end #-------------------------------------------------------------------------- # ● フォグの不透明度変更の開始 # opacity : 不透明度 # duration : 時間 #-------------------------------------------------------------------------- def start_fog_opacity_change(opacity, duration) @fog_opacity_target = opacity * 1.0 @fog_opacity_duration = duration if @fog_opacity_duration == 0 @fog_opacity = @fog_opacity_target end end end