赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 290 |
最后登录 | 2013-6-12 |
在线时间 | 11 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 11 小时
- 注册时间
- 2013-6-6
- 帖子
- 11
|
7楼
楼主 |
发表于 2013-6-9 23:44:55
|
只看该作者
喵呜喵5 发表于 2013-6-9 23:41
这脚本真的只有这么一段?会不会漏了什么内容啊………… - class Window_MapList < Window_ItemList
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- self.height = fitting_height(1)
- self.arrows_visible = false
- make_item_list
- create_contents
- select_map($game_map.current_map_data)
- refresh
- select_map(current_map_adjust)
- self.opacity = 0
- end
- #--------------------------------------------------------------------------
- # ● 最大欄數
- #--------------------------------------------------------------------------
- def col_max
- return 1
- end
- #--------------------------------------------------------------------------
- # ● 判斷是否有效
- #--------------------------------------------------------------------------
- def enable?(map=@data[index])
- return map.can_use?
- end
- #--------------------------------------------------------------------------
- # ● 返回當前選中的地圖
- #--------------------------------------------------------------------------
- def map
- return item
- end
- #--------------------------------------------------------------------------
- # ● 返回全部地圖
- #--------------------------------------------------------------------------
- def maps
- return @data
- end
- #--------------------------------------------------------------------------
- # ● 生成項目列表
- #--------------------------------------------------------------------------
- def make_item_list
- $data_maps.each_value{|map|
- @data.push(map) if map.can_list?
- }
- if @data.empty?
- @data.push(nil)
- else
- @sort_map_x = @data.sort{|a, b| a.world_x <=> b.world_x}
- @sort_map_y = @data.sort{|a, b| a.world_y <=> b.world_y}
- end
- end
- #--------------------------------------------------------------------------
- # ● 繪製項目
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- if map
- # 獲取文字顏色
- change_color(text_color(map.name_color), enable?(map))
- width = text_size(map.name).width
- x = (self.width - width)/2
- make_font_smaller # 文字大小變小
- draw_text(x, 0, 172, line_height, map.name)
- reset_font_settings # 重設文字設定
- # 調整座標
- x = map.world_x - self.width/2
- bitmap = Cache.load_map(map.world_img)
- y = map.world_y + bitmap.height/2 - self.standard_padding
- y += help_window.height if help_window
- self.x = x
- self.y = y
- end
- end
- #--------------------------------------------------------------------------
- # ● 獲取文字顏色
- #--------------------------------------------------------------------------
- def change_color(color, enabled = true)
- if enabled
- contents.font.color.set(color)
- else
- contents.font.color.set(Color.new(100, 100, 100))
- end
- end
- #--------------------------------------------------------------------------
- # ● 按下方向左鍵
- #--------------------------------------------------------------------------
- def cursor_left(wrap = false)
- change_curser(@sort_map_x, 4)
- end
- #--------------------------------------------------------------------------
- # ● 按下方向右鍵
- #--------------------------------------------------------------------------
- def cursor_right(wrap = false)
- change_curser(@sort_map_x, 6)
- end
- #--------------------------------------------------------------------------
- # ● 按下方向上鍵
- #--------------------------------------------------------------------------
- def cursor_up(wrap = false)
- change_curser(@sort_map_y, 8)
- end
- #--------------------------------------------------------------------------
- # ● 按下方向下鍵
- #--------------------------------------------------------------------------
- def cursor_down(wrap = false)
- change_curser(@sort_map_y, 2)
- end
- #--------------------------------------------------------------------------
- # ● 按下方向鍵
- #--------------------------------------------------------------------------
- def change_curser(array, direction)
- return if array.nil? || array.empty?
- #return unless array.include?(map)
- index = array.index(current_map_adjust)
- case direction
- when 4, 8 # 按左右鍵時
- if index == 0
- index = array.size - 1
- else
- index -= 1
- end
- when 2, 6 # 按上下鍵時
- if index == array.size-1
- index = 0
- else
- index += 1
- end
- else
- return
- end
- real_index = @data.index(array[index]) # 獲取真實index
- select(real_index) # 選擇地圖
- refresh # 刷新窗口
- end
- def current_map_adjust
- return map if map
- actual_map = $data_maps[$game_map.current_map_data.parent_id_on_map]
- return actual_map
- end
- #--------------------------------------------------------------------------
- # ● 更新游標
- #--------------------------------------------------------------------------
- def update_cursor
- cursor_rect.empty if cursor_rect.height > 0 # 將游標隱藏
- end
- #--------------------------------------------------------------------------
- # ● 選擇地圖
- #--------------------------------------------------------------------------
- def select_map(map)
- i = @data.index(map)
- select(i)
- end
- end
- class Window_MapChoices < Window_Command
- #--------------------------------------------------------------------------
- # ● 生成命令
- #--------------------------------------------------------------------------
- def make_command_list
- add_command("傳送到這裡", :transfer)
- add_command("詳細資料", :description)
- end
- #--------------------------------------------------------------------------
- # ● 設置命令有效度
- #--------------------------------------------------------------------------
- def set_command_enable(index, enable)
- @list[index][:enabled] = enable
- redraw_item(index)
- end
- end
- class Window_MapDetail < Window_Selectable
- attr_reader :map
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @map = nil
- @show_desc = false
- end
- #--------------------------------------------------------------------------
- # ● 設置地圖
- #--------------------------------------------------------------------------
- def map=(m)
- @map = m
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 窗口刷新
- #--------------------------------------------------------------------------
- def refresh
- return unless @map
- contents.clear
- if @map.detail_image != ""
- draw_detail_image
- else
- @show_desc = @map.full_desc != ""
- end
- draw_full_desc if @show_desc
- end
- #--------------------------------------------------------------------------
- # ● 繪製詳細圖像
- #--------------------------------------------------------------------------
- def draw_detail_image
- dest_rect = Rect.new(0, 0, self.width-24, self.height-24)
- src_bitmap = Cache.load_map(@map.detail_image)
- src_rect = Rect.new(0, 0, src_bitmap.width, src_bitmap.height)
- opacity = @show_desc ? 128 : 255
- contents.stretch_blt(dest_rect, src_bitmap, src_rect, opacity)
- end
- #--------------------------------------------------------------------------
- # ● 繪製詳細資訊
- #--------------------------------------------------------------------------
- def draw_full_desc
- draw_text_ex(0, 0, @map.full_desc)
- end
- #--------------------------------------------------------------------------
- # ● 按下確認鍵時
- #--------------------------------------------------------------------------
- def process_ok
- if @map.full_desc != ""
- Sound.play_ok
- @show_desc = !@show_desc
- refresh
- else
- Sound.play_buzzer
- end
- end
- end
- class Scene_WorldMap < Scene_Base
- #--------------------------------------------------------------------------
- # ● 場景開始
- #--------------------------------------------------------------------------
- def start
- super
- @sprites=[]
- create_map_description_window
- create_map_list_window
- create_choice_window
- create_map_detail_window
- create_world_map
- create_location_sprite
- create_player_sprite
- end
- #--------------------------------------------------------------------------
- # ● 生成地圖列表窗口
- #--------------------------------------------------------------------------
- def create_map_list_window
- y = @map_desc_window.height
- @map_list_window = Window_MapList.new(0, y, 160, Graphics.height-48)
- @map_list_window.viewport = @viewport
- @map_list_window.set_handler(:ok, method(:on_map_ok))
- @map_list_window.set_handler(:cancel, method(:on_map_cancel))
- @map_list_window.help_window = @map_desc_window
- @map_list_window.refresh
- @map_list_window.activate
- @current_map = $game_map.current_map_data
- @selected_map = @map_list_window.map
- end
- #--------------------------------------------------------------------------
- # ● 生成地圖說明窗口
- #--------------------------------------------------------------------------
- def create_map_description_window
- @map_desc_window = Window_Help.new(1)
- end
- #--------------------------------------------------------------------------
- # ● 生成選項窗口
- #--------------------------------------------------------------------------
- def create_choice_window
- @choice_window = Window_MapChoices.new(0, 0)
- @choice_window.x = (Graphics.width - @choice_window.width)/2
- @choice_window.y = (Graphics.height - @choice_window.height)/2
- @choice_window.viewport = @viewport
- @choice_window.set_handler(:transfer, method(:do_player_transfer))
- @choice_window.set_handler(:description, method(:show_full_desc))
- @choice_window.set_handler(:cancel, method(:choice_cancel))
- @choice_window.deactivate.hide
- end
- #--------------------------------------------------------------------------
- # ● 生成詳細資訊窗口
- #--------------------------------------------------------------------------
- def create_map_detail_window
- y = @map_desc_window.height
- width = 384
- height = Graphics.height - y
- @detail_window = Window_MapDetail.new(0, y, width, height)
- @detail_window.x = (Graphics.width - @detail_window.width)/2
- @detail_window.viewport = @viewport
- @detail_window.set_handler(:ok, method(:update))
- @detail_window.set_handler(:cancel, method(:detail_cancel))
- @detail_window.deactivate.hide
- end
- #--------------------------------------------------------------------------
- # ● 生成世界地圖精靈
- #--------------------------------------------------------------------------
- def create_world_map
- @world_map_sprite = Sprite.new(@viewport)
- src_bitmap = Cache.load_map("world")
- width = Graphics.width
- height = Graphics.height - @map_desc_window.height
- dest_bitmap = Bitmap.new(width, height)
- dest_bitmap.stretch_blt(dest_bitmap.rect, src_bitmap, src_bitmap.rect)
- @world_map_sprite.bitmap = dest_bitmap
- @world_map_sprite.x = 0
- @world_map_sprite.y = @map_desc_window.height
- @sprites.push(@world_map_sprite)
- end
- #--------------------------------------------------------------------------
- # ● 生成當前主角精靈
- #--------------------------------------------------------------------------
- def create_player_sprite
- @player_sprite = Sprite.new(@viewport)
- @player_sprite.bitmap = Cache.load_map("player")
- update_player_sprite
- @player_sprite.x = @current_map.player_x - @player_sprite.width/2
- @player_sprite.y = @current_map.player_y - @player_sprite.height/2
- @player_sprite.x += sprite_dx
- @player_sprite.y += sprite_dy
- @player_sprite.z = @selected_sprite.z + 10
- @sprites.push(@player_sprite)
- end
- #--------------------------------------------------------------------------
- # ● 生成地圖位置精靈
- #--------------------------------------------------------------------------
- def create_location_sprite
- @location_sprites= []
- @map_list_window.maps.each{ |map|
- l_sprite = Sprite.new(@viewport)
- create_a_map_sprite(l_sprite, map)
- @location_sprites.push(l_sprite)
- }
- update_location_sprites
- @selected_sprite = Sprite.new(@viewport)
- @sprites.push(@selected_sprite)
- @sprites += @location_sprites
- create_select_sprite
- end
- #--------------------------------------------------------------------------
- # ● 生成選擇精靈
- #--------------------------------------------------------------------------
- def create_select_sprite
- create_a_map_sprite(@selected_sprite, @selected_map, "select")
- @selected_sprite.z = current_sprite.z+10
- end
- #--------------------------------------------------------------------------
- # ● 生成一個地圖位置精靈
- #--------------------------------------------------------------------------
- def create_a_map_sprite(sprite, map, image="")
- return unless map
- image = map.world_img if image==""
- sprite.bitmap = Cache.load_map(image)
- sprite.x = map.world_x - sprite.width/2
- sprite.y = map.world_y - sprite.height/2
- sprite.x += sprite_dx
- sprite.y += sprite_dy
- end
- #--------------------------------------------------------------------------
- # ● 選擇地圖結束
- #--------------------------------------------------------------------------
- def on_map_ok
- @map_list_window.deactivate
- @choice_window.set_command_enable(0, @selected_map.can_transfer?)
- @choice_window.set_command_enable(1, @selected_map.known?)
- @choice_window.activate.show
- end
- #--------------------------------------------------------------------------
- # ● 執行角色傳送
- #--------------------------------------------------------------------------
- def do_player_transfer
- map = @map_list_window.map
- id = map.id
- x = map.land_x
- y = map.land_y
- $game_player.reserve_transfer(id, x, y)
- SceneManager.goto(Scene_Map)
- end
- #--------------------------------------------------------------------------
- # ● 返回地圖場景
- #--------------------------------------------------------------------------
- def on_map_cancel
- SceneManager.call(Scene_Map)
- end
- #--------------------------------------------------------------------------
- # ● 顯示詳細資訊窗口
- #--------------------------------------------------------------------------
- def show_full_desc
- @detail_window.activate.show
- @detail_window.map = @selected_map
- @choice_window.deactivate.hide
- end
- #--------------------------------------------------------------------------
- # ● 取消選項
- #--------------------------------------------------------------------------
- def choice_cancel
- @map_list_window.activate
- @choice_window.deactivate.hide
- end
- #--------------------------------------------------------------------------
- # ● 跳出詳細資訊窗口
- #--------------------------------------------------------------------------
- def detail_cancel
- @detail_window.deactivate.hide
- @map_list_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 場景更新
- #--------------------------------------------------------------------------
- def update
- super
- update_player_sprite
- update_location_sprites
- $game_player.perform_transfer if $game_player.transfer?
- end
- #--------------------------------------------------------------------------
- # ● 更新主角精靈
- #--------------------------------------------------------------------------
- def update_player_sprite
- cw = @player_sprite.bitmap.width/3
- ch = @player_sprite.bitmap.height
- player_rect = Rect.new(0, 0, cw, ch)
- sx = Graphics.frame_count/24%4
- player_rect.x = sx*cw
- player_rect.x = cw if sx==3
- @player_sprite.src_rect.set(player_rect)
- end
- #--------------------------------------------------------------------------
- # ● 更新位置精靈
- #--------------------------------------------------------------------------
- def update_location_sprites
- if @selected_map != @map_list_window.map
- @selected_map = @map_list_window.map
- @selected_sprite.x = current_sprite.x
- @selected_sprite.y = current_sprite.y
- end
- end
- #--------------------------------------------------------------------------
- # ● 獲取精靈位移座標
- #--------------------------------------------------------------------------
- def sprite_dx
- @world_map_sprite.x
- end
- def sprite_dy
- @world_map_sprite.y
- end
- #--------------------------------------------------------------------------
- # ● 獲取當前選中的地圖的精靈
- #--------------------------------------------------------------------------
- def current_sprite
- return @location_sprites[@map_list_window.index]
- end
- end
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ● 呼叫世界地圖場景
- #--------------------------------------------------------------------------
- def call_world_map
- SceneManager.call(Scene_WorldMap)
- end
- #--------------------------------------------------------------------------
- # ● 手動設定「已知」標記
- #--------------------------------------------------------------------------
- def know_map(id)
- $data_maps[id].know
- end
- #--------------------------------------------------------------------------
- # ● 取消「已知」標記
- #--------------------------------------------------------------------------
- def unknow_map(id)
- $data_maps[id].unknow
- end
- #--------------------------------------------------------------------------
- # ● 取消「已造訪」標記
- #--------------------------------------------------------------------------
- def unvisit_map(id)
- $data_maps[id].unvisit
- end
- end
复制代码 还有个这个脚本 只有这两个脚本 |
|