设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索

关于世界地图传送功能

查看数: 3472 | 评论数: 8 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2013-6-9 18:58

正文摘要:

RT,这是什么意思?

回复

weiz 发表于 2013-6-13 18:10:51
这是原来自带的脚本吗?如果是,你会不会不小心更改了什么?
xTsukihime 发表于 2013-6-10 11:31:03
本帖最后由 xTsukihime 于 2013-6-10 11:47 编辑

238: map_data_setup

?
rf520 发表于 2013-6-9 23:44:55
喵呜喵5 发表于 2013-6-9 23:41
这脚本真的只有这么一段?会不会漏了什么内容啊…………
  1. class Window_MapList < Window_ItemList
  2.   #--------------------------------------------------------------------------
  3.   # ● 初始化
  4.   #--------------------------------------------------------------------------
  5.   def initialize(x, y, width, height)
  6.     super(x, y, width, height)
  7.     self.height = fitting_height(1)
  8.     self.arrows_visible = false
  9.     make_item_list
  10.     create_contents
  11.     select_map($game_map.current_map_data)
  12.     refresh
  13.     select_map(current_map_adjust)
  14.     self.opacity = 0
  15.   end
  16.   #--------------------------------------------------------------------------
  17.   # ● 最大欄數
  18.   #--------------------------------------------------------------------------
  19.   def col_max
  20.     return 1
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 判斷是否有效
  24.   #--------------------------------------------------------------------------
  25.   def enable?(map=@data[index])
  26.     return map.can_use?
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 返回當前選中的地圖
  30.   #--------------------------------------------------------------------------
  31.   def map
  32.     return item
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 返回全部地圖
  36.   #--------------------------------------------------------------------------
  37.   def maps
  38.     return @data
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 生成項目列表
  42.   #--------------------------------------------------------------------------
  43.   def make_item_list
  44.     $data_maps.each_value{|map|
  45.       @data.push(map) if map.can_list?
  46.     }
  47.     if @data.empty?
  48.       @data.push(nil)
  49.     else
  50.       @sort_map_x = @data.sort{|a, b| a.world_x <=> b.world_x}
  51.       @sort_map_y = @data.sort{|a, b| a.world_y <=> b.world_y}
  52.     end
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● 繪製項目
  56.   #--------------------------------------------------------------------------
  57.   def refresh
  58.     contents.clear
  59.     if map
  60.       # 獲取文字顏色
  61.       change_color(text_color(map.name_color), enable?(map))
  62.       width = text_size(map.name).width
  63.       x = (self.width - width)/2
  64.       make_font_smaller # 文字大小變小
  65.       draw_text(x, 0, 172, line_height, map.name)
  66.       reset_font_settings # 重設文字設定
  67.       # 調整座標
  68.       x = map.world_x - self.width/2
  69.       bitmap = Cache.load_map(map.world_img)
  70.       y = map.world_y + bitmap.height/2 - self.standard_padding
  71.       y += help_window.height if help_window
  72.       self.x = x
  73.       self.y = y
  74.     end
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 獲取文字顏色
  78.   #--------------------------------------------------------------------------
  79.   def change_color(color, enabled = true)
  80.     if enabled
  81.       contents.font.color.set(color)
  82.     else
  83.       contents.font.color.set(Color.new(100, 100, 100))
  84.     end
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 按下方向左鍵
  88.   #--------------------------------------------------------------------------
  89.   def cursor_left(wrap = false)
  90.     change_curser(@sort_map_x, 4)
  91.   end
  92.   #--------------------------------------------------------------------------
  93.   # ● 按下方向右鍵
  94.   #--------------------------------------------------------------------------
  95.   def cursor_right(wrap = false)
  96.     change_curser(@sort_map_x, 6)
  97.   end
  98.   #--------------------------------------------------------------------------
  99.   # ● 按下方向上鍵
  100.   #--------------------------------------------------------------------------
  101.   def cursor_up(wrap = false)
  102.     change_curser(@sort_map_y, 8)
  103.   end
  104.   #--------------------------------------------------------------------------
  105.   # ● 按下方向下鍵
  106.   #--------------------------------------------------------------------------
  107.   def cursor_down(wrap = false)
  108.     change_curser(@sort_map_y, 2)
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 按下方向鍵
  112.   #--------------------------------------------------------------------------
  113.   def change_curser(array, direction)
  114.     return if array.nil? || array.empty?
  115.     #return unless array.include?(map)
  116.     index = array.index(current_map_adjust)
  117.     case direction
  118.     when 4, 8 # 按左右鍵時
  119.       if index == 0
  120.         index = array.size - 1
  121.       else
  122.         index -= 1
  123.       end
  124.     when 2, 6 # 按上下鍵時
  125.       if index == array.size-1
  126.         index = 0
  127.       else
  128.         index += 1
  129.       end
  130.     else
  131.       return
  132.     end
  133.     real_index = @data.index(array[index]) # 獲取真實index
  134.     select(real_index) # 選擇地圖
  135.     refresh # 刷新窗口
  136.   end
  137.   def current_map_adjust
  138.     return map if map
  139.     actual_map = $data_maps[$game_map.current_map_data.parent_id_on_map]
  140.     return actual_map
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 更新游標
  144.   #--------------------------------------------------------------------------
  145.   def update_cursor
  146.     cursor_rect.empty if cursor_rect.height > 0 # 將游標隱藏
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 選擇地圖
  150.   #--------------------------------------------------------------------------
  151.   def select_map(map)
  152.     i = @data.index(map)
  153.     select(i)
  154.   end
  155. end
  156. class Window_MapChoices < Window_Command
  157.   #--------------------------------------------------------------------------
  158.   # ● 生成命令
  159.   #--------------------------------------------------------------------------
  160.   def make_command_list
  161.     add_command("傳送到這裡", :transfer)
  162.     add_command("詳細資料", :description)
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 設置命令有效度
  166.   #--------------------------------------------------------------------------
  167.   def set_command_enable(index, enable)
  168.     @list[index][:enabled] = enable
  169.     redraw_item(index)
  170.   end
  171. end
  172. class Window_MapDetail < Window_Selectable
  173.   attr_reader :map
  174.   #--------------------------------------------------------------------------
  175.   # ● 初始化
  176.   #--------------------------------------------------------------------------
  177.   def initialize(x, y, width, height)
  178.     super(x, y, width, height)
  179.     @map = nil
  180.     @show_desc = false
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● 設置地圖
  184.   #--------------------------------------------------------------------------
  185.   def map=(m)
  186.     @map = m
  187.     refresh
  188.   end
  189.   #--------------------------------------------------------------------------
  190.   # ● 窗口刷新
  191.   #--------------------------------------------------------------------------
  192.   def refresh
  193.     return unless @map
  194.     contents.clear
  195.     if @map.detail_image != ""
  196.       draw_detail_image
  197.     else
  198.       @show_desc = @map.full_desc != ""
  199.     end
  200.     draw_full_desc if @show_desc
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # ● 繪製詳細圖像
  204.   #--------------------------------------------------------------------------
  205.   def draw_detail_image
  206.     dest_rect = Rect.new(0, 0, self.width-24, self.height-24)
  207.     src_bitmap = Cache.load_map(@map.detail_image)
  208.     src_rect = Rect.new(0, 0, src_bitmap.width, src_bitmap.height)
  209.     opacity = @show_desc ? 128 : 255
  210.     contents.stretch_blt(dest_rect, src_bitmap, src_rect, opacity)
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # ● 繪製詳細資訊
  214.   #--------------------------------------------------------------------------
  215.   def draw_full_desc
  216.     draw_text_ex(0, 0, @map.full_desc)
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 按下確認鍵時
  220.   #--------------------------------------------------------------------------
  221.   def process_ok
  222.     if @map.full_desc != ""
  223.       Sound.play_ok
  224.       @show_desc = !@show_desc
  225.       refresh
  226.     else
  227.       Sound.play_buzzer
  228.     end
  229.   end
  230. end
  231. class Scene_WorldMap < Scene_Base
  232.   #--------------------------------------------------------------------------
  233.   # ● 場景開始
  234.   #--------------------------------------------------------------------------
  235.   def start
  236.     super
  237.     @sprites=[]
  238.     create_map_description_window
  239.     create_map_list_window
  240.     create_choice_window
  241.     create_map_detail_window
  242.     create_world_map
  243.     create_location_sprite
  244.     create_player_sprite
  245.   end
  246.   #--------------------------------------------------------------------------
  247.   # ● 生成地圖列表窗口
  248.   #--------------------------------------------------------------------------
  249.   def create_map_list_window
  250.     y = @map_desc_window.height
  251.     @map_list_window = Window_MapList.new(0, y, 160, Graphics.height-48)
  252.     @map_list_window.viewport = @viewport
  253.     @map_list_window.set_handler(:ok, method(:on_map_ok))
  254.     @map_list_window.set_handler(:cancel, method(:on_map_cancel))
  255.     @map_list_window.help_window = @map_desc_window
  256.     @map_list_window.refresh
  257.     @map_list_window.activate
  258.     @current_map = $game_map.current_map_data
  259.     @selected_map = @map_list_window.map
  260.   end
  261.   #--------------------------------------------------------------------------
  262.   # ● 生成地圖說明窗口
  263.   #--------------------------------------------------------------------------
  264.   def create_map_description_window
  265.     @map_desc_window = Window_Help.new(1)
  266.   end
  267.   #--------------------------------------------------------------------------
  268.   # ● 生成選項窗口
  269.   #--------------------------------------------------------------------------
  270.   def create_choice_window
  271.     @choice_window = Window_MapChoices.new(0, 0)
  272.     @choice_window.x = (Graphics.width - @choice_window.width)/2
  273.     @choice_window.y = (Graphics.height - @choice_window.height)/2
  274.     @choice_window.viewport = @viewport
  275.     @choice_window.set_handler(:transfer, method(:do_player_transfer))
  276.     @choice_window.set_handler(:description, method(:show_full_desc))
  277.     @choice_window.set_handler(:cancel, method(:choice_cancel))
  278.     @choice_window.deactivate.hide
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 生成詳細資訊窗口
  282.   #--------------------------------------------------------------------------
  283.   def create_map_detail_window
  284.     y = @map_desc_window.height
  285.     width = 384
  286.     height = Graphics.height - y
  287.     @detail_window = Window_MapDetail.new(0, y, width, height)
  288.     @detail_window.x = (Graphics.width - @detail_window.width)/2
  289.     @detail_window.viewport = @viewport
  290.     @detail_window.set_handler(:ok, method(:update))
  291.     @detail_window.set_handler(:cancel, method(:detail_cancel))
  292.     @detail_window.deactivate.hide
  293.   end
  294.   #--------------------------------------------------------------------------
  295.   # ● 生成世界地圖精靈
  296.   #--------------------------------------------------------------------------
  297.   def create_world_map
  298.     @world_map_sprite = Sprite.new(@viewport)
  299.     src_bitmap = Cache.load_map("world")
  300.     width = Graphics.width
  301.     height = Graphics.height - @map_desc_window.height
  302.     dest_bitmap = Bitmap.new(width, height)
  303.     dest_bitmap.stretch_blt(dest_bitmap.rect, src_bitmap, src_bitmap.rect)
  304.     @world_map_sprite.bitmap = dest_bitmap
  305.     @world_map_sprite.x = 0
  306.     @world_map_sprite.y = @map_desc_window.height
  307.     @sprites.push(@world_map_sprite)
  308.   end
  309.   #--------------------------------------------------------------------------
  310.   # ● 生成當前主角精靈
  311.   #--------------------------------------------------------------------------
  312.   def create_player_sprite
  313.     @player_sprite = Sprite.new(@viewport)
  314.     @player_sprite.bitmap = Cache.load_map("player")
  315.     update_player_sprite
  316.     @player_sprite.x = @current_map.player_x - @player_sprite.width/2
  317.     @player_sprite.y = @current_map.player_y - @player_sprite.height/2
  318.     @player_sprite.x += sprite_dx
  319.     @player_sprite.y += sprite_dy
  320.     @player_sprite.z = @selected_sprite.z + 10
  321.     @sprites.push(@player_sprite)
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # ● 生成地圖位置精靈
  325.   #--------------------------------------------------------------------------
  326.   def create_location_sprite
  327.     @location_sprites= []
  328.     @map_list_window.maps.each{ |map|
  329.       l_sprite = Sprite.new(@viewport)
  330.       create_a_map_sprite(l_sprite, map)
  331.       @location_sprites.push(l_sprite)
  332.     }
  333.     update_location_sprites
  334.     @selected_sprite = Sprite.new(@viewport)
  335.     @sprites.push(@selected_sprite)
  336.     @sprites += @location_sprites
  337.     create_select_sprite
  338.   end
  339.   #--------------------------------------------------------------------------
  340.   # ● 生成選擇精靈
  341.   #--------------------------------------------------------------------------
  342.   def create_select_sprite
  343.     create_a_map_sprite(@selected_sprite, @selected_map, "select")
  344.     @selected_sprite.z = current_sprite.z+10
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 生成一個地圖位置精靈
  348.   #--------------------------------------------------------------------------
  349.   def create_a_map_sprite(sprite, map, image="")
  350.     return unless map
  351.     image = map.world_img if image==""
  352.     sprite.bitmap = Cache.load_map(image)
  353.     sprite.x = map.world_x - sprite.width/2
  354.     sprite.y = map.world_y - sprite.height/2
  355.     sprite.x += sprite_dx
  356.     sprite.y += sprite_dy
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● 選擇地圖結束
  360.   #--------------------------------------------------------------------------
  361.   def on_map_ok
  362.     @map_list_window.deactivate
  363.     @choice_window.set_command_enable(0, @selected_map.can_transfer?)
  364.     @choice_window.set_command_enable(1, @selected_map.known?)
  365.     @choice_window.activate.show
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 執行角色傳送
  369.   #--------------------------------------------------------------------------
  370.   def do_player_transfer
  371.     map = @map_list_window.map
  372.     id = map.id
  373.     x = map.land_x
  374.     y = map.land_y
  375.     $game_player.reserve_transfer(id, x, y)
  376.     SceneManager.goto(Scene_Map)
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● 返回地圖場景
  380.   #--------------------------------------------------------------------------
  381.   def on_map_cancel
  382.     SceneManager.call(Scene_Map)
  383.   end
  384.   #--------------------------------------------------------------------------
  385.   # ● 顯示詳細資訊窗口
  386.   #--------------------------------------------------------------------------
  387.   def show_full_desc
  388.     @detail_window.activate.show
  389.     @detail_window.map = @selected_map
  390.     @choice_window.deactivate.hide
  391.   end
  392.   #--------------------------------------------------------------------------
  393.   # ● 取消選項
  394.   #--------------------------------------------------------------------------
  395.   def choice_cancel
  396.     @map_list_window.activate
  397.     @choice_window.deactivate.hide
  398.   end
  399.   #--------------------------------------------------------------------------
  400.   # ● 跳出詳細資訊窗口
  401.   #--------------------------------------------------------------------------
  402.   def detail_cancel
  403.     @detail_window.deactivate.hide
  404.     @map_list_window.activate
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   # ● 場景更新
  408.   #--------------------------------------------------------------------------
  409.   def update
  410.     super
  411.     update_player_sprite
  412.     update_location_sprites
  413.     $game_player.perform_transfer if $game_player.transfer?
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ● 更新主角精靈
  417.   #--------------------------------------------------------------------------
  418.   def update_player_sprite
  419.     cw = @player_sprite.bitmap.width/3
  420.     ch = @player_sprite.bitmap.height
  421.     player_rect = Rect.new(0, 0, cw, ch)
  422.     sx = Graphics.frame_count/24%4
  423.     player_rect.x = sx*cw
  424.     player_rect.x = cw if sx==3
  425.     @player_sprite.src_rect.set(player_rect)
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ● 更新位置精靈
  429.   #--------------------------------------------------------------------------
  430.   def update_location_sprites
  431.     if @selected_map != @map_list_window.map
  432.       @selected_map = @map_list_window.map
  433.       @selected_sprite.x = current_sprite.x
  434.       @selected_sprite.y = current_sprite.y
  435.     end
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● 獲取精靈位移座標
  439.   #--------------------------------------------------------------------------
  440.   def sprite_dx
  441.     @world_map_sprite.x
  442.   end
  443.   def sprite_dy
  444.     @world_map_sprite.y
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # ● 獲取當前選中的地圖的精靈
  448.   #--------------------------------------------------------------------------
  449.   def current_sprite
  450.     return @location_sprites[@map_list_window.index]
  451.   end
  452. end
  453. class Game_Interpreter
  454.   #--------------------------------------------------------------------------
  455.   # ● 呼叫世界地圖場景
  456.   #--------------------------------------------------------------------------
  457.   def call_world_map
  458.     SceneManager.call(Scene_WorldMap)
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ● 手動設定「已知」標記
  462.   #--------------------------------------------------------------------------
  463.   def know_map(id)
  464.     $data_maps[id].know
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ● 取消「已知」標記
  468.   #--------------------------------------------------------------------------
  469.   def unknow_map(id)
  470.     $data_maps[id].unknow
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # ● 取消「已造訪」標記
  474.   #--------------------------------------------------------------------------
  475.   def unvisit_map(id)
  476.     $data_maps[id].unvisit
  477.   end
  478. end
复制代码
还有个这个脚本  只有这两个脚本
喵呜喵5 发表于 2013-6-9 23:41:23
这脚本真的只有这么一段?会不会漏了什么内容啊…………
rf520 发表于 2013-6-9 22:15:25
黄濑凉太 发表于 2013-6-9 21:15
请上传脚本或附件。

这是脚本
  1. class RPG::Map
  2.   #--------------------------------------------------------------------------
  3.   # ● 獲取世界地圖XY座標
  4.   #--------------------------------------------------------------------------
  5.   def get_worldxy
  6.     self.note.split(/[\r\n]+/).each { |line|
  7.       if line =~ /\[worldxy (\d+),(?:|\s+)(\d+)\]/
  8.         return $1.to_i, $2.to_i
  9.       end
  10.     }
  11.     return -1, -1
  12.   end
  13.   #--------------------------------------------------------------------------
  14.   # ● 獲取玩家在世界地圖上的XY座標
  15.   #--------------------------------------------------------------------------
  16.   def get_playerxy
  17.     self.note.split(/[\r\n]+/).each { |line|
  18.       if line =~ /\[playerxy (\d+),(?:|\s+)(\d+)\]/
  19.         return $1.to_i, $2.to_i
  20.       end
  21.     }
  22.     return -1, -1
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 獲取玩家傳送後的地圖XY座標
  26.   #--------------------------------------------------------------------------
  27.   def get_landxy
  28.     self.note.split(/[\r\n]+/).each { |line|
  29.       if line =~ /\[landxy (\d+),(?:|\s+)(\d+)\]/
  30.         return $1.to_i, $2.to_i
  31.       end
  32.     }
  33.     return -1, -1
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # ● 獲取顯示在世界地圖上的圖像文件名
  37.   #--------------------------------------------------------------------------
  38.   def get_worldimg
  39.     self.note.split(/[\r\n]+/).each { |line|
  40.       return $1 if line =~ /\[worldimg (\w+)\]/
  41.     }
  42.     return ""
  43.   end
  44.   def get_detailimg
  45.     self.note.split(/[\r\n]+/).each { |line|
  46.       return $1 if line =~ /\[detimg (\w+)\]/
  47.     }
  48.     return ""
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 獲取顯示在世界地圖上的說明文字
  52.   #--------------------------------------------------------------------------
  53.   def get_desc
  54.     self.note.split(/[\r\n]+/).each { |line|
  55.       return $1 if line =~ /\[desc (\S+)\]/
  56.     }
  57.     return ""
  58.   end
  59.   def get_visitswitch
  60.     self.note.split(/[\r\n]+/).each { |line|
  61.       return $1.to_i if line =~ /\[visitswitch (\d+)\]/
  62.     }
  63.     return 0
  64.   end
  65.   def get_name_color
  66.     self.note.split(/[\r\n]+/).each { |line|
  67.       return $1.to_i if line =~ /\[name_color (\d+)\]/
  68.     }
  69.     return 0
  70.   end
  71. end
  72. #==============================================================================
  73. # ■ Data_Map
  74. #------------------------------------------------------------------------------
  75. #  儲存地圖與傳送的相關資料。
  76. #==============================================================================
  77. class Data_Map
  78.   IGNORE_VISIT_SWITCH = false # 忽略造訪過的開關
  79.   attr_reader   :id
  80.   attr_reader   :player_x
  81.   attr_reader   :player_y
  82.   attr_reader   :world_x
  83.   attr_reader   :world_y
  84.   attr_reader   :land_x
  85.   attr_reader   :land_y
  86.   attr_reader   :world_img
  87.   attr_reader   :name_color
  88.   attr_reader   :description
  89.   attr_reader   :detail_image
  90.   attr_accessor :full_desc
  91.   
  92.   #--------------------------------------------------------------------------
  93.   # ● 初始化
  94.   #--------------------------------------------------------------------------
  95.   def initialize(map_id)
  96.     @id = map_id
  97.     map = load_data(sprintf("Data/Map%03d.rvdata2", @id))
  98.     @name = $data_mapinfos[@id].name
  99.     @parent_id = $data_mapinfos[@id].parent_id
  100.     @display_name = map.display_name
  101.     @world_x, @world_y = map.get_worldxy
  102.     @player_x, @player_y = map.get_playerxy
  103.     @land_x, @land_y = map.get_landxy
  104.     @world_img = map.get_worldimg
  105.     @name_color = map.get_name_color
  106.     @full_desc = ""
  107.     @detail_image = map.get_detailimg
  108.     @description = map.get_desc
  109.     @visited = false
  110.     @known = false
  111.     @visit_switch_id = map.get_visitswitch
  112.     adjust_player_xy
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ● 地圖名稱
  116.   #--------------------------------------------------------------------------
  117.   def name
  118.     return @name unless @display_name!=""
  119.     return @display_name
  120.   end
  121.   #--------------------------------------------------------------------------
  122.   # ● 判斷是否可以傳送
  123.   #--------------------------------------------------------------------------
  124.   def can_transfer?
  125.     return false if @land_x==-1 && @land_y==-1
  126.     return false if name.include?("MAP") # 若名稱是普通為命名的名稱時無法傳送
  127.     return visited? && !isCurrentMap?
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # ● 判斷是否可以列出
  131.   #--------------------------------------------------------------------------
  132.   def can_list?
  133.     return false if @world_img == ""
  134.     return !(@world_x==-1 && @world_y==-1)
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 判斷是否可以使用
  138.   #--------------------------------------------------------------------------
  139.   def can_use?
  140.     return visited? || known?
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 判斷是否已經造訪過
  144.   #--------------------------------------------------------------------------
  145.   def visited?
  146.     return true if IGNORE_VISIT_SWITCH # 忽略時返回 true
  147.     if @visit_switch_id != 0
  148.       return $game_switches[@visit_switch_id]
  149.     end
  150.     return @visited
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 判斷是否有詳細資訊
  154.   #--------------------------------------------------------------------------
  155.   def has_detail?
  156.     return @full_desc != "" || @detail_image != ""
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 判斷是否已知
  160.   #--------------------------------------------------------------------------
  161.   def known?
  162.     return false unless has_detail?
  163.     return @known
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 判斷是否為當前地圖
  167.   #--------------------------------------------------------------------------
  168.   def isCurrentMap?
  169.     return @id == $game_map.map_id
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● 造訪地圖
  173.   #--------------------------------------------------------------------------
  174.   def visit
  175.     @visited = true
  176.     know
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # ● 取消造訪地圖
  180.   #--------------------------------------------------------------------------
  181.   def unvisit
  182.     @visited = false
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # ● 已知地圖
  186.   #--------------------------------------------------------------------------
  187.   def know
  188.     @known = true
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 取消已知地圖
  192.   #--------------------------------------------------------------------------
  193.   def unknow
  194.     @knwon = false
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 調整主角顯示座標
  198.   #--------------------------------------------------------------------------
  199.   def adjust_player_xy
  200.     return if @player_x>=0 && @player_y>=0 # 本地圖有指定時返回
  201.     if @world_x>=0 && @world_y>=0 # 本地圖在世界地圖上有顯示時
  202.       @player_x, @player_y = @world_x, @world_y # 獲取世界地圖座標
  203.     else
  204.       @player_x, @player_y = parent_player_xy # 獲取母地圖主角座標
  205.     end
  206.   end
  207.   #--------------------------------------------------------------------------
  208.   # ● 獲取母地圖的主角顯示座標
  209.   #--------------------------------------------------------------------------
  210.   def parent_player_xy
  211.     if @parent_id == 0 # 無母地圖時
  212.       return Graphics.width, 0 # 顯示螢幕外
  213.     else
  214.       par_map = $data_maps[@parent_id]
  215.       return par_map.player_x, par_map.player_y # 返回母地圖指定的主角顯示座標
  216.     end
  217.   end
  218.   def parent_id_on_map
  219.     return 0 if @parent_id == 0 # 無母地圖時
  220.     par_map = $data_maps[@parent_id]
  221.     if par_map.player_x == @player_x && par_map.player_y == @player_y
  222.       return @parent_id
  223.     else
  224.       return parent_id_on_map
  225.     end
  226.   end
  227. end
  228. module DataManager
  229.   #--------------------------------------------------------------------------
  230.   # ● 載入資料庫
  231.   #--------------------------------------------------------------------------
  232.   class << self
  233.     alias worldmap_load_database load_database
  234.     def load_database
  235.       worldmap_load_database
  236.       load_mapdata # 載入地圖資料
  237.       map_data_setup
  238.     end
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 載入地圖資料
  242.   #--------------------------------------------------------------------------
  243.   def self.load_mapdata
  244.     $data_maps = {}
  245.     $data_mapinfos.each_key{ |mapid|
  246.       mapdata = Data_Map.new(mapid)
  247.       $data_maps[mapid] = mapdata
  248.     }
  249.   end
  250. end
  251. module Cache
  252.   #--------------------------------------------------------------------------
  253.   # ● 載入地圖圖片
  254.   #--------------------------------------------------------------------------
  255.   def self.load_map(filename)
  256.     load_bitmap("Graphics/Maps/", filename)
  257.   end
  258. end
  259. class Game_Map
  260.   #--------------------------------------------------------------------------
  261.   # ● 地圖設置
  262.   #--------------------------------------------------------------------------
  263.   alias worldmap_setup setup
  264.   def setup(map_id)
  265.     worldmap_setup(map_id)
  266.     $data_maps[map_id].visit
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● 返回當前地圖資訊
  270.   #--------------------------------------------------------------------------
  271.   def current_map_data
  272.     return $data_maps[@map_id]
  273.   end
  274. end
复制代码
不知道怎么设置
rf520 发表于 2013-6-9 22:12:42
光の異形 发表于 2013-6-9 20:54
215行 是什么啊喂 .........

      return par_map.player_x, par_map.player_y # 返回母地圖指定的主角顯示座標   这是啥意思?
黄濑凉太 发表于 2013-6-9 21:15:57
请上传脚本或附件。
光の異形 发表于 2013-6-9 20:54:48
215行 是什么啊喂 .........
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-18 14:41

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表