#============================================================================== # ■ XP-RGSS-50 ワールドマップ [シーン] by Claimh #============================================================================== #============================================================================== # ■ Scene_WorldMap #------------------------------------------------------------------------------ # ワールドマップ処理 #============================================================================== class Scene_WorldMap #-------------------------------------------------------------------------- # ● オブジェクト初期化 # back: キャンセル時のプレイヤーの移動位置 # 0, 5: 移動なし # 1: 左下に1歩移動 # 2: 下に1歩移動 # 3: 右下に1歩移動 # 4: 左に1歩移動 # 6: 右に1歩移動 # 7: 左上に1歩移動 # 8: 上に1歩移動 # 9: 右上に1歩移動 # direction : キャンセル時の向き(2:下 4:左 6:右 8:上 0:そのまま) #-------------------------------------------------------------------------- def initialize(back=0, direction=0) x = $game_player.x y = $game_player.y case back # 戻る方向に応じてプレイヤー位置を決める when 1; x -= 1; y += 1 when 2; y += 1; when 3; x += 1; y += 1 when 4; x -= 1 when 6; x += 1 when 7; x -= 1; y -= 1 when 8; y -= 1 when 9; x += 1 end @player_pos = WorldMap::Position.new(x, y, direction) @enter_new_map = false end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main start # 開始処理 # トランジション実行 file = WorldMap::W_TRAN_F.nil? ? "": ("Graphics/Transitions/"+WorldMap::W_TRAN_F) Graphics.transition(WorldMap::W_TRAN_T, file) loop do Graphics.update # ゲーム画面を更新 Input.update # 入力情報を更新 update # フレーム更新 break if $scene != self # 画面が切り替わったらループを中断 end Graphics.update # 移動地点選択処理 if WorldMap::W_ENTER_EFFECT and WorldMap::W_CENTARING enter_effect end Graphics.freeze # トランジション準備 terminate # 終了処理 end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start # BGM再生 Audio.bgm_play("Audio/bgm/" + WorldMap::W_BGM) unless WorldMap::W_BGM.nil? # 現在のマップIDからリージョン情報とタウン情報を取得 town_data = $game_system.worldmap.get_mapid_to_town($game_map.map_id) region_data = $game_system.worldmap[town_data.region_id] # 現在地のマップを強制表示ONにする region_data.visible = true region_data.enable = true town_data.visible = true town_data.enable = true # ビューポート初期化 @viewport = Viewport.new(0, 0, 640, 480) # 背景オブジェクト作成 @picture = Game_MapPicture.new(town_data.region_id) @picture.show_center(region_data.region_map) @sprite = Sprite_MapPicture.new(@viewport, @picture) # ポイントアロー作成 @point_arrow = Arrow_TownPoint.new(@viewport) # 地点位置の特定 @point_arrow.update_point(town_data.map_pos, town_data.icon.nil?) # 説明ウィンドウ作成 @text_window = Window_WorldInfo.new # 地域名リスト取得 @region_list = $game_system.worldmap.make_region_list # 地点名リスト取得 @town_list = $game_system.worldmap.make_town_list(region_data) # 地点名ウィンドウ作成 @name_window = Window_TownName.new # 地点ウィンドウ初期化 @town_window = Window_Town.new(@town_list, town_data.town_id) @town_window.active = true # 関連ウィンドウの連結 @town_window.help_arrow = @point_arrow @town_window.move_sprite = @picture @town_window.town_window = @name_window @town_window.help_window = @text_window # 地域ウィンドウ初期化 @region_window = Window_Region.new(@region_list, region_data.region_id) @region_window.active = false # 関連ウィンドウの連結 @region_window.help_window = nil @region_window.back_sprite = @picture @region_window.town_window = @town_window if WorldMap::USE_LIST if !WorldMap::USE_REGION @region_window.visible = false elsif WorldMap::RESIZE_REGION @region_window.resize_height end else @region_window.visible = false @town_window.visible = false end end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate # ウィンドウなどを解放 @viewport.dispose @sprite.dispose @region_window.dispose @town_window.dispose @name_window.dispose @text_window.dispose @point_arrow.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update @sprite.update if WorldMap::USE_LIST if @region_window.active @region_window.update update_region elsif @town_window.active @town_window.update @point_arrow.update update_town end else @town_window.update_help @point_arrow.update update_point end end #-------------------------------------------------------------------------- # ● 地域ウィンドウがアクティブ #-------------------------------------------------------------------------- def update_region if Input.trigger?(Input::C) or Input.trigger?(Input::RIGHT) unless @town_window.visible and @region_window.r_enable? # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # タウンウィンドウを展開 @town_window.active = true @town_window.visible = true @town_window.index = 0 @town_window.z = 50 # リージョンウィンドウを凍結 @region_window.active = false @region_window.z = 30 @region_window.resize_height if WorldMap::RESIZE_REGION # ヘルプウィンドウ切り替え @region_window.help_window = nil @town_window.help_window = @text_window @town_window.update_help return end # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # 現在位置に戻る return_current_map return end end #-------------------------------------------------------------------------- # ● 地点ウィンドウがアクティブ #-------------------------------------------------------------------------- def update_town if Input.trigger?(Input::C) unless @town_window.t_enable? # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) ### 転送処理 ### change_map(@town_window.return_town) @enter_new_map = true return end # B ボタンが押された場合 if Input.trigger?(Input::B) or Input.trigger?(Input::LEFT) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) unless @region_window.visible # ポイントアロー消去 @point_arrow.visible = false WorldMap::T_CANCEL_LOCK ? @town_window.cancel_current : @town_window.cancel # 現在位置に戻る return_current_map return end # タウンウィンドウを展開 @town_window.active = false @town_window.index = -1 @town_window.z = 30 # リージョンウィンドウをアクティブ @region_window.reset_height if WorldMap::RESIZE_REGION @region_window.active = true @region_window.z = 50 # ヘルプウィンドウ切り替え @town_window.help_window = nil @region_window.help_window = @text_window @region_window.p_updete_help # ポイントアロー消去 @point_arrow.visible = false # 地点名ウィンドウ消去 @name_window.visible = false @town_window.cancel return end end #-------------------------------------------------------------------------- # ● ポイントのみ更新 #-------------------------------------------------------------------------- def update_point if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) # キャンセル SE を演奏 @point_arrow.visible = false # ポイントアロー消去 @name_window.visible = false # 地点名ウィンドウ消去 WorldMap::T_CANCEL_LOCK ? @town_window.cancel_current : @town_window.cancel return_current_map # 現在位置に戻る elsif Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) ### 転送処理 ### change_map(@town_window.return_town) @enter_new_map = true elsif Input.repeat?(Input::L) or Input.repeat?(Input::R) if WorldMap::USE_REGION tmp_index = @region_window.index @region_window.update_LR if tmp_index != @region_window.index @point_arrow.visible = false # ポイントアロー消去 @name_window.visible = false # 地点名ウィンドウ消去 @town_window.cancel end end elsif Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN) or Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT) @point_arrow.visible = false # ポイントアロー消去 @name_window.visible = false # 地点名ウィンドウ消去 @town_window.update_dir4 end end #-------------------------------------------------------------------------- # ● 現在位置復帰処理 #-------------------------------------------------------------------------- def return_current_map # マップをセットアップ $game_map.setup($game_map.map_id) # プレイヤーを移動 $game_player.moveto(@player_pos.x, @player_pos.y) # プレイヤーの向きを設定 case @player_pos.d when 2; $game_player.turn_down when 4; $game_player.turn_left when 6; $game_player.turn_right when 8; $game_player.turn_up end # プレイヤーの姿勢を矯正 $game_player.straighten # 元のBGMを再生 $game_system.bgm_play($game_system.playing_bgm) # マップを更新 (並列イベント実行) $game_map.update # マップ画面に切り替え $scene = Scene_Map.new end #-------------------------------------------------------------------------- # ● ポイント移動処理 #-------------------------------------------------------------------------- def change_map(town) # マップをセットアップ $game_map.setup(town.map_id) # プレイヤーを移動 $game_player.moveto(town.player.x, town.player.y) # 向きを決定 case town.player.d when 2; $game_player.turn_down when 4; $game_player.turn_left when 6; $game_player.turn_right when 8; $game_player.turn_up end # プレイヤーの姿勢を矯正 $game_player.straighten # マップに設定されている BGM と BGS の自動切り替えを実行 $game_map.autoplay # マップを更新 (並列イベント実行) $game_map.update # マップ画面に切り替え $scene = Scene_Map.new end #-------------------------------------------------------------------------- # ● 全ウィンドウの透明度設定 #-------------------------------------------------------------------------- def set_all_opacity(opacity) @sprite.opacity = opacity if WorldMap::USE_LIST @region_window.opacity = opacity @town_window.opacity = opacity end @text_window.opacity = opacity @point_arrow.opacity = opacity end #-------------------------------------------------------------------------- # ● 全ウィンドウのコンテンツ透明度設定 #-------------------------------------------------------------------------- def set_all_contents_opacity(opacity) if WorldMap::USE_LIST @region_window.contents_opacity = opacity @town_window.contents_opacity = opacity end @text_window.contents_opacity = opacity @name_window.contents_opacity = opacity end #-------------------------------------------------------------------------- # ● 移動地点選択処理 #-------------------------------------------------------------------------- def enter_effect if @enter_new_map # ニューマップへ移動 enter_new_map else # カレントマップへ移動 enter_current_map end time = WorldMap::W_ENTER_ZOOM_T # 画面更新 for i in 0...time @sprite.update @point_arrow.update set_all_opacity((WorldMap::W_SKIN_OPACITY / time) * (time - i)) set_all_contents_opacity((255 / time) * (time - i)) Graphics.update end end #-------------------------------------------------------------------------- # ● ニューマップ移動処理 #-------------------------------------------------------------------------- def enter_new_map unless WorldMap::W_ENTER_SE.nil? Audio.se_play("Audio/SE/" + WorldMap::W_ENTER_SE) end @picture.move(WorldMap::W_ENTER_ZOOM_T, @town_window.return_town.map_pos.x, @town_window.return_town.map_pos.y, WorldMap::W_ENTER_Z, WorldMap::W_ENTER_Z, 255, 0) @point_arrow.change_char_back if WorldMap::W_ARROW_TYPE end #-------------------------------------------------------------------------- # ● カレントマップ移動処理 #-------------------------------------------------------------------------- def enter_current_map @picture.move(WorldMap::W_ENTER_ZOOM_T, @picture.center_x, @picture.center_y, WorldMap::W_CANCEL_Z, WorldMap::W_CANCEL_Z, 255, 0) end end