Project1

标题: 想把人物仓库改成武器仓库,改到一半不会改了,求助! [打印本页]

作者: 木许许    时间: 2014-9-12 12:51
标题: 想把人物仓库改成武器仓库,改到一半不会改了,求助!
chaochao的人物仓库,想自己改成武器仓库,现在做到左半窗口显示武器,选中按下确定武器失去,但是右半边窗口不知道怎么做,怎么让确认存放的武器转到右半窗口??

这是工程:
Project2.rar (187.95 KB, 下载次数: 38)




作者: 永燃的狂炎    时间: 2014-9-12 14:05
物品仓库不行吗?https://rpg.blue/forum.php?mod=v ... 5060&highlight=仓库
作者: 木许许    时间: 2014-9-12 15:06
永燃的狂炎 发表于 2014-9-12 14:05
物品仓库不行吗?https://rpg.blue/forum.php?mod=viewthread&tid=365060&highlight=仓库

不需要物品仓库,我只希望左窗口失去的武器能出现在右窗口上
作者: RyanBern    时间: 2014-9-12 16:51
本帖最后由 RyanBern 于 2014-9-12 16:52 编辑

简单地弄了下,一定要设置“武器仓库”的存储结构。
对于武器仓库来说,也有单个武器上限99的限制。这个要注意。
有什么BUG通知我,URL什么的别忘了去掉。
RUBY 代码复制
  1. class Game_Party
  2.   alias rb_initialize initialize
  3.   def initialize
  4.     @weapon_storage = {}
  5.     rb_initialize
  6.   end
  7.   def storage_import(item_id, number)
  8.     @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil?
  9.     current = @weapon_storage[item_id]
  10.     @weapon_storage[item_id] = [number + current, 99].min
  11.   end
  12.   def storage_export(item_id, number)
  13.     @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil?
  14.     current = @weapon_storage[item_id]
  15.     @weapon_storage[item_id] = [current - number, 0].max
  16.   end
  17.   def storage_number(item_id)
  18.     @weapon_storage[item_id].nil? ? 0 : @weapon_storage[item_id]
  19.   end
  20.   def storage_full?(item_id)
  21.     @weapon_storage[item_id] == 99
  22.   end
  23. end
  24.  
  25. class Commitem_Window_PartyLeft < Window_Selectable
  26.   def initialize
  27.     super(0, 64, 320, 324)
  28.     self.index = 0
  29.     refresh
  30.   end
  31.   def item
  32.     return @data[self.index]
  33.   end
  34.   def refresh
  35.     if self.contents != nil
  36.       self.contents.dispose
  37.       self.contents = nil
  38.     end
  39.     @data = []
  40.  
  41.     for i in 1..$data_weapons.size  #武器
  42.       if $game_party.weapon_number(i) > 0
  43.         @data.push($data_weapons[i])
  44.       end
  45.     end
  46.  
  47.     @item_max = @data.size
  48.     if @item_max > 0
  49.       self.contents = Bitmap.new(width - 32, @item_max * 32)
  50.       for i in 0...@item_max
  51.         draw_item(i)
  52.       end
  53.     end
  54.   end
  55.  
  56.   def draw_item(index)
  57.     item = @data[index]
  58.     number = $game_party.weapon_number(item.id)
  59.     self.contents.font.color = normal_color
  60.     x = 4
  61.     y = index * 32
  62.     rect = Rect.new(x,y,self.width - 32,32)
  63.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  64.     bitmap = RPG::Cache.icon(item.icon_name)
  65.     opacity = self.contents.font.color == normal_color ? 255 : 128
  66.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  67.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  68.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  69.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  70.   end
  71. end
  72.  
  73. class Commitem_Window_PartyRight < Window_Selectable
  74.   def initialize
  75.     super(320, 64, 320, 324)
  76.     self.index = -1
  77.     refresh
  78.   end
  79.   def item
  80.     return @data[self.index]
  81.   end
  82.   def refresh
  83.     if self.contents != nil
  84.       self.contents.dispose
  85.       self.contents = nil
  86.     end
  87.     @data = []
  88.     $data_weapons.each do |weapon|
  89.       next if weapon.nil?
  90.       @data.push(weapon) if $game_party.storage_number(weapon.id) > 0
  91.     end
  92.     @item_max = @data.size
  93.     if @item_max > 0
  94.       self.contents = Bitmap.new(width - 32, @item_max * 32)
  95.       for i in 0...@item_max
  96.         draw_item(i)
  97.       end
  98.     end
  99.   end
  100.  
  101.   def draw_item(index)
  102.     item = @data[index]
  103.     number = $game_party.storage_number(item.id)
  104.     self.contents.font.color = normal_color
  105.     x = 4
  106.     y = index * 32
  107.     rect = Rect.new(x,y,self.width - 32,32)
  108.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  109.     bitmap = RPG::Cache.icon(item.icon_name)
  110.     opacity = self.contents.font.color == normal_color ? 255 : 128
  111.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  112.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  113.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  114.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  115.   end
  116. end
  117.  
  118. class Commitem_Scene_Party
  119.   def main
  120.     @left_temp_command = 0
  121.     @right_temp_command = 0
  122.     @left_window = Commitem_Window_PartyLeft.new
  123.     @left_window.active = true
  124.     @right_window = Commitem_Window_PartyRight.new
  125.     @right_window.active = false
  126.  
  127.     @base = Window_Base.new(0, 0, 640, 64)
  128.     @base.contents = Bitmap.new(@base.width - 32, @base.height - 32)
  129.     @base.contents.draw_text(4, 0, @base.width - 40, 32, "武器仓库", 1)
  130.  
  131.     Graphics.transition
  132.     loop do
  133.       Graphics.update
  134.       Input.update
  135.       update
  136.       if $scene != self
  137.         break
  138.       end
  139.     end
  140.     Graphics.freeze
  141.     @left_window.dispose
  142.     @right_window.dispose
  143.     @base.dispose
  144.   end
  145.  
  146.   def update
  147.     @left_window.update
  148.     @right_window.update
  149.     update_command
  150.   end
  151.  
  152.   def update_command
  153.     if Input.trigger?(Input::B)
  154.       $game_system.se_play($data_system.cancel_se)
  155.       #画面切换
  156.       $scene = Scene_Map.new
  157.  
  158.       return
  159.     end
  160.     if @left_window.active
  161.       update_left
  162.       return
  163.     end
  164.     if @right_window.active
  165.       update_right
  166.       return
  167.     end
  168.   end
  169.  
  170.   def update_left
  171.     if Input.trigger?(Input::RIGHT)
  172.       @left_temp_command = @left_window.index
  173.       @left_window.index = -1
  174.       $game_system.se_play($data_system.cursor_se)
  175.       @left_window.active = false
  176.       @right_window.active = true
  177.       @right_window.index = @right_temp_command
  178.       return
  179.     end
  180.     if Input.trigger?(Input::C)
  181.       id = @left_window.item.id
  182.       if $game_party.weapon_number(id) > 0 && !$game_party.storage_full?(id)
  183.         $game_system.se_play($data_system.decision_se)
  184.         $game_party.lose_weapon(id, 1)
  185.         $game_party.storage_import(id, 1)
  186.         @left_window.refresh
  187.         @right_window.refresh
  188.       else
  189.         $game_system.se_play($data_system.buzzer_se)
  190.       end
  191.       return
  192.     end
  193.   end
  194.   def update_right
  195.     if Input.trigger?(Input::LEFT)
  196.       @right_temp_command = @right_window.index
  197.       @right_window.index = -1
  198.       $game_system.se_play($data_system.cursor_se)
  199.       @left_window.active = true
  200.       @right_window.active = false
  201.       @left_window.index = @left_temp_command
  202.       return
  203.     end
  204.     if Input.trigger?(Input::C)
  205.       id = @right_window.item.id
  206.       if $game_party.weapon_number(id) < 99 && $game_party.storage_number(id) > 0
  207.         $game_system.se_play($data_system.decision_se)
  208.         $game_party.gain_weapon(id, 1)
  209.         $game_party.storage_export(id, 1)
  210.         @left_window.refresh
  211.         @right_window.refresh
  212.       else
  213.         $game_system.se_play($data_system.buzzer_se)
  214.       end
  215.       return
  216.     end
  217.   end  
  218. end


作者: 木许许    时间: 2014-9-12 20:42
本帖最后由 木许许 于 2014-9-12 20:50 编辑
RyanBern 发表于 2014-9-12 16:51
简单地弄了下,一定要设置“武器仓库”的存储结构。
对于武器仓库来说,也有单个武器上限99的限制。这个要 ...


太感谢了,如果我想仓库的空间最大只能放三种武器,并且这三件的数据库编号分别代入$w1,$w2,$w3,应该怎么改?




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