Project1

标题: 关于物品描绘的问题。。 [打印本页]

作者: 夏萝酱    时间: 2010-10-10 14:06
提示: 作者被禁止或删除 内容自动屏蔽
作者: 禾西    时间: 2010-10-10 14:54
本帖最后由 禾西 于 2010-10-11 02:54 编辑

沒測試
  1. #==============================================================================
  2. # ■ Game_Party
  3. #------------------------------------------------------------------------------
  4. class Game_Party
  5.   #--------------------------------------------------------------------------
  6.   # ● 增加物品
  7.   #--------------------------------------------------------------------------
  8.   def gain_item(item_id, n)
  9.     if item_id > 0
  10.       @items[item_id] = [item_number(item_id) + n, 0].max
  11.     end
  12.   end
  13.   #--------------------------------------------------------------------------
  14.   # ● 增加武器
  15.   #--------------------------------------------------------------------------
  16.   def gain_weapon(weapon_id, n)
  17.     if weapon_id > 0
  18.       @weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
  19.     end
  20.   end
  21.   #--------------------------------------------------------------------------
  22.   # ● 增加防具
  23.   #--------------------------------------------------------------------------
  24.   def gain_armor(armor_id, n)
  25.     if armor_id > 0
  26.       @armors[armor_id] = [armor_number(armor_id) + n, 0].max
  27.     end
  28.   end
  29. end
  30. #==============================================================================
  31. # ■ Window_Item
  32. #------------------------------------------------------------------------------
  33. class Window_Item < Window_Selectable
  34.   #--------------------------------------------------------------------------
  35.   # ● 刷新
  36.   #--------------------------------------------------------------------------
  37.   def refresh
  38.     if self.contents != nil
  39.       self.contents.dispose
  40.       self.contents = nil
  41.     end
  42.     @data = []
  43. #---------------------------------------------
  44.     # 添加报务
  45.     for i in 1...$data_items.size
  46.       if $game_party.item_number(i) > 0
  47.         ( ( $game_party.item_number(i) - 1 ) /99 + 1).times do
  48.           @data.push($data_items[i])
  49.         end
  50.       end
  51.     end
  52.     # 在战斗中以外添加武器、防具
  53.     unless $game_temp.in_battle
  54.       for i in 1...$data_weapons.size
  55.         if $game_party.weapon_number(i) > 0
  56.           ( ( $game_party.weapon_number(i) - 1 ) /99 + 1).times do
  57.             @data.push($data_weapons[i])
  58.           end
  59.         end
  60.       end
  61.       for i in 1...$data_armors.size
  62.         if $game_party.armor_number(i) > 0
  63.           ( ( $game_party.armor_number(i) - 1 ) /99 + 1).times do
  64.             @data.push($data_armors[i])
  65.           end
  66.         end
  67.       end
  68.     end
  69. #---------------------------------------------
  70.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  71.     @item_max = @data.size
  72.     if @item_max > 0
  73.       self.contents = Bitmap.new(width - 32, row_max * 32)
  74.       @last_item = []
  75.       for i in 0...@item_max
  76.         draw_item(i)
  77.       end
  78.     end
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # ● 描绘项目
  82.   #     index : 项目编号
  83.   #--------------------------------------------------------------------------
  84.   def draw_item(index)
  85.     item = @data[index]
  86.     case item
  87.     when RPG::Item
  88.       number = $game_party.item_number(item.id)
  89.     when RPG::Weapon
  90.       number = $game_party.weapon_number(item.id)
  91.     when RPG::Armor
  92.       number = $game_party.armor_number(item.id)
  93.     end
  94. #---------------------------------------------
  95.     if number > 99
  96.       if @last_item[0] != index
  97.         @last_item = [index, number]
  98.       end
  99.       @last_item[1] -= 99
  100.       number = [ 99, @last_item[1] ].min
  101.     end
  102. #---------------------------------------------
  103.     if item.is_a?(RPG::Item) and
  104.        $game_party.item_can_use?(item.id)
  105.       self.contents.font.color = normal_color
  106.     else
  107.       self.contents.font.color = disabled_color
  108.     end
  109.     x = 4 + index % 2 * (288 + 32)
  110.     y = index / 2 * 32
  111.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  112.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  113.     bitmap = RPG::Cache.icon(item.icon_name)
  114.     opacity = self.contents.font.color == normal_color ? 255 : 128
  115.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  116.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  117.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  118.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  119.   end
  120. end
复制代码

作者: 夏萝酱    时间: 2010-10-10 22:39
提示: 作者被禁止或删除 内容自动屏蔽




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