| 
 
| 赞 | 3 |  
| VIP | 109 |  
| 好人卡 | 208 |  
| 积分 | 3 |  
| 经验 | 22037 |  
| 最后登录 | 2025-4-27 |  
| 在线时间 | 1196 小时 |  
 Lv2.观梦者 虚構歪曲
	梦石0 星屑334 在线时间1196 小时注册时间2010-12-18帖子3928 
 | 
| 复制代码#==============================================================================
# ■ Window_Smap
#------------------------------------------------------------------------------
#  小地图背景的窗口。
#==============================================================================
class Window_Smap < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(640 - 145, 25, 120, 80)
    self.back_opacity = 0
    self.windowskin = RPG::Cache.windowskin("Windowskin1")
  end
end
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ ミニマップ - KGC_MiniMap ◆
#_/    ◇ Last update : 2007/08/19 ◇
#_/----------------------------------------------------------------------------
#_/  ミニマップ表示機能を追加します。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ カスタマイズ項目 ★
#==============================================================================
module KGC
module MiniMap
  # ◆ミニマップ表示位置・サイズ (X, Y, 幅, 高さ)
  MAP_RECT = Rect.new(640 - 145, 25, 120, 80)
  # ◆ミニマップの Z 座標
  #  大きくしすぎると、色々なものに被ります。
  MAP_Z = 0
  # ◆1マスのサイズ
  #  3 以上を推奨。1 だと見えません(´・ω・`)
  GRID_SIZE = 3
  # ◆ミニマップ前景色(通行可)
  FOREGROUND_COLOR = Color.new(224, 224, 255, 160)
  # ◆ミニマップ背景色(通行不可)
  BACKGROUND_COLOR = Color.new(0, 0, 160, 160)
  # ◆現在位置の色
  POSITION_COLOR   = Color.new(255, 0, 0, 192)
  # ◆マップ移動イベントの色
  MOVE_EVENT_COLOR = Color.new(255, 160, 0, 160)
  # ◆オブジェクトの色
  #  要素の先頭から順に [OBJ1], [OBJ2], ... に対応。
  OBJECT_COLOR = [
    Color.new(0, 160, 0, 160),    # [OBJ 1]
    Color.new(0, 160, 160, 160),  # [OBJ 2]
  ]  # ← Don't delete this line!
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["MiniMap"] = true
=begin
RPG::MapInfo
Game_System
Game_Map
Game_Event
Game_MiniMap
Spriteset_Map
=end
module KGC::MiniMap
  # ミニマップ非表示表現
  REGEXP_NO_MINIMAP = /\[NOMAP\]/i
  # 移動イベント表現
  REGEXP_MOVE_EVENT = /\[MOVE\]/i
  # オブジェクト表現
  REGEXP_OBJECT = /\[OBJ(?:ECT)?[ ]*(\d)\]/i
  #--------------------------------------------------------------------------
  # ● ミニマップ全体をリフレッシュ
  #--------------------------------------------------------------------------
  def self.refresh
    if $scene.is_a?(Scene_Map)
      $scene.spriteset.minimap.refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● ミニマップのオブジェクトを更新
  #--------------------------------------------------------------------------
  def self.update_object
    if $scene.is_a?(Scene_Map)
      $scene.spriteset.minimap.update_object_list
    end
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ RPG::MapInfo
#==============================================================================
class RPG::MapInfo
  #--------------------------------------------------------------------------
  # ● マップ名
  #--------------------------------------------------------------------------
  def name
    return @name.gsub(/\[.*\]/) {""}
  end
  #--------------------------------------------------------------------------
  # ● オリジナル名
  #--------------------------------------------------------------------------
  def original_name
    return @name
  end
  #--------------------------------------------------------------------------
  # ● ミニマップ表示
  #--------------------------------------------------------------------------
  def show_minimap?
    return !(@name =~ KGC::MiniMap::REGEXP_NO_MINIMAP)
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_System
#==============================================================================
class Game_System
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :show_minimap             # ミニマップ表示
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_KGC_MiniMap initialize
  def initialize
    initialize_KGC_MiniMap
    @show_minimap = false
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # ● セットアップ
  #     map_id : マップ ID
  #--------------------------------------------------------------------------
  alias setup_KGC_MiniMap setup
  def setup(map_id)
    setup_KGC_MiniMap(map_id)
    @map_info = load_data("Data/MapInfos.rxdata")[map_id]
  end
  #--------------------------------------------------------------------------
  # ● ミニマップ表示
  #--------------------------------------------------------------------------
  def show_minimap?
    return @map_info.show_minimap?
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Event
#==============================================================================
class Game_Event < Game_Character
  #--------------------------------------------------------------------------
  # ● イベント名
  #--------------------------------------------------------------------------
  def name
    return @event.name
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_MiniMap
#------------------------------------------------------------------------------
#  ミニマップを扱うクラスです。
#==============================================================================
class Game_MiniMap
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(tilemap)
    map_rect = KGC::MiniMap::MAP_RECT
    grid_size = [KGC::MiniMap::GRID_SIZE, 1].max
    @x = 0
    @y = 0
    @size = [map_rect.width / grid_size, map_rect.height / grid_size]
    @tilemap = tilemap
    # マップ用スプライト作成
    @map_sprite = Sprite.new
    @map_sprite.x = map_rect.x
    @map_sprite.y = map_rect.y
    @map_sprite.z = KGC::MiniMap::MAP_Z
    bitmap_width = $game_map.width * grid_size + map_rect.width
    bitmap_height = $game_map.height * grid_size + map_rect.height
    @map_sprite.bitmap = Bitmap.new(bitmap_width, bitmap_height)
    @map_sprite.src_rect = map_rect
    @map_sprite.z += 1
    # オブジェクト用スプライト作成
    @object_sprite = Sprite.new
    @object_sprite.x = map_rect.x
    @object_sprite.y = map_rect.y
    @object_sprite.z = KGC::MiniMap::MAP_Z + 1
    @object_sprite.bitmap = Bitmap.new(bitmap_width, bitmap_height)
    @object_sprite.src_rect = map_rect
    # 現在位置スプライト作成
    @position_sprite = RPG::Sprite.new
    @position_sprite.x = map_rect.x + @size[0] / 2 * grid_size
    @position_sprite.y = map_rect.y + @size[1] / 2 * grid_size
    @position_sprite.z = KGC::MiniMap::MAP_Z + 2
    bitmap = Bitmap.new(grid_size, grid_size)
    bitmap.fill_rect(bitmap.rect, KGC::MiniMap::POSITION_COLOR)
    @position_sprite.bitmap = bitmap
    @position_sprite.blink_on
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    @map_sprite.bitmap.dispose
    @map_sprite.dispose
    @object_sprite.bitmap.dispose
    @object_sprite.dispose
    @position_sprite.bitmap.dispose
    @position_sprite.dispose
  end
  #--------------------------------------------------------------------------
  # ● 可視状態取得
  #--------------------------------------------------------------------------
  def visible
    return @map_sprite.visible
  end
  #--------------------------------------------------------------------------
  # ● 可視状態設定
  #--------------------------------------------------------------------------
  def visible=(value)
    @map_sprite.visible = value
    @object_sprite.visible = value
    @position_sprite.visible = value
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    draw_map
    update_object_list
    draw_object
    update_position
  end
  #--------------------------------------------------------------------------
  # ● マップ描画
  #--------------------------------------------------------------------------
  def draw_map
    bitmap = @map_sprite.bitmap
    bitmap.fill_rect(bitmap.rect, KGC::MiniMap::BACKGROUND_COLOR)
    map_rect = KGC::MiniMap::MAP_RECT
    grid_size = [KGC::MiniMap::GRID_SIZE, 1].max
    $game_map.width.times { |i|     # X座標
      $game_map.height.times { |j|  # Y座標
        if !$game_map.passable?(i, j, 0)
          next
        end
        rect = Rect.new(map_rect.width / 2 + grid_size * i,
          map_rect.height / 2 + grid_size * j,
          grid_size, grid_size)
        # 通行可能判定
        if grid_size >= 3
          if !$game_map.passable?(i, j, 2)
            rect.height -= 1
          end
          if !$game_map.passable?(i, j, 4)
            rect.x += 1
            rect.width -= 1
          end
          if !$game_map.passable?(i, j, 6)
            rect.width -= 1
          end
          if !$game_map.passable?(i, j, 8)
            rect.y += 1
            rect.height -= 1
          end
        end
        # 色設定
        color = KGC::MiniMap::FOREGROUND_COLOR
        $game_map.events.values.each { |e|
          if e.x == i && e.y == j && e.name =~ KGC::MiniMap::REGEXP_MOVE_EVENT
            color = KGC::MiniMap::MOVE_EVENT_COLOR
            break
          end
        }
        bitmap.fill_rect(rect, color)
      }
    }
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト一覧更新
  #--------------------------------------------------------------------------
  def update_object_list
    @object_list = []
    $game_map.events.values.each { |e|
      if e.name =~ KGC::MiniMap::REGEXP_OBJECT
        type = $1.to_i
        if @object_list[type] == nil
          @object_list[type] = []
        end
        @object_list[type] << e
      end
    }
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト描画
  #--------------------------------------------------------------------------
  def draw_object
    # 下準備
    bitmap = @object_sprite.bitmap
    bitmap.clear
    map_rect = KGC::MiniMap::MAP_RECT
    grid_size = [KGC::MiniMap::GRID_SIZE, 1].max
    rect = Rect.new(0, 0, grid_size, grid_size)
    mw = map_rect.width / 2
    mh = map_rect.height / 2
    # オブジェクト描画
    @object_list.each_with_index { |list, i|
      color = KGC::MiniMap::OBJECT_COLOR[i - 1]
      if list.nil? || color.nil?
        next
      end
      list.each { |obj|
        # 歩行グラフィック無しなら表示しない
        if obj.character_name != ""
          rect.x = mw + obj.real_x * grid_size / 128
          rect.y = mh + obj.real_y * grid_size / 128
          bitmap.fill_rect(rect, color)
        end
      }
    }
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def update
    draw_object
    update_position
    if @map_sprite.visible
      @map_sprite.update
      @object_sprite.update
      @position_sprite.update
    end
  end
  #--------------------------------------------------------------------------
  # ● 位置更新
  #--------------------------------------------------------------------------
  def update_position
    map_rect = KGC::MiniMap::MAP_RECT
    grid_size = [KGC::MiniMap::GRID_SIZE, 1].max
    sx = $game_player.real_x * grid_size / 128
    sy = $game_player.real_y * grid_size / 128
    @map_sprite.src_rect.x = sx
    @map_sprite.src_rect.y = sy
    @object_sprite.src_rect.x = sx
    @object_sprite.src_rect.y = sy
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map
  attr_reader :minimap
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_KGC_MiniMap initialize
  def initialize
    initialize_KGC_MiniMap
    if $game_map.show_minimap?
      @minimap = Game_MiniMap.new(@tilemap)
      if $game_system.show_minimap == nil
        $game_system.show_minimap = true
      end
      @minimap.visible = $game_system.show_minimap
    end
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  alias dispose_KGC_MiniMap dispose
  def dispose
    dispose_KGC_MiniMap
    if @minimap != nil
      @minimap.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_KGC_MiniMap update
  def update
    update_KGC_MiniMap
    if @minimap != nil
      if $game_system.show_minimap
        @minimap.visible = true
        @minimap.update
      else
        @minimap.visible = false
      end
    end
  end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
  attr_reader :spriteset
end
 | 
 评分
查看全部评分
 |