#============================================================================== # ■ VXAce-RGSS3-33 ワールドマップ [シーン] by Claimh #============================================================================== #============================================================================== # ■ Scene_WorldMap #============================================================================== class Scene_WorldMap < Scene_Base #-------------------------------------------------------------------------- # ● オブジェクト初期設定 # back: キャンセル時のプレイヤーの移動位置 # 0, 5: 移動なし # -1:一方後ろへ # 1: 左下に1歩移動 # 2: 下に1歩移動 # 3: 右下に1歩移動 # 4: 左に1歩移動 # 6: 右に1歩移動 # 7: 左上に1歩移動 # 8: 上に1歩移動 # 9: 右上に1歩移動 # direction : キャンセル時の向き(2:下 4:左 6:右 8:上 0:そのまま) #-------------------------------------------------------------------------- def prepare(back=0, direction=0) x = $game_player.x y = $game_player.y d = $game_player.direction case back # 戻る方向に応じてプレイヤー位置を決める when -1; case d when 2; y -= 1 when 4; x += 1 when 6; y -= 1 when 8; y += 1 end 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 player_back end #-------------------------------------------------------------------------- # ● トランジション実行 #-------------------------------------------------------------------------- def perform_transition file = WorldMap::W_TRAN_F.nil? ? "": ("Graphics/System/"+WorldMap::W_TRAN_F) Graphics.transition(transition_speed, file) end #-------------------------------------------------------------------------- # ● トランジション速度の取得 #-------------------------------------------------------------------------- def transition_speed WorldMap::W_TRAN_T end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start start_bgm show_current_region_town super create_background create_info_window create_arrow_sprite create_name_window create_town_window create_region_window reset_current disable_list end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_arrow_sprite dispose_background end #-------------------------------------------------------------------------- # ● 終了前処理 #-------------------------------------------------------------------------- def pre_terminate enter_effect if WorldMap::W_ENTER_EFFECT and WorldMap::W_CENTARING end #-------------------------------------------------------------------------- # ● BGM開始 #-------------------------------------------------------------------------- def start_bgm return if WorldMap::W_BGM.nil? $game_system.save_bgm WorldMap::W_BGM.play end #-------------------------------------------------------------------------- # ● BGM再開 #-------------------------------------------------------------------------- def restart_bgm return if WorldMap::W_BGM.nil? $game_system.replay_bgm end #-------------------------------------------------------------------------- # ● 現在地点の表示ON #-------------------------------------------------------------------------- def show_current_region_town town = $game_system.worldmap.get_mapid_to_town($game_map.map_id) $game_system.worldmap[town.region_id].visible = true town.visible = true end #-------------------------------------------------------------------------- # ● 現在地点へ #-------------------------------------------------------------------------- def reset_current @region_window.reset @region_window.update_help @town_window.reset end #-------------------------------------------------------------------------- # ● リストを非表示へ #-------------------------------------------------------------------------- def disable_list @region_window.deactivate.hide unless WorldMap::USE_REGION @town_window.deactivate.hide unless WorldMap::USE_LIST end #-------------------------------------------------------------------------- # ● リージョンウィンドウ生成 #-------------------------------------------------------------------------- def create_region_window @region_window = Window_Region.new @region_window.deactivate @region_window.back_sprite = @back_sprite @region_window.town_window = @town_window @region_window.help_window = @info_window @region_window.set_handler(:ok, method(:on_region_ok)) @region_window.set_handler(:cancel, method(:on_region_cancel)) end #-------------------------------------------------------------------------- # ● リージョンウィンドウ : 選択 #-------------------------------------------------------------------------- def on_region_ok @town_window.activate @region_window.resize_height end #-------------------------------------------------------------------------- # ● リージョンウィンドウ : キャンセル #-------------------------------------------------------------------------- def on_region_cancel return_current_map end #-------------------------------------------------------------------------- # ● タウンウィンドウ生成 #-------------------------------------------------------------------------- def create_town_window @town_window = Window_Town.new @town_window.back_sprite = @back_sprite @town_window.name_window = @name_window @town_window.help_window = @info_window @town_window.set_handler(:ok, method(:on_town_ok)) @town_window.set_handler(:cancel, method(:on_town_cancel)) end #-------------------------------------------------------------------------- # ● タウンウィンドウ : 選択 #-------------------------------------------------------------------------- def on_town_ok change_map end #-------------------------------------------------------------------------- # ● タウンウィンドウ : キャンセル #-------------------------------------------------------------------------- def on_town_cancel if WorldMap::USE_REGION @region_window.activate.reset_height @name_window.hide @back_sprite.picture.move_center else return_current_map end end #-------------------------------------------------------------------------- # ● 名前ウィンドウ生成 #-------------------------------------------------------------------------- def create_name_window @name_window = Window_TownName.new @name_window.arrow = @arrow_sprite end #-------------------------------------------------------------------------- # ● 名前ウィンドウ生成 #-------------------------------------------------------------------------- def create_arrow_sprite @arrow_sprite = Arrow_TownPoint.new end #-------------------------------------------------------------------------- # ● 背景の解放 #-------------------------------------------------------------------------- def dispose_arrow_sprite @arrow_sprite.dispose end #-------------------------------------------------------------------------- # ● 情報ウィンドウ生成 #-------------------------------------------------------------------------- def create_info_window @info_window = Window_WorldInfo.new end #-------------------------------------------------------------------------- # ● 背景の生成 #-------------------------------------------------------------------------- def create_background @back_sprite = Sprite_WorldMapPicture.new end #-------------------------------------------------------------------------- # ● 背景の解放 #-------------------------------------------------------------------------- def dispose_background @back_sprite.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_sprite update_moving update_position unless WorldMap::USE_LIST end #-------------------------------------------------------------------------- # ● スプライト更新 #-------------------------------------------------------------------------- def update_sprite @back_sprite.update @arrow_sprite.update end #-------------------------------------------------------------------------- # ● ポイント表示/非表示 #-------------------------------------------------------------------------- def show_point @name_window.show unless @name_window.visible @arrow_sprite.show unless @arrow_sprite.visible end def hide_point @name_window.hide if @name_window.visible @arrow_sprite.hide if @arrow_sprite.visible end #-------------------------------------------------------------------------- # ● 移動中処理 #-------------------------------------------------------------------------- def update_moving if @back_sprite.picture.move_finish? (@town_window.active or !WorldMap::USE_LIST) ? show_point : hide_point else hide_point end end #-------------------------------------------------------------------------- # ● リスト非表示時のカーソル移動 #-------------------------------------------------------------------------- def update_position return @town_window.process_ok if @town_window.ok_enabled? && Input.trigger?(:C) return @town_window.process_cancel if @town_window.cancel_enabled? && Input.trigger?(:B) tmp = @town_window.index if Input.repeat?(:UP) or Input.repeat?(:DOWN) or Input.repeat?(:RIGHT) or Input.repeat?(:LEFT) update_index(Input.dir4) end if tmp != @town_window.index Sound.play_cursor @town_window.update_help end end # change index def update_index(dir) ud = (dir == 2 or dir == 8) plus = (dir == 2 or dir == 6) list = WorldMap::CUR_MAP_POS ? (ud ? list_ud : list_lr) : @town_window.list i = list_search(list, @town_window.data.town_id) i = plus ? ((i + 1) % list.size) : ((i - 1 + list.size) % list.size) @town_window.index = list_search(@town_window.list, list[i].town_id) end # town_id -> list.index def list_search(list, town_id) list.each_with_index {|town, i| return i if town.town_id == town_id} return 0 end # sort up-down list def list_ud @town_window.list.sort {|a,b| a.map_pos.y - b.map_pos.y } end # sort left-right list def list_lr @town_window.list.sort {|a,b| a.map_pos.x - b.map_pos.x } end #-------------------------------------------------------------------------- # ● 現在位置復帰処理 #-------------------------------------------------------------------------- def return_current_map restart_bgm $game_player.moveto(@player_pos.x, @player_pos.y) $game_player.set_direction(@player_pos.d) $game_player.straighten return_scene end #-------------------------------------------------------------------------- # ● ポイント移動処理 #-------------------------------------------------------------------------- def change_map @enter_new_map = true $game_map.setup(@town_window.data.map_id) $game_player.moveto(@town_window.data.player.x, @town_window.data.player.y) $game_player.set_direction(@town_window.data.player.d) $game_player.straighten $game_map.autoplay $game_map.update SceneManager.goto(Scene_Map) end #-------------------------------------------------------------------------- # ● 全ウィンドウ/スプライト #-------------------------------------------------------------------------- def objects [@arrow_sprite] + windows end def windows obj = [@info_window, @name_window] obj.push(@region_window) if WorldMap::USE_LIST and WorldMap::USE_REGION obj.push(@town_window) if WorldMap::USE_LIST obj end #-------------------------------------------------------------------------- # ● 全ウィンドウの透明度設定 #-------------------------------------------------------------------------- def set_all_opacity(opacity) objects.each {|obj| obj.opacity = opacity} end #-------------------------------------------------------------------------- # ● 全ウィンドウのコンテンツ透明度設定 #-------------------------------------------------------------------------- def set_all_contents_opacity(opacity) windows.each {|win| win.contents_opacity = opacity} end #-------------------------------------------------------------------------- # ● 移動地点選択処理 #-------------------------------------------------------------------------- def enter_effect @enter_new_map ? enter_new_map : enter_current_map time = WorldMap::W_ENTER_ZOOM_T time.times do |i| set_all_opacity((@info_window.opacity / time) * (time - i)) set_all_contents_opacity((255 / time) * (time - i)) update_sprite Graphics.update end end #-------------------------------------------------------------------------- # ● ニューマップ移動処理 #-------------------------------------------------------------------------- def enter_new_map WorldMap::W_ENTER_SE.play unless WorldMap::W_ENTER_SE.nil? @back_sprite.picture.fadein @arrow_sprite.change_char_back if WorldMap::W_ARROW_TYPE end #-------------------------------------------------------------------------- # ● カレントマップ移動処理 #-------------------------------------------------------------------------- def enter_current_map @back_sprite.picture.fadeout end end