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

Project1

 找回密码
 注册会员
搜索
查看: 3245|回复: 0
打印 上一主题 下一主题

[转载] [RGSS2脚本]KGC样的小地图

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
43 小时
注册时间
2010-9-20
帖子
46
跳转到指定楼层
1
发表于 2010-10-4 17:33:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 qiji19980124 于 2010-10-4 17:36 编辑

【不知道我有没有煋……】
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/    ◆ ミニマップ - KGC_MiniMap ◆ VX ◆
  3. #_/    ◇ Last update : 2009/09/13 ◇
  4. #_/----------------------------------------------------------------------------
  5. #_/  ミニマップ表示機能を追加します。
  6. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

  7. #==============================================================================
  8. # ★ カスタマイズ項目 - Customize ★
  9. #==============================================================================

  10. module KGC
  11. module MiniMap
  12.   # ◆ ミニマップ表示 ON/OFF を切り替えるスイッチ ID
  13.   MINIMAP_SWITCH_ID = 3

  14.   # ◆ ミニマップ表示位置・サイズ (X, Y, 幅, 高さ)
  15.   MAP_RECT = Rect.new(364, 20, 160, 120)
  16.   # ◆ ミニマップの Z 座標
  17.   #  大きくしすぎると色々なものに被ります。
  18.   MAP_Z = 0
  19.   # ◆ 1マスのサイズ
  20.   #  3 以上を推奨。
  21.   GRID_SIZE = 5

  22.   # ◆ ミニマップ前景色(通行可)
  23.   FOREGROUND_COLOR = Color.new(224, 224, 255, 160)
  24.   # ◆ ミニマップ背景色(通行不可)
  25.   BACKGROUND_COLOR = Color.new(0, 0, 160, 160)

  26.   # ◆ 現在位置アイコンの色
  27.   POSITION_COLOR   = Color.new(255, 0, 0, 192)
  28.   # ◆ マップ移動イベント [MOVE] の色
  29.   MOVE_EVENT_COLOR = Color.new(255, 160, 0, 192)

  30.   # ◆ オブジェクトの色
  31.   #  要素の先頭から順に [OBJ1], [OBJ2], ... に対応。
  32.   OBJECT_COLOR = [
  33.     Color.new(  0, 160,   0, 192),  # [OBJ 1]
  34.     Color.new(  0, 160, 160, 192),  # [OBJ 2]
  35.     Color.new(160,   0, 160, 192),  # [OBJ 3]
  36.   ]  # ← この ] は消さないこと!

  37.   # ◆ アイコンの点滅の強さ
  38.   #  5 ~ 8 あたりを推奨。
  39.   BLINK_LEVEL = 7

  40.   # ◆ マップのキャッシュ数
  41.   #  この数を超えると、長期間参照していないものから削除。
  42.   CACHE_NUM = 10
  43. end
  44. end

  45. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  46. $imported = {} if $imported == nil
  47. $imported["MiniMap"] = true

  48. if $data_mapinfos == nil
  49.   $data_mapinfos = load_data("Data/MapInfos.rvdata")
  50. end

  51. module KGC::MiniMap
  52.   module Regexp
  53.     # ミニマップ非表示
  54.     NO_MINIMAP = /\[NOMAP\]/i
  55.     # 障害物
  56.     WALL_EVENT = /\[WALL\]/i
  57.     # 移動イベント
  58.     MOVE_EVENT = /\[MOVE\]/i
  59.     # オブジェクト
  60.     OBJECT = /\[OBJ(?:ECT)?\s*(\d)\]/i
  61.   end
  62. end

  63. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  64. #==============================================================================
  65. # □ KGC::Commands
  66. #==============================================================================

  67. module KGC
  68. module Commands
  69.   module_function
  70.   #--------------------------------------------------------------------------
  71.   # ○ ミニマップを表示
  72.   #--------------------------------------------------------------------------
  73.   def show_minimap
  74.     $game_system.minimap_show = true
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ○ ミニマップを隠す
  78.   #--------------------------------------------------------------------------
  79.   def hide_minimap
  80.     $game_system.minimap_show = false
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ○ ミニマップをリフレッシュ
  84.   #--------------------------------------------------------------------------
  85.   def refresh_minimap
  86.     return unless $scene.is_a?(Scene_Map)

  87.     $game_map.refresh if $game_map.need_refresh
  88.     $scene.refresh_minimap
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ○ ミニマップのオブジェクトを更新
  92.   #--------------------------------------------------------------------------
  93.   def update_minimap_object
  94.     return unless $scene.is_a?(Scene_Map)

  95.     $game_map.refresh if $game_map.need_refresh
  96.     $scene.update_minimap_object
  97.   end
  98. end
  99. end

  100. class Game_Interpreter
  101.   include KGC::Commands
  102. end

  103. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  104. #==============================================================================
  105. # ■ RPG::MapInfo
  106. #==============================================================================

  107. class RPG::MapInfo
  108.   #--------------------------------------------------------------------------
  109.   # ● マップ名取得
  110.   #--------------------------------------------------------------------------
  111.   def name
  112.     return @name.gsub(/\[.*\]/) { "" }
  113.   end
  114.   #--------------------------------------------------------------------------
  115.   # ○ オリジナルマップ名取得
  116.   #--------------------------------------------------------------------------
  117.   def original_name
  118.     return @name
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ○ ミニマップのキャッシュ生成
  122.   #--------------------------------------------------------------------------
  123.   def create_minimap_cache
  124.     @__minimap_show = !(@name =~ KGC::MiniMap::Regexp::NO_MINIMAP)
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ○ ミニマップ表示
  128.   #--------------------------------------------------------------------------
  129.   def minimap_show?
  130.     create_minimap_cache if @__minimap_show == nil
  131.     return @__minimap_show
  132.   end
  133. end

  134. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  135. #==============================================================================
  136. # ■ Game_System
  137. #==============================================================================

  138. class Game_System
  139.   #--------------------------------------------------------------------------
  140.   # ○ ミニマップ表示フラグ取得
  141.   #--------------------------------------------------------------------------
  142.   def minimap_show
  143.     return $game_switches[KGC::MiniMap::MINIMAP_SWITCH_ID]
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ○ ミニマップ表示フラグ変更
  147.   #--------------------------------------------------------------------------
  148.   def minimap_show=(value)
  149.     $game_switches[KGC::MiniMap::MINIMAP_SWITCH_ID] = value
  150.     $game_map.need_refresh = true
  151.   end
  152. end

  153. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  154. #==============================================================================
  155. # ■ Game_Map
  156. #==============================================================================

  157. class Game_Map
  158.   #--------------------------------------------------------------------------
  159.   # ○ ミニマップを表示するか
  160.   #--------------------------------------------------------------------------
  161.   def minimap_show?
  162.     return $data_mapinfos[map_id].minimap_show?
  163.   end
  164. end

  165. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  166. #==============================================================================
  167. # ■ Game_Event
  168. #==============================================================================

  169. class Game_Event < Game_Character
  170.   #--------------------------------------------------------------------------
  171.   # ○ グラフィックがあるか
  172.   #--------------------------------------------------------------------------
  173.   def graphic_exist?
  174.     return (character_name != "" || tile_id > 0)
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # ○ 障害物か
  178.   #--------------------------------------------------------------------------
  179.   def is_minimap_wall_event?
  180.     return (@event.name =~ KGC::MiniMap::Regexp::WALL_EVENT)
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ○ 移動イベントか
  184.   #--------------------------------------------------------------------------
  185.   def is_minimap_move_event?
  186.     return (@event.name =~ KGC::MiniMap::Regexp::MOVE_EVENT)
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ○ ミニマップオブジェクトか
  190.   #--------------------------------------------------------------------------
  191.   def is_minimap_object?
  192.     return (@event.name =~ KGC::MiniMap::Regexp::OBJECT)
  193.   end
  194.   #--------------------------------------------------------------------------
  195.   # ○ ミニマップオブジェクトタイプ
  196.   #--------------------------------------------------------------------------
  197.   def minimap_object_type
  198.     if @event.name =~ KGC::MiniMap::Regexp::OBJECT
  199.       return $1.to_i
  200.     else
  201.       return 0
  202.     end
  203.   end
  204. end

  205. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  206. #==============================================================================
  207. # □ Game_MiniMap
  208. #------------------------------------------------------------------------------
  209. #   ミニマップを扱うクラスです。
  210. #==============================================================================

  211. class Game_MiniMap
  212.   #--------------------------------------------------------------------------
  213.   # ○ 構造体
  214.   #--------------------------------------------------------------------------
  215.   Point = Struct.new(:x, :y)
  216.   Size  = Struct.new(:width, :height)
  217.   PassageCache = Struct.new(:map_id, :table, :scan_table)
  218.   #--------------------------------------------------------------------------
  219.   # ○ クラス変数
  220.   #--------------------------------------------------------------------------
  221.   @@passage_cache = []  # 通行フラグテーブルキャッシュ
  222.   #--------------------------------------------------------------------------
  223.   # ● オブジェクト初期化
  224.   #--------------------------------------------------------------------------
  225.   def initialize(tilemap)
  226.     @map_rect  = KGC::MiniMap::MAP_RECT
  227.     @grid_size = [KGC::MiniMap::GRID_SIZE, 1].max

  228.     @x = 0
  229.     @y = 0
  230.     @grid_num = Point.new(
  231.       (@map_rect.width  + @grid_size - 1) / @grid_size,
  232.       (@map_rect.height + @grid_size - 1) / @grid_size
  233.     )
  234.     @draw_grid_num    = Point.new(@grid_num.x + 2, @grid_num.y + 2)
  235.     @draw_range_begin = Point.new(0, 0)
  236.     @draw_range_end   = Point.new(0, 0)
  237.     @tilemap = tilemap

  238.     @last_x = $game_player.x
  239.     @last_y = $game_player.y

  240.     create_sprites
  241.     refresh
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ○ スプライト作成
  245.   #--------------------------------------------------------------------------
  246.   def create_sprites
  247.     @viewport   = Viewport.new(@map_rect)
  248.     @viewport.z = KGC::MiniMap::MAP_Z

  249.     # ビットマップサイズ計算
  250.     @bmp_size = Size.new(
  251.       (@grid_num.x + 2) * @grid_size,
  252.       (@grid_num.y + 2) * @grid_size
  253.     )
  254.     @buf_bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)

  255.     # マップ用スプライト作成
  256.     @map_sprite   = Sprite.new(@viewport)
  257.     @map_sprite.x = -@grid_size
  258.     @map_sprite.y = -@grid_size
  259.     @map_sprite.z = 0
  260.     @map_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)

  261.     # オブジェクト用スプライト作成
  262.     @object_sprite   = Sprite_MiniMapIcon.new(@viewport)
  263.     @object_sprite.x = -@grid_size
  264.     @object_sprite.y = -@grid_size
  265.     @object_sprite.z = 1
  266.     @object_sprite.bitmap = Bitmap.new(@bmp_size.width, @bmp_size.height)

  267.     # 現在位置スプライト作成
  268.     @position_sprite   = Sprite_MiniMapIcon.new
  269.     @position_sprite.x = @map_rect.x + @grid_num.x / 2 * @grid_size
  270.     @position_sprite.y = @map_rect.y + @grid_num.y / 2 * @grid_size
  271.     @position_sprite.z = @viewport.z + 2
  272.     bitmap = Bitmap.new(@grid_size, @grid_size)
  273.     bitmap.fill_rect(bitmap.rect, KGC::MiniMap::POSITION_COLOR)
  274.     @position_sprite.bitmap = bitmap
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ● 解放
  278.   #--------------------------------------------------------------------------
  279.   def dispose
  280.     @buf_bitmap.dispose
  281.     @map_sprite.bitmap.dispose
  282.     @map_sprite.dispose
  283.     @object_sprite.bitmap.dispose
  284.     @object_sprite.dispose
  285.     @position_sprite.bitmap.dispose
  286.     @position_sprite.dispose
  287.     @viewport.dispose
  288.   end
  289.   #--------------------------------------------------------------------------
  290.   # ○ 可視状態取得
  291.   #--------------------------------------------------------------------------
  292.   def visible
  293.     return @map_sprite.visible
  294.   end
  295.   #--------------------------------------------------------------------------
  296.   # ○ 可視状態設定
  297.   #--------------------------------------------------------------------------
  298.   def visible=(value)
  299.     @viewport.visible        = value
  300.     @map_sprite.visible      = value
  301.     @object_sprite.visible   = value
  302.     @position_sprite.visible = value
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ○ リフレッシュ
  306.   #--------------------------------------------------------------------------
  307.   def refresh
  308.     update_draw_range
  309.     update_passage_table
  310.     update_object_list
  311.     update_position
  312.     draw_map
  313.     draw_object
  314.     Graphics.frame_reset
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ○ 描画範囲更新
  318.   #--------------------------------------------------------------------------
  319.   def update_draw_range
  320.     range = []
  321.     (2).times { |i| range[i] = @draw_grid_num[i] / 2 }

  322.     @draw_range_begin.x = $game_player.x - range[0]
  323.     @draw_range_begin.y = $game_player.y - range[1]
  324.     @draw_range_end.x   = $game_player.x + range[0]
  325.     @draw_range_end.y   = $game_player.y + range[1]
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # ○ 通行可否テーブル更新
  329.   #--------------------------------------------------------------------------
  330.   def update_passage_table
  331.     cache = get_passage_table_cache
  332.     @passage_table      = cache.table
  333.     @passage_scan_table = cache.scan_table

  334.     update_around_passage
  335.   end
  336.   #--------------------------------------------------------------------------
  337.   # ○ 通行可否テーブルのキャッシュを取得
  338.   #--------------------------------------------------------------------------
  339.   def get_passage_table_cache
  340.     map_id = $game_map.map_id
  341.     cache  = @@passage_cache.find { |c| c.map_id == map_id }
  342.     if cache == nil
  343.       # キャッシュミス
  344.       cache = PassageCache.new(map_id)
  345.       cache.table      = Table.new($game_map.width, $game_map.height)
  346.       cache.scan_table = Table.new(
  347.         ($game_map.width  + @draw_grid_num.x - 1) / @draw_grid_num.x,
  348.         ($game_map.height + @draw_grid_num.y - 1) / @draw_grid_num.y
  349.       )
  350.     end

  351.     # 直近のキャッシュは先頭、古いキャッシュは削除
  352.     @@passage_cache.unshift(cache)
  353.     @@passage_cache.delete_at(KGC::MiniMap::CACHE_NUM)

  354.     return cache
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # ○ 通行可否テーブルのキャッシュをクリア
  358.   #--------------------------------------------------------------------------
  359.   def clear_passage_table_cache
  360.     return if @passage_scan_table == nil

  361.     table = @passage_scan_table
  362.     @passage_scan_table = Table.new(table.xsize, table.ysize)
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ○ 通行可否テーブルの探索
  366.   #     x, y : 探索位置
  367.   #--------------------------------------------------------------------------
  368.   def scan_passage(x, y)
  369.     dx = x / @draw_grid_num.x
  370.     dy = y / @draw_grid_num.y

  371.     return if @passage_scan_table[dx, dy] == 1
  372.     return unless dx.between?(0, @passage_scan_table.xsize - 1)
  373.     return unless dy.between?(0, @passage_scan_table.ysize - 1)

  374.     rx = (dx * @draw_grid_num.x)...((dx + 1) * @draw_grid_num.x)
  375.     ry = (dy * @draw_grid_num.y)...((dy + 1) * @draw_grid_num.y)
  376.     mw = $game_map.width  - 1
  377.     mh = $game_map.height - 1
  378.     rx.each { |x|
  379.       next unless x.between?(0, mw)
  380.       ry.each { |y|
  381.         next unless y.between?(0, mh)
  382.         @passage_table[x, y] = ($game_map.passable?(x, y) ? 1 : 0)
  383.       }
  384.     }
  385.     @passage_scan_table[dx, dy] = 1
  386.   end
  387.   #--------------------------------------------------------------------------
  388.   # ○ 周辺の通行可否テーブル更新
  389.   #--------------------------------------------------------------------------
  390.   def update_around_passage
  391.     gx = @draw_grid_num.x
  392.     gy = @draw_grid_num.y
  393.     dx = $game_player.x - gx / 2
  394.     dy = $game_player.y - gy / 2
  395.     scan_passage(dx,      dy)
  396.     scan_passage(dx + gx, dy)
  397.     scan_passage(dx,      dy + gy)
  398.     scan_passage(dx + gx, dy + gy)
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ○ オブジェクト一覧更新
  402.   #--------------------------------------------------------------------------
  403.   def update_object_list
  404.     events = $game_map.events.values

  405.     # WALL
  406.     @wall_events = events.find_all { |e|
  407.       e.graphic_exist? && e.is_minimap_wall_event?
  408.     }

  409.     # MOVE
  410.     @move_events = events.find_all { |e|
  411.       e.graphic_exist? && e.is_minimap_move_event?
  412.     }

  413.     # OBJ
  414.     @object_list = []
  415.     events.each { |e|
  416.       next unless e.graphic_exist?
  417.       next unless e.is_minimap_object?

  418.       type = e.minimap_object_type
  419.       if @object_list[type] == nil
  420.         @object_list[type] = []
  421.       end
  422.       @object_list[type] << e
  423.     }
  424.   end
  425.   #--------------------------------------------------------------------------
  426.   # ○ 位置更新
  427.   #--------------------------------------------------------------------------
  428.   def update_position
  429.     pt = Point.new($game_player.x, $game_player.y)
  430.     dx = ($game_player.real_x - pt.x * 256) * @grid_size / 256
  431.     dy = ($game_player.real_y - pt.y * 256) * @grid_size / 256
  432.     ox = dx % @grid_size
  433.     oy = dy % @grid_size
  434.     ox = -(@grid_size - ox) if dx < 0
  435.     oy = -(@grid_size - oy) if dy < 0
  436.     @viewport.ox = ox
  437.     @viewport.oy = oy
  438.     if pt.x != @last_x || pt.y != @last_y
  439.       draw_map
  440.       @last_x = pt.x
  441.       @last_y = pt.y
  442.     end
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # ○ 描画範囲内判定
  446.   #--------------------------------------------------------------------------
  447.   def in_draw_range?(x, y)
  448.     rb = @draw_range_begin
  449.     re = @draw_range_end
  450.     return (x.between?(rb.x, re.x) && y.between?(rb.y, re.y))
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ○ マップ範囲内判定
  454.   #--------------------------------------------------------------------------
  455.   def in_map_range?(x, y)
  456.     mw = $game_map.width
  457.     mh = $game_map.height
  458.     return (x.between?(0, mw - 1) && y.between?(0, mh - 1))
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ○ マップ描画
  462.   #     dir : 追加位置 (0 で全体)
  463.   #--------------------------------------------------------------------------
  464.   def draw_map(dir = 0)
  465.     bitmap  = @map_sprite.bitmap
  466.     bitmap.fill_rect(bitmap.rect, KGC::MiniMap::BACKGROUND_COLOR)

  467.     rect = Rect.new(0, 0, @grid_size, @grid_size)

  468.     range_x = (@draw_range_begin.x)..(@draw_range_end.x)
  469.     range_y = (@draw_range_begin.y)..(@draw_range_end.y)
  470.     mw = $game_map.width  - 1
  471.     mh = $game_map.height - 1
  472.     update_around_passage

  473.     # 通行可能領域描画
  474.     range_x.each { |x|
  475.       next unless x.between?(0, mw)
  476.       range_y.each { |y|
  477.         next unless y.between?(0, mh)
  478.         next if @passage_table[x, y] == 0
  479.         next if @wall_events.find { |e| e.x == x && e.y == y }  # 壁

  480.         rect.x = (x - @draw_range_begin.x) * @grid_size
  481.         rect.y = (y - @draw_range_begin.y) * @grid_size
  482.         bitmap.fill_rect(rect, KGC::MiniMap::FOREGROUND_COLOR)
  483.       }
  484.     }

  485.     # MOVE
  486.     @move_events.each { |e|
  487.       rect.x = (e.x - @draw_range_begin.x) * @grid_size
  488.       rect.y = (e.y - @draw_range_begin.y) * @grid_size
  489.       bitmap.fill_rect(rect, KGC::MiniMap::MOVE_EVENT_COLOR)
  490.     }
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ○ オブジェクト描画
  494.   #--------------------------------------------------------------------------
  495.   def draw_object
  496.     # 下準備
  497.     bitmap = @object_sprite.bitmap
  498.     bitmap.clear
  499.     rect = Rect.new(0, 0, @grid_size, @grid_size)

  500.     # オブジェクト描画
  501.     @object_list.each_with_index { |list, i|
  502.       color = KGC::MiniMap::OBJECT_COLOR[i - 1]
  503.       next if list.nil? || color.nil?

  504.       list.each { |obj|
  505.         next unless in_draw_range?(obj.x, obj.y)

  506.         rect.x = (obj.real_x - @draw_range_begin.x * 256) * @grid_size / 256
  507.         rect.y = (obj.real_y - @draw_range_begin.y * 256) * @grid_size / 256
  508.         bitmap.fill_rect(rect, color)
  509.       }
  510.     }
  511.   end
  512.   #--------------------------------------------------------------------------
  513.   # ○ 更新
  514.   #--------------------------------------------------------------------------
  515.   def update
  516.     return unless @map_sprite.visible

  517.     update_draw_range
  518.     update_position
  519.     draw_object
  520.     @map_sprite.update
  521.     @object_sprite.update
  522.     @position_sprite.update
  523.   end
  524. end

  525. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  526. #==============================================================================
  527. # □ Sprite_MiniMapIcon
  528. #------------------------------------------------------------------------------
  529. #   ミニマップ用アイコンのクラスです。
  530. #==============================================================================

  531. class Sprite_MiniMapIcon < Sprite
  532.   DURATION_MAX = 60
  533.   #--------------------------------------------------------------------------
  534.   # ● オブジェクト初期化
  535.   #     viewport : ビューポート
  536.   #--------------------------------------------------------------------------
  537.   def initialize(viewport = nil)
  538.     super(viewport)
  539.     @duration = DURATION_MAX / 2
  540.   end
  541.   #--------------------------------------------------------------------------
  542.   # ● フレーム更新
  543.   #--------------------------------------------------------------------------
  544.   def update
  545.     super
  546.     @duration += 1
  547.     if @duration == DURATION_MAX
  548.       @duration = 0
  549.     end
  550.     update_effect
  551.   end
  552.   #--------------------------------------------------------------------------
  553.   # ○ エフェクトの更新
  554.   #--------------------------------------------------------------------------
  555.   def update_effect
  556.     self.color.set(255, 255, 255,
  557.       (@duration - DURATION_MAX / 2).abs * KGC::MiniMap::BLINK_LEVEL
  558.     )
  559.   end
  560. end

  561. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  562. #==============================================================================
  563. # ■ Spriteset_Map
  564. #==============================================================================

  565. class Spriteset_Map
  566.   attr_reader :minimap
  567.   #--------------------------------------------------------------------------
  568.   # ● オブジェクト初期化
  569.   #--------------------------------------------------------------------------
  570.   alias initialize_KGC_MiniMap initialize
  571.   def initialize
  572.     initialize_KGC_MiniMap

  573.     create_minimap
  574.   end
  575.   #--------------------------------------------------------------------------
  576.   # ○ ミニマップ作成
  577.   #--------------------------------------------------------------------------
  578.   def create_minimap
  579.     return unless $game_map.minimap_show?

  580.     @minimap = Game_MiniMap.new(@tilemap)
  581.     @minimap.visible = $game_system.minimap_show
  582.   end
  583.   #--------------------------------------------------------------------------
  584.   # ● 解放
  585.   #--------------------------------------------------------------------------
  586.   alias dispose_KGC_MiniMap dispose
  587.   def dispose
  588.     dispose_KGC_MiniMap

  589.     dispose_minimap
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # ○ ミニマップ解放
  593.   #--------------------------------------------------------------------------
  594.   def dispose_minimap
  595.     @minimap.dispose unless @minimap.nil?
  596.   end
  597.   #--------------------------------------------------------------------------
  598.   # ● フレーム更新
  599.   #--------------------------------------------------------------------------
  600.   alias update_KGC_MiniMap update
  601.   def update
  602.     update_KGC_MiniMap

  603.     update_minimap
  604.   end
  605.   #--------------------------------------------------------------------------
  606.   # ○ ミニマップ更新
  607.   #--------------------------------------------------------------------------
  608.   def update_minimap
  609.     return if @minimap.nil?

  610.     if $game_system.minimap_show
  611.       @minimap.visible = true
  612.       @minimap.update
  613.     else
  614.       @minimap.visible = false
  615.     end
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # ○ ミニマップ全体をリフレッシュ
  619.   #--------------------------------------------------------------------------
  620.   def refresh_minimap
  621.     return if @minimap.nil?

  622.     @minimap.clear_passage_table_cache
  623.     @minimap.refresh
  624.   end
  625.   #--------------------------------------------------------------------------
  626.   # ○ ミニマップのオブジェクトを更新
  627.   #--------------------------------------------------------------------------
  628.   def update_minimap_object
  629.     @minimap.update_object_list unless @minimap.nil?
  630.   end
  631. end

  632. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

  633. #==============================================================================
  634. # ■ Scene_Map
  635. #==============================================================================

  636. class Scene_Map
  637.   #--------------------------------------------------------------------------
  638.   # ○ ミニマップ全体をリフレッシュ
  639.   #--------------------------------------------------------------------------
  640.   def refresh_minimap
  641.     @spriteset.refresh_minimap
  642.   end
  643.   #--------------------------------------------------------------------------
  644.   # ○ ミニマップのオブジェクトを更新
  645.   #--------------------------------------------------------------------------
  646.   def update_minimap_object
  647.     @spriteset.update_minimap_object
  648.   end
  649. end
复制代码
这个……可以在地图右上角显示小地图
# ◆ ミニマップ表示 ON/OFF を切り替えるスイッチ ID
  MINIMAP_SWITCH_ID = 3
这里是要设定一下的,是显示/不显示小地图的开关的ID(就是编辑事件那里的)
开关On时就是开小地图,Off时是不开
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-4-29 19:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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