Project1

标题: 怎样使"显示小地图"里地图ID名称寻找方法改变? [打印本页]

作者: cloverhope    时间: 2007-8-18 21:19
提示: 作者被禁止或删除 内容自动屏蔽
作者: cloverhope    时间: 2007-8-18 21:19
提示: 作者被禁止或删除 内容自动屏蔽
作者: K’    时间: 2007-8-18 21:40
小地图文件等于 大地图名 + SM {/gg}



  1. #==============================================================================
  2. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  3. #==============================================================================

  4. #==============================================================================
  5. # ■ 全景地图显示小地图
  6. #########################
  7. # by      sphinger      #
  8. #########################
  9. #==============================================================================
  10. #==============================================================================
  11. # □ 前期定义
  12. #==============================================================================
  13. module PLAN_Map_Window
  14.   WIN_X       = 440         # 窗口的初始 X 座標
  15.   WIN_Y       = 0         # 窗口的初始 Y 座標
  16.   WIN_WIDTH   = 200      # 地图的宽度
  17.   WIN_HEIGHT  = 150     # 地图的高度
  18.   ZOOM        = 4.0       # 地图的放缩比例
  19.   ZOOMP       = 1         # 小地图上角色的缩放(1为图片原来大小,往大调节时图片变小)
  20.   SHOWPLAYER  = false     # 是否显示角色,当为true时,小地图将显示角色为false时显示兰色的标记
  21.   PLAYCW      = 4         #当使用上面的显示角色时,这个用来设置,角色的横向帧数
  22.   PLAYCH      = 8         #当使用上面的显示角色时,这个用来设置,角色的综向帧数
  23.   WINDOWSKIN  = ""        # 自定义地图窗口素材,如果留空则是默认的

  24.   ON_OFF_KEY  = Input::A  # 打开地图的按钮,A就是键盘的Z键

  25.   SWITCH      = 50       # 禁用地图功能的开关,默认这个就是打开100号开关则禁止
  26.                           # 使用地图功能,关闭则可以使用地图功能

  27.   WINDOW_MOVE = true     # 是否可以自动改变窗口位置(true:可改变, false:固定)
  28.   
  29.   OVER_X      = 440   # 自动改变后窗口的位置x
  30.   OVER_Y      = 480 - WIN_HEIGHT       #自动改变后窗口的位置y

  31.   OPACITY     = 192       # 窗口的透明度
  32.   C_OPACITY   = 192       # 地图的透明度
  33.   VISIBLE     = true     # 最初是否可见
  34. end
  35. #==============================================================================
  36. # ■ Game_Temp
  37. #==============================================================================
  38. class Game_Temp
  39.   attr_accessor  :map_visible     # 地图的表示状態
  40.   alias plan_map_window_initialize initialize
  41.   def initialize
  42.     plan_map_window_initialize
  43.     @map_visible = true
  44.   end
  45. end
  46. #==============================================================================
  47. # ■ Scene_Map
  48. #==============================================================================
  49. class Scene_Map
  50.   #--------------------------------------------------------------------------
  51.   # ● 主处理
  52.   #--------------------------------------------------------------------------
  53.   alias plan_map_window_main main
  54.   def main
  55.     @map_window         = Window_Map.new
  56.     @map_window.visible = $game_temp.map_visible
  57.     plan_map_window_main
  58.     @map_window.dispose
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 更新
  62.   #--------------------------------------------------------------------------
  63.   alias plan_map_window_update update
  64.   def update
  65.     $game_temp.map_visible = @map_window.visible
  66.     plan_map_window_update
  67.     unless $game_switches[PLAN_Map_Window::SWITCH]   #意思为:开关关闭地图功能开启,开关开启地图功能关闭
  68.       if Input.trigger?(PLAN_Map_Window::ON_OFF_KEY)
  69.         if @map_window.visible
  70.           @map_window.visible = false
  71.         else
  72.           @map_window.visible = true
  73.         end
  74.       end
  75.     else
  76.       if @map_window.visible
  77.         @map_window.visible = false
  78.       end
  79.     end
  80.     if @map_window.visible
  81.       @map_window.update
  82.     end
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # ● 场所移动的变化
  86.   #--------------------------------------------------------------------------
  87.   alias plan_map_window_transfer_player transfer_player
  88.   def transfer_player
  89.     visible = @map_window.visible
  90.     @map_window.visible = false
  91.     plan_map_window_transfer_player
  92.     @map_window.dispose
  93.     @map_window = Window_Map.new
  94.     @map_window.visible = visible
  95.   end
  96. end
  97. #==============================================================================
  98. # ■ Window_Map
  99. #==============================================================================
  100. class Window_Map < Window_Base

  101.   #--------------------------------------------------------------------------
  102.   # ● 初始化
  103.   #--------------------------------------------------------------------------
  104.   def initialize
  105.     x = PLAN_Map_Window::WIN_X
  106.     y = PLAN_Map_Window::WIN_Y
  107.     w = PLAN_Map_Window::WIN_WIDTH
  108.     h = PLAN_Map_Window::WIN_HEIGHT
  109.     super(x, y, w, h)
  110.     unless PLAN_Map_Window::WINDOWSKIN.empty?
  111.       self.windowskin = RPG::Cache.windowskin(PLAN_Map_Window::WINDOWSKIN)
  112.     end
  113.     self.contents = Bitmap.new(width - 32, height - 32)
  114.     self.opacity = PLAN_Map_Window::OPACITY
  115.     self.contents_opacity = PLAN_Map_Window::C_OPACITY
  116.     @old_real_x = $game_player.real_x
  117.     @old_real_y = $game_player.real_y
  118.     @all_map = make_all_map
  119.     self.visible = PLAN_Map_Window::VISIBLE
  120.     refresh
  121.   end
  122.   $data_mapinfos      = load_data("Data/MapInfos.rxdata")
  123.   
  124.   def map_name
  125.    id = $game_map.map_id
  126.    return $data_mapinfos[id].name
  127.   end  
  128.    
  129.    
  130.   #--------------------------------------------------------------------------
  131.   # ● 缩小图做成
  132.   #--------------------------------------------------------------------------
  133.   def make_all_map
  134.     all_map = RPG::Cache.icon(map_name + "SM")   
  135.     cw = $game_map.width * 32
  136.     ch = $game_map.height * 32
  137.     src_rect = Rect.new(0, 0, cw, ch)
  138.     self.contents.blt(0 , 0, all_map, src_rect)
  139.     w = ($game_map.width / PLAN_Map_Window::ZOOM) * 32
  140.     h = ($game_map.height / PLAN_Map_Window::ZOOM) * 32
  141.     ret_bitmap = Bitmap.new(w, h)
  142.     src_rect = Rect.new(0, 0, all_map.width, all_map.height)
  143.     dest_rect = Rect.new(0, 0, ret_bitmap.width, ret_bitmap.height)
  144.     ret_bitmap.stretch_blt(dest_rect, all_map, src_rect)
  145.     all_map.dispose
  146.     return ret_bitmap
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 刷新
  150.   #--------------------------------------------------------------------------
  151.   def refresh
  152.     self.contents.clear
  153.     one_tile_size = 32 / PLAN_Map_Window::ZOOM
  154.     x = $game_player.real_x - 128 * (self.contents.width / one_tile_size) / 2
  155.     y = $game_player.real_y - 128 * (self.contents.height / one_tile_size) / 2
  156.     x = x * one_tile_size / 128
  157.     y = y * one_tile_size / 128
  158.     half_width = self.contents.width * 128 / 2
  159.     rest_width = ($game_map.width * 128 - $game_player.real_x) * one_tile_size
  160.     rev_x = 0
  161.     if @all_map.width < self.contents.width
  162.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  163.       rev_x -= (self.contents.width - @all_map.width) / 2
  164.       x += rev_x
  165.     elsif half_width > $game_player.real_x * one_tile_size
  166.       rev_x = (half_width - $game_player.real_x * one_tile_size) / 128
  167.       x += rev_x
  168.     elsif half_width > rest_width
  169.       rev_x = -((half_width - rest_width) / 128)
  170.       x += rev_x
  171.     end
  172.     half_height = self.contents.height * 128 / 2
  173.     rest_height = ($game_map.height * 128 - $game_player.real_y) * one_tile_size
  174.     rev_y = 0
  175.     if @all_map.height < self.contents.height
  176.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  177.       rev_y -= (self.contents.height - @all_map.height) / 2
  178.       y += rev_y
  179.     elsif half_height > $game_player.real_y * one_tile_size
  180.       rev_y = (half_height - $game_player.real_y * one_tile_size) / 128
  181.       y += rev_y
  182.     elsif half_height > rest_height
  183.       rev_y = -((half_height - rest_height) / 128)
  184.       y += rev_y
  185.     end
  186.     src_rect = Rect.new(x, y, self.contents.width, self.contents.height)
  187.     self.contents.blt(0, 0, @all_map, src_rect)
  188.     if PLAN_Map_Window::WINDOW_MOVE == true
  189.       wr = PLAN_Map_Window::WIN_X + self.width
  190.       wl = PLAN_Map_Window::WIN_X
  191.       ht = PLAN_Map_Window::WIN_Y
  192.       he = PLAN_Map_Window::WIN_Y + self.height
  193.       if $game_player.screen_x >= wl and $game_player.screen_x <= wr
  194.         if $game_player.screen_y >= ht and $game_player.screen_y <= he
  195.           self.x = PLAN_Map_Window::OVER_X
  196.           self.y = PLAN_Map_Window::OVER_Y
  197.         else
  198.           self.x = PLAN_Map_Window::WIN_X
  199.           self.y = PLAN_Map_Window::WIN_Y
  200.         end
  201.       else
  202.         self.x = PLAN_Map_Window::WIN_X
  203.         self.y = PLAN_Map_Window::WIN_Y
  204.       end
  205.     end
  206.     if $game_party.actors.size > 0
  207.       actor = $game_party.actors[0]
  208.       if PLAN_Map_Window::SHOWPLAYER
  209.       bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  210.       width = bitmap.width / PLAN_Map_Window::PLAYCW
  211.       height = bitmap.height / PLAN_Map_Window::PLAYCH
  212.       src_rect = Rect.new(0, 0, width, height)
  213.       w = width / PLAN_Map_Window::ZOOM
  214.       h = height / PLAN_Map_Window::ZOOM
  215.       else
  216.       bitmap = RPG::Cache.icon("方向" + $game_player.direction.to_s)
  217.       width = bitmap.width / PLAN_Map_Window::ZOOMP
  218.       height = bitmap.height / PLAN_Map_Window::ZOOMP
  219.       src_rect = Rect.new(0, 0, width, height)
  220.       w = width
  221.       h = height
  222.       end
  223.       x = self.contents.width / 2 - w / 2 + one_tile_size / 2 - rev_x
  224.       y = self.contents.height / 2 - h / 2 - rev_y
  225.       dest_rect = Rect.new(x, y, w, h)
  226.       self.contents.stretch_blt(dest_rect, bitmap, src_rect)
  227.     end
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # ● 更新
  231.   #--------------------------------------------------------------------------
  232.   def update
  233.     super
  234.     if @old_real_x != $game_player.real_x or @old_real_y != $game_player.real_y
  235.       @old_real_x = $game_player.real_x
  236.       @old_real_y = $game_player.real_y
  237.       refresh
  238.     end
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 释放
  242.   #--------------------------------------------------------------------------
  243.   def dispose
  244.     super
  245.     @all_map.dispose
  246.   end
  247. end

  248. #==============================================================================
  249. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  250. #==============================================================================
复制代码
[LINE]1,#dddddd[/LINE]系统信息:本贴获得楼主认可,66RPG感谢您的热情解答~
作者: cloverhope    时间: 2007-8-18 22:20
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1