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

Project1

 找回密码
 注册会员
搜索

物品名称不见了

查看数: 2148 | 评论数: 3 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2014-1-29 16:18

正文摘要:

物品名称不见了怎么弄回去

回复

754707165 发表于 2014-2-2 18:12:19
顶贴
754707165 发表于 2014-1-29 18:39:32
本帖最后由 754707165 于 2014-1-30 14:20 编辑

module Equipplus
  CODE ={
    11 => "属性抗性",
    12 => "弱化抗性",
    13 => "状态抗性",
    14 => "状态免疫",
    21 => "基本能力",
    22 => "附加能力",
    23 => "独有能力",
    31 => "攻击附带属性",
    32 => "攻击附带状态",
    33 => "修正攻击速度",
    34 => "添加攻击次数",
    41 => "添加技能类型",
    42 => "禁用技能类型",
    43 => "添加技能",
    44 => "禁用技能",
    51 => "可装备武器类型",
    52 => "可装备护甲类型",
    53 => "固定装备",
    54 => "禁用装备",
    55 => "装备风格",
    61 => "添加行动次数",
    62 => "特殊标志",
    63 => "消失效果",
    64 => "队伍能力"}
  #特殊标志
  FLAG ={
                0 => "自动战斗",
                1 => "擅长防御",
                2 => "保护弱者",
                3 => "特技专注"}
  #普通能力
        PARAM ={
                0 => "血量上限",
                1 => "魔力上限",
                2 => "物理破坏力",
                3 => "物理防御力",
                4 => "魔法破坏力",
                5 => "魔法防御力",
                6 => "灵巧值",
                7 => "幸运值"}
  #添加能力
        XPARAM ={
                0 => "攻击率:",
                1 => "闪避率:",
                2 => "暴击率:",
                3 => "保护率:",
                4 => "魔力抵消率:",
                5 => "魔力克制率:",
                6 => "物理反击率:",
                7 => "伤口愈合率:",
                8 => "魔力产生率:",
                9 => "怒气攻心率:"}
  #特殊能力
        SPARAM ={
                0 => "受到攻击率",
                1 => "防御效果率",
                2 => "恢复效果率",
                3 => "药理知识",
                4 => "魔法熟练度",
                5 => "怒气释放率",
                6 => "物理攻击伤害加成",
                7 => "魔法攻击伤害加成",
                8 => "洞察能力",
                9 => "领悟能力"}
        @队伍能力 ={
                0 => "霸气外露",
                1 => "随机遇敌无效",
                2 => "很高的警惕性",
                3 => "善于隐藏自己",
                4 => "财神附体",
                5 => "幸运女神"}
  def self.equiphelpready
    @状态 = {}
    @武器类型 = {}
    @防具类型 = {}
    @属性 = {}
    $data_states.each{|x| @状态[x.id] = x.name if x != nil}
    elements = $data_system.elements
    weapon_types = $data_system.weapon_types
    armor_types = $data_system.armor_types
    elements.each_with_index{|x,y| @属性[y] = x if x != ""}
    weapon_types.each_with_index{|x,y| @武器类型[y] = x if x != ""}
    armor_types.each_with_index{|x,y| @防具类型[y] = x if x != ""}
  end
  def self.getequiphelp(equip)
    help = ""
    param = []
    equip.params.each_with_index{|x,y| param.push([PARAM[y],x])}
    param = param.select{|x| x[1] != 0}
    param.each{|x| help += x[0] + ":" + x[1].to_int.to_s + "\n"}
    features = equip.features
    features.select{|x| x.code == 55}.each{|x| help += CODE[x.code] + ":双持武器" + "\n"}
    features.select{|x| x.code == 11}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "*" + x.value.to_s + "\n"}
    features.select{|x| x.code == 12}.each{|x| help += CODE[x.code] + ":" + PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
    features.select{|x| x.code == 13}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "*" + x.value.to_s + "\n"}
    features.select{|x| x.code == 14}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "\n"}
    features.select{|x| x.code == 31}.each{|x| help += CODE[x.code] + ":" + @属性[x.data_id] + "\n"}
    features.select{|x| x.code == 32}.each{|x| help += CODE[x.code] + ":" + @状态[x.data_id] + "+" + x.value.to_s + "\n"}
    features.select{|x| x.code == 33}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
    features.select{|x| x.code == 34}.each{|x| help += CODE[x.code] + ":" + x.value.to_s + "\n"}
    features.select{|x| x.code == 41}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
    features.select{|x| x.code == 42}.each{|x| help += CODE[x.code] + ":" + (x.data_id == 1 ? "特技" : "魔法")  + "\n"}
    features.select{|x| x.code == 43}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
    features.select{|x| x.code == 44}.each{|x| help += CODE[x.code] + ":" + $data_skills[x.data_id].name  + "\n"}
    features.select{|x| x.code == 51}.each{|x| help += CODE[x.code] + ":" + @武器类型[x.data_id]  + "\n"}
    features.select{|x| x.code == 52}.each{|x| help += CODE[x.code] + ":" + @防具类型[x.data_id]  + "\n"}
    features.select{|x| x.code == 61}.each{|x| help += CODE[x.code] + ":" + x.value.to_s  + "\n"}
    features.select{|x| x.code == 62}.each{|x| help += CODE[x.code] + ":" + FLAG[x.data_id]  + "\n"}
    features.select{|x| x.code == 64}.each{|x| help += CODE[x.code] + ":" + @队伍能力[x.data_id]  + "\n"}
    featuresparam = []
    featuresparam.push features.select{|x| x.code == 21}
    featuresparam.push features.select{|x| x.code == 22}
    featuresparam.push features.select{|x| x.code == 23}
    featuresparam[0].each{|x| help += PARAM[x.data_id] + "*" + x.value.to_s + "\n"}
    featuresparam[1].each{|x| help += XPARAM[x.data_id] + x.value.to_s + "\n"}
    featuresparam[2].each{|x| help += SPARAM[x.data_id] + "*" + x.value.to_s + "\n"}
    help
  end
  def self.getline(text,maxtext)
    xtext = []
    line = 0
    text.each_line{|x| xtext.push x.sub(/\n/){}}
    xtext.each{|x| x.size % maxtext != 0 ? line += x.size / maxtext + 1 : line += x.size / maxtext}
    line
  end
end
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
#  显示特技和物品等的说明、以及角色状态的窗口
#==============================================================================

class Window_Help2 < Window_Base
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(line_number = 0)
    super(0, 0, 210, 0)
    self.z = 150
    contents.font.size = 14
    hide
  end
  #--------------------------------------------------------------------------
  # ● 设置内容
  #--------------------------------------------------------------------------
  def set_text(text)
      @text = text
      refresh
  end
  #--------------------------------------------------------------------------
  # ● 清除
  #--------------------------------------------------------------------------
  def clear
    set_text("")
  end
  #--------------------------------------------------------------------------
  # ● 更新帮助位置
  #--------------------------------------------------------------------------
  def uppos(index,rect,window)
    self.height = fitting_height2(Equipplus.getline(@xtext,13))
    create_contents
    contents.font.size = 15
    rect.x -= window.ox
    rect.y -= window.oy
    ax = rect.x + rect.width + 10
    ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
    ax += window.x
    ax = 0 if ax < 0
    ay = rect.y + rect.height
    ay = rect.y - self.height if ay + self.height > window.height
    ay += window.y
    ay = 0 if ay < 0
    self.x = ax
    self.y = ay
    set_text(@xtext)
    show
  end
  #--------------------------------------------------------------------------
  # ● 设置物品
  #     item : 技能、物品等
  #--------------------------------------------------------------------------
  def set_item(item)
    if item == nil
      set_text("")
      return
    end
    @xtext = ""
    @xtext = "名称:" + item.name + "\n"
    @xtext += "介绍:" + item.description + "\n"
    @xtext += "价格:" + item.price.to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
    @xtext += "持有:" + $game_party.item_number(item).to_s + "\n" if item.is_a?(RPG::EquipItem) || item.is_a?(RPG::Item)
    @xtext += Equipplus.getequiphelp(item) if item.is_a?(RPG::EquipItem)
    @xtext = @xtext[0,@text.size - 2] if @xtext[@xtext.size - 2,2] == "\n"
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    hide if @text == ""
    draw_text_ex(4, 0, @text,width,40,false)
  end
end
class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 计算窗口显示指定行数时的应用高度2*************************
  #--------------------------------------------------------------------------
  def fitting_height2(line_number)
    line_number * contents.font.size + standard_padding * 2
  end
# draw_text_ex的增强,使其可以自动换行  原作者:叶子 修改:wyongcan
  #--------------------------------------------------------------------------
  # ● 绘制带有控制符的文本内容
  #   如果传递了width参数的话,会自动换行
  #--------------------------------------------------------------------------
  def draw_text_ex(x, y, text, width = nil,textwidth = nil,normalfont = true)
    reset_font_settings if normalfont == true
    text = convert_escape_characters(text)
    pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
    if width != nil
      pos[:height] = contents.font.size
      pos[:width] = width
      pos[:textwidth] = textwidth
    end
    process_character(text.slice!(0, 1), text, pos) until text.empty?
  end
  #--------------------------------------------------------------------------
  # ● 文字的处理
  #     c    : 文字
  #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  #--------------------------------------------------------------------------
  def process_character(c, text, pos)
    case c
    when "\r"   # 回车
      return
    when "\n"   # 换行
      process_new_line(text, pos)
    when "\f"   # 翻页
      process_new_page(text, pos)
    when "\e"   # 控制符
      process_escape_character(obtain_escape_code(text), text, pos)
    else        # 普通文字
      pos[:textwidth] == nil ? text_width = text_size(c).width : text_width = pos[:textwidth]
      if pos[:width] != nil && pos[:x] - pos[:new_x] + text_width > pos[:width]
        process_new_line(text, pos)
      end
      process_normal_character(c, pos)
    end
  end
end

class Window_ItemList < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item)
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  end
end

class Window_SkillList < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item)
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil
  end
end

class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_item(item) if @help_window
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
    @status_window.item = item if @status_window
  end
end

class Window_EquipSlot < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 更新帮助内容
  #--------------------------------------------------------------------------
  def update_help
    super
    @help_window.set_item(item) if @help_window
    @help_window.uppos(index,item_rect(index),self) if index != -1 && item != nil && @help_window
    @status_window.set_temp_actor(nil) if @status_window
  end
end

class Scene_Shop < Scene_MenuBase
        alias on_sell_ok_old on_sell_ok
        def on_sell_ok
                on_sell_ok_old
                @help_window.hide
        end
        alias on_buy_ok_old on_buy_ok
        def on_buy_ok
                on_buy_ok_old
                @help_window.hide
        end
        alias on_number_ok_old on_number_ok
        def on_number_ok
                on_number_ok_old
    @help_window.refresh
                @help_window.show
        end
        alias on_number_cancel_old on_number_cancel
        def on_number_cancel
                on_number_cancel_old
    @help_window.refresh
                @help_window.show
        end
end

class Scene_Title < Scene_Base
  alias start_old start
  def start
    start_old
    Equipplus.equiphelpready
  end
end

class Scene_ItemBase < Scene_MenuBase
        alias old_on_actor_cancel on_actor_cancel
  def on_actor_cancel
    old_on_actor_cancel
        @help_window.refresh
  end
        alias old_on_actor_ok on_actor_ok
  def on_actor_ok
    old_on_actor_ok
        @help_window.refresh
  end
end

class Window_Base < Window
        alias old_process_new_line process_new_line
        def process_new_line(text, pos)
    old_process_new_line(text, pos)
                pos[:height] = contents.font.size if pos[:width] != nil
        end
end

class Scene_MenuBase < Scene_Base
  def create_help_window
    @help_window = Window_Help2.new
    @help_window.viewport = @viewport
  end
end
class Scene_Battle < Scene_Base
  def create_help_window
    @help_window = Window_Help2.new
    @help_window.visible = false
  end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
#  选项重新定义
#==============================================================================
class Window_ItemCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 添加指令
  #     color     : 指令字体颜色
  #     icon_index: 指令图标
  #     name      : 指令名称
  #     symbol    : 对应的符号
  #     enabled   : 有效状态的标志
  #     ext       : 任意的扩展数据
  #--------------------------------------------------------------------------
  def add_command(name, symbol, enabled = true, color = Color.new(255,255,255) ,icon_index = 0 ,ext = nil)
    @list.push({:color=>color, :icon_index=>icon_index, :name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext})
  end
  #--------------------------------------------------------------------------
  # ● 获取指令字体颜色
  #--------------------------------------------------------------------------
  def command_color(index)
    @list[index][:color]
  end
  #--------------------------------------------------------------------------
  # ● 获取指令图标
  #--------------------------------------------------------------------------
  def command_icon_index(index)
    @list[index][:icon_index]
  end
  def draw_text_in_rect(rect, str,icon_index,enabled = true, align = 0)
    draw_icon(icon_index, rect.x, rect.y, enabled)
    if icon_index > 0
      draw_text(rect.x + 24, rect.y, rect.width - 28, line_height,str)
    else
      draw_text(rect.x, rect.y, rect.width - 8, line_height,str)
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制项目
  #--------------------------------------------------------------------------
  def draw_item(index)
    change_color(command_color(index), command_enabled?(index))
    draw_text_in_rect(item_rect_for_text(index), command_name(index),command_icon_index(index))   
  end
end
#==============================================================================
# ■ Window_ItemCommand
#------------------------------------------------------------------------------
#  物品画面中,显示装备选项的窗口。
#==============================================================================
class Window_ItemCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(item)
    @item = item
    super(0,0)
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # ● 获取列数
  #--------------------------------------------------------------------------
  def visible_line_number
    return 4
  end
  def enable?
    $game_party.usable?(@item)
  end
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("使用物品",   :use_item   , enable?,Color.new(11,168,3)   ,121)
    add_command("卖出物品",   :sell_item  , true   ,Color.new(252,236,15) ,361)
    add_command("丢弃物品",   :giveup_item, true   ,Color.new(242,119,14) ,227)
    add_command("取消",       :cancel     , true   ,Color.new(173,164,156))
  end
  #--------------------------------------------------------------------------
  # ● 更新帮助位置
  #--------------------------------------------------------------------------
  def uppos(index,rect,window)
    create_contents
    clear_command_list
    make_command_list
    rect.x -= window.ox
    rect.y -= window.oy
    ax = rect.x + rect.width + 10
    ax = rect.x - self.width + 10 if ax + self.width > window.width + 10
    ax += window.x
    ax = 0 if ax < 0
    ay = rect.y + rect.height
    ay = rect.y - self.height if ay + self.height > window.height
    ay += window.y
    ay = 0 if ay < 0
    self.x = ax
    self.y = ay
    refresh
    show
  end
  
end
#==============================================================================
# ■ Window_ItemCategory
#------------------------------------------------------------------------------
#  物品画面和商店画面中,显示装备、所持物品等项目列表的窗口。
#==============================================================================
class Window_New_ItemCategory < Window_Command
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :item_window
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize
    super(0,72)
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    return 168
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的高度
  #--------------------------------------------------------------------------
  def window_height
    return Graphics.height - 72
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    @item_window.category = current_symbol if @item_window
  end
  #--------------------------------------------------------------------------
  # ● 生成指令列表
  #--------------------------------------------------------------------------
  def make_command_list
    add_command("全部道具",     :none)
    add_command("全部物品",     :item)
    add_command("全部武器",   :weapon)
    add_command("全部防具",   :armor)
    add_command("消耗品",       :use_item)
    for i in 0 ... $kind_of_item.size
    add_command($kind_of_item,("kind_"+i.to_s).to_sym)
    end
    add_command(Vocab::key_item, :key_item)
  end
  #--------------------------------------------------------------------------
  # ● 设置物品窗口
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
end
#==============================================================================
# ■ Window_ItemList
#------------------------------------------------------------------------------
#  物品画面中,显示持有物品的窗口。
#==============================================================================
class Window_ItemList2 < Window_ItemList
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super
    @category = :none
    @data = []
  end
  #--------------------------------------------------------------------------
  # ● 获取列数
  #--------------------------------------------------------------------------
  def col_max
    return 12
  end
  #--------------------------------------------------------------------------
  # ● 项目间隔
  #--------------------------------------------------------------------------
  def spacing
    return 4
  end
  #--------------------------------------------------------------------------
  # ● 获取选择项目的有效状态
  #--------------------------------------------------------------------------
  def current_item_enabled?
    true
  end
  #--------------------------------------------------------------------------
  # ● 查询列表中是否含有此物品
  #--------------------------------------------------------------------------
  def include?(item)
    case @category
    when :none
      true if item
    when :item
      item.is_a?(RPG::Item) && !item.key_item?
    when :use_item
      item.is_a?(RPG::Item) && !item.key_item? && item.consumable
    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
      if item.is_a?(RPG::Item)
        a = @category.to_s[5,2]
        return true if item.class_id == a.to_i
      else
        false
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成物品列表
  #--------------------------------------------------------------------------
  def make_item_list
    @data = $game_party.all_items.select {|item| include?(item) }
    @data.push(nil) if include?(nil)
  end
  #--------------------------------------------------------------------------
  # ● 绘制项目
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect(index)
      rect.width -= 4
      draw_icon(item.icon_index, rect.x, rect.y, enable?(item))
    end
  end
end
#==============================================================================
# ■ Window_Control_Number
#------------------------------------------------------------------------------
#  物品选择数量画面
#==============================================================================
class Window_Control_Number < Window_ShopNumber
  #--------------------------------------------------------------------------
  # ● 定义实例变量
  #--------------------------------------------------------------------------
  attr_reader   :number                   # 数量
  #--------------------------------------------------------------------------
  # ● 初始化
  #--------------------------------------------------------------------------
  def initialize(x,y,w,h)
    @window_w = w
    super(x,y,h)
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    return @window_w
  end
  #--------------------------------------------------------------------------
  # ● 计算窗口内容的宽度
  #--------------------------------------------------------------------------
  def contents_width
    width - standard_padding * 2
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_item_name(@item, 4, 0)
    draw_number
    draw_total_price
  end
  #--------------------------------------------------------------------------
  # ● 绘制数量
  #--------------------------------------------------------------------------
  def draw_number
    change_color(normal_color) # x = cursor_x - 28
    draw_text(4, fitting_height(1)-12, 22, line_height, "×")
    draw_text(32, fitting_height(1)-12, cursor_width - 4, line_height, @number, 2)
  end
  #--------------------------------------------------------------------------
  # ● 绘制总价
  #--------------------------------------------------------------------------
  def draw_total_price
    width = contents_width - 60
    draw_currency_value(@price * @number, @currency_unit, 4, price_y + 8, width)
  end
  #--------------------------------------------------------------------------
  # ● 更新光标
  #--------------------------------------------------------------------------
  def update_cursor
    cursor_rect.set(32, fitting_height(1)-12, cursor_width - 4, line_height)
  end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
#  物品画面
#==============================================================================
class Scene_Item < Scene_ItemBase
  #--------------------------------------------------------------------------
  # ● 开始处理
  #--------------------------------------------------------------------------
  def start
    super
    @control_kind = :none
    create_help_window
    create_category_window
    create_item_window
    create_item_logo
  end
  #--------------------------------------------------------------------------
  # ● 生成Logo
  #--------------------------------------------------------------------------
  def create_item_logo
    @logo_window = Window_Base.new(0,0,@category_window.width,Graphics.height - @category_window.height)
    @logo_window.draw_icon(264,4,0)
    @logo_window.draw_text(28,0,@logo_window.width - 28,@logo_window.line_height,"我的包裹")
    @logo_window.make_font_smaller
    @logo_window.draw_text(4,26,@logo_window.width - 4,@logo_window.line_height,"道具数:"+$game_party.all_items.size.to_s)
    @logo_window.make_font_bigger
    @logo_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● 刷新Logo
  #--------------------------------------------------------------------------
  def refresh_item_logo
    @logo_window.contents.clear
    @logo_window.draw_icon(264,4,0)
    @logo_window.draw_text(28,0,@logo_window.width - 28,@logo_window.line_height,"我的包裹")
    @logo_window.make_font_smaller
    @logo_window.draw_text(4,26,@logo_window.width - 4,@logo_window.line_height,"道具数:"+$game_party.all_items.size.to_s)
    @logo_window.make_font_bigger
    @logo_window.viewport = @viewport
  end
  #--------------------------------------------------------------------------
  # ● 生成控制数量
  #--------------------------------------------------------------------------
  def create_item_control_amount
    x = 145
    y = 140
    w = Graphics.width - x * 2
    h = Graphics.height - y * 2
    @control_amount = Window_Control_Number.new(x,y,w,h)
    @control_amount.viewport = @viewport
    @control_amount.set_handler(:ok,   method(:on_item_control))
    @control_amount.set_handler(:cancel,   method(:back_to_choose_item))
  end
  #--------------------------------------------------------------------------
  # ● 生成物品控制窗口
  #--------------------------------------------------------------------------
  def create_item_control
    @item_control = Window_ItemCommand.new(item)
    @item_control.viewport = @viewport
    @item_control.set_handler(:use_item,   method(:on_item_use))
    @item_control.set_handler(:sell_item,  method(:sell_item))
    @item_control.set_handler(:giveup_item,method(:giveup_item))
    @item_control.set_handler(:cancel,     method(:back_to_choose_item))
  end
  #--------------------------------------------------------------------------
  # ● 生成物品分类窗口
  #--------------------------------------------------------------------------
  def create_category_window
    @category_window = Window_New_ItemCategory.new
    @category_window.viewport = @viewport
    @category_window.help_window = @help_window
    @category_window.set_handler(:ok,     method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:return_scene))
    @category_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 生成物品窗口
  #--------------------------------------------------------------------------
  def create_item_window
    @item_window = Window_ItemList2.new(@category_window.width, 0, Graphics.width - @category_window.width, Graphics.height)
    @item_window.help_window = @help_window
    @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
    @item_window.refresh
  end
  #--------------------------------------------------------------------------
  # ● 分类“确定”
  #--------------------------------------------------------------------------
  def on_category_ok
    @item_window.activate
    @item_window.select_last
  end
  #--------------------------------------------------------------------------
  # ● 物品“确定”
  #--------------------------------------------------------------------------
  def on_item_ok
    @help_window.hide
    create_item_control
    @item_control.uppos(@item_window.index,@item_window.item_rect(@item_window.index),@item_window)
    @item_control.activate
  end
  #--------------------------------------------------------------------------
  # ● 返回选择物品
  #--------------------------------------------------------------------------
  def back_to_choose_item
    @control_amount.hide if @control_amount
    @item_control.hide
    @item_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 物品“取消”
  #--------------------------------------------------------------------------
  def on_item_cancel
    @item_window.unselect
    @category_window.activate
  end
  #--------------------------------------------------------------------------
  # ● 播放使用物品声效
  #--------------------------------------------------------------------------
  def play_se_for_item
    Sound.play_use_item
  end
  #--------------------------------------------------------------------------
  # ● 卖出物品(选择数量)
  #--------------------------------------------------------------------------
  def sell_item
    create_item_control_amount
    @control_amount.set(item, max_sell, selling_price, currency_unit)
    @control_amount.activate
    @control_kind = :sell
  end
  #--------------------------------------------------------------------------
  # ● 丢弃物品(选择数量)
  #--------------------------------------------------------------------------
  def giveup_item
    create_item_control_amount
    @control_amount.set(item, max_sell, 0, currency_unit)
    @control_amount.activate
    @control_kind = :giveup
  end
  #--------------------------------------------------------------------------
  # ● 结束选择数量
  #--------------------------------------------------------------------------
  def on_item_control
    case @control_kind
    when :sell
      do_sell(@control_amount.number)
    when :giveup
      do_giveup(@control_amount.number)
    end
    refresh_item_logo
    @item_window.refresh
    back_to_choose_item
  end
  #--------------------------------------------------------------------------
  # ● 执行卖出
  #--------------------------------------------------------------------------
  def do_sell(number)
    $game_party.gain_gold(number * selling_price)
    $game_party.lose_item(item, number)
  end
  #--------------------------------------------------------------------------
  # ● 执行丢弃
  #--------------------------------------------------------------------------
  def do_giveup(number)
    $game_party.lose_item(item, number)
  end
  #--------------------------------------------------------------------------
  # ● 获取货币单位
  #--------------------------------------------------------------------------
  def currency_unit
    Vocab::currency_unit
  end
  #--------------------------------------------------------------------------
  # ● 获取可以卖出的最大值
  #--------------------------------------------------------------------------
  def max_sell
    $game_party.item_number(item)
  end
  #--------------------------------------------------------------------------
  # ● 获取卖出价格
  #--------------------------------------------------------------------------
  def selling_price
    item.price / 2
  end
  #--------------------------------------------------------------------------
  # ● 使用物品(选择角色)
  #--------------------------------------------------------------------------
  def on_item_use
    @item_control.hide
    $game_party.last_item.object = item
    determine_item
  end
  #--------------------------------------------------------------------------
  # ● 使用物品
  #--------------------------------------------------------------------------
  def use_item
    super
    @item_window.redraw_current_item
    refresh_item_logo
  end
end
喵呜喵5 发表于 2014-1-29 17:43:24
你加什么脚本了?
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-11-16 02:39

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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