#========================================================================= #======随身背包============================================================ #============================================================================ $icon_wupin= 260 #物品图标的编号 $icon_wuqi= 386 #武器图标的编号 $icon_hujia= 308 #护甲图标的编号 $icon_guizhong= 358 #贵重物品图标的编号 #============================================================================== # ** Window_MapStatus #============================================================================== class Window_MapStatus < Window_Command #---------------------------------------------------------------------------- # * 初始化 #---------------------------------------------------------------------------- def initialize @command_icon_index = [$icon_wupin] super(Graphics.width-48, Graphics.height-48) end #---------------------------------------------------------------------------- # * 获取窗口宽度 #---------------------------------------------------------------------------- def window_width return 48 end #---------------------------------------------------------------------------- # * 创建命令列表 #---------------------------------------------------------------------------- def make_command_list add_command(Vocab::item,:item, true) end def draw_item(index) rect = item_rect_for_text(index) draw_icon(@command_icon_index[index], rect.x-5, rect.y) end end #============================================================================== # ** Scene_Map #============================================================================== class Scene_Map<Scene_Base #---------------------------------------------------------------------------- # * 重命名方法 #---------------------------------------------------------------------------- alias o_start start #---------------------------------------------------------------------------- # * 开始处理 #---------------------------------------------------------------------------- def start o_start create_menu_window end def create_menu_window @menu_command = Window_MapStatus.new @menu_command.set_handler(:item , method(:item_ok)) end def item_ok SceneManager.call(Scene_NewItem) end end #------------------------------------------------------------------------------ # 物品画面和商店画面中,显示装备、所持物品等项目列表的窗口。 #============================================================================== class Window_NewItemCategory < Window_HorzCommand #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_reader :item_window #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize @command_icon_index = [$icon_wupin,$icon_wuqi,$icon_hujia,$icon_guizhong] super(Graphics.width-220, Graphics.height-368) end #-------------------------------------------------------------------------- # ● 获取窗口的宽度 #-------------------------------------------------------------------------- def window_width 220 end #-------------------------------------------------------------------------- # ● 获取列数 #-------------------------------------------------------------------------- def col_max return 4 end #-------------------------------------------------------------------------- # ● 更新画面 #-------------------------------------------------------------------------- def update super @item_window.category = current_symbol if @item_window end #-------------------------------------------------------------------------- # ● 生成指令列表 #-------------------------------------------------------------------------- def make_command_list add_command(Vocab::item, :item) add_command(Vocab::weapon, :weapon) add_command(Vocab::armor, :armor) add_command(Vocab::key_item, :key_item) end #-------------------------------------------------------------------------- # ● 设置物品窗口 #-------------------------------------------------------------------------- def item_window=(item_window) @item_window = item_window update end def draw_item(index) rect = item_rect_for_text(index) draw_icon(@command_icon_index[index], rect.x+5, rect.y) end end #encoding:utf-8 #============================================================================== # ■ Window_NewItemList #------------------------------------------------------------------------------ # 物品画面中,显示持有物品的窗口。 #============================================================================== class Window_NewItemList < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(Graphics.width-220,Graphics.height-326,220,278) @category = :none @data = [] end #-------------------------------------------------------------------------- # ● 设置分类 #-------------------------------------------------------------------------- def category=(category) return if @category == category @category = category refresh self.oy = 0 end #-------------------------------------------------------------------------- # ● 获取列数 #-------------------------------------------------------------------------- def col_max return 4 end #-------------------------------------------------------------------------- # ● 获取项目数 #-------------------------------------------------------------------------- def item_max @data ? @data.size : 1 end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def item @data && index >= 0 ? @data[index] : nil end #-------------------------------------------------------------------------- # ● 获取选择项目的有效状态 #-------------------------------------------------------------------------- def current_item_enabled? enable?(@data[index]) end #-------------------------------------------------------------------------- # ● 查询列表中是否含有此物品 #-------------------------------------------------------------------------- def include?(item) case @category when :item item.is_a?(RPG::Item) && !item.key_item? when :weapon item.is_a?(RPG::Weapon) when :armor item.is_a?(RPG::Armor) when :key_item item.is_a?(RPG::Item) && item.key_item? else false end end #-------------------------------------------------------------------------- # ● 查询此物品是否可用 #-------------------------------------------------------------------------- def enable?(item) $game_party.usable?(item) end #-------------------------------------------------------------------------- # ● 生成物品列表 #-------------------------------------------------------------------------- def make_item_list @data = $game_party.all_items.select {|item| include?(item) } @data.push(nil) if include?(nil) end #-------------------------------------------------------------------------- # ● 返回上一个选择的位置 #-------------------------------------------------------------------------- def select_last select(@data.index($game_party.last_item.object) || 0) end #-------------------------------------------------------------------------- # ● 绘制项目 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] if item rect = item_rect(index) rect.width -= 4 color = Color.new(40, 40, 40) self.contents.fill_rect(rect.x, rect.y, 24, 1, color) self.contents.fill_rect(rect.x, rect.y, 1, 24, color) self.contents.fill_rect(rect.x, rect.y+23, 24, 1, color) self.contents.fill_rect(rect.x+23, rect.y, 1, 24, color) draw_icon(item.icon_index,rect.x,rect.y,enable?(item)) rect.width += 9 rect.height += 14 draw_item_number(rect, item) end end #-------------------------------------------------------------------------- # ● 绘制物品个数 #-------------------------------------------------------------------------- def draw_item_number(rect, item) draw_text(rect, sprintf("%2d", $game_party.item_number(item)), 2) end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh make_item_list create_contents draw_all_items end end #encoding:utf-8 #============================================================================== # ■ Scene_Item #------------------------------------------------------------------------------ # 物品画面 #============================================================================== class Scene_NewItem < Scene_ItemBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super create_menu_window2 create_category_window create_item_window end #-------------------------------------------------------------------------- # ● 生成分类窗口 #-------------------------------------------------------------------------- def create_category_window @category_window = Window_NewItemCategory.new @category_window.viewport = @viewport @category_window.set_handler(:ok, method(:on_category_ok)) @category_window.set_handler(:cancel, method(:return_scene)) end #-------------------------------------------------------------------------- # ● 生成物品窗口 #-------------------------------------------------------------------------- def create_item_window wy = @category_window.y + @category_window.height wh = Graphics.height @item_window = Window_NewItemList.new(0, wy, Graphics.width, wh) @item_window.viewport = @viewport @item_window.set_handler(:ok, method(:on_item_ok)) @item_window.set_handler(:cancel, method(:on_item_cancel)) @category_window.item_window = @item_window end #-------------------------------------------------------------------------- # ● 分类“确定” #-------------------------------------------------------------------------- def on_category_ok @item_window.activate @item_window.select_last end #-------------------------------------------------------------------------- # ● 物品“确定” #-------------------------------------------------------------------------- def on_item_ok $game_party.last_item.object = item determine_item end #-------------------------------------------------------------------------- # ● 物品“取消” #-------------------------------------------------------------------------- def on_item_cancel @item_window.unselect @category_window.activate end #-------------------------------------------------------------------------- # ● 播放使用物品声效 #-------------------------------------------------------------------------- def play_se_for_item Sound.play_use_item end #-------------------------------------------------------------------------- # ● 使用物品 #-------------------------------------------------------------------------- def use_item super @item_window.redraw_current_item end def create_menu_window2 @menu_command = Window_MapStatus.new @menu_command.set_handler(:ok , method(:return_scene )) end end
#装备栏 module VIPArcher::Equipplus TIME = 0 end class Scene_NewItem < Scene_ItemBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- alias help_ex_start start def start help_ex_start create_help_ex end end
BEIBAO1.png (68.97 KB, 下载次数: 37)
BEIBAO2.png (90.82 KB, 下载次数: 35)
1.67 MB, 下载次数: 169
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |