chaochao的人物仓库,想自己改成武器仓库,现在做到左半窗口显示武器,选中按下确定武器失去,但是右半边窗口不知道怎么做,怎么让确认存放的武器转到右半窗口?? 这是工程: ...
RyanBern 发表于 2014-9-12 16:51 简单地弄了下,一定要设置“武器仓库”的存储结构。 对于武器仓库来说,也有单个武器上限99的限制。这个要 ...
class Game_Party alias rb_initialize initialize def initialize @weapon_storage = {} rb_initialize end def storage_import(item_id, number) @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil? current = @weapon_storage[item_id] @weapon_storage[item_id] = [number + current, 99].min end def storage_export(item_id, number) @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil? current = @weapon_storage[item_id] @weapon_storage[item_id] = [current - number, 0].max end def storage_number(item_id) @weapon_storage[item_id].nil? ? 0 : @weapon_storage[item_id] end def storage_full?(item_id) @weapon_storage[item_id] == 99 endend class Commitem_Window_PartyLeft < Window_Selectable def initialize super(0, 64, 320, 324) self.index = 0 refresh end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 1..$data_weapons.size #武器 if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] number = $game_party.weapon_number(item.id) self.contents.font.color = normal_color x = 4 y = index * 32 rect = Rect.new(x,y,self.width - 32,32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) endend class Commitem_Window_PartyRight < Window_Selectable def initialize super(320, 64, 320, 324) self.index = -1 refresh end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] $data_weapons.each do |weapon| next if weapon.nil? @data.push(weapon) if $game_party.storage_number(weapon.id) > 0 end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] number = $game_party.storage_number(item.id) self.contents.font.color = normal_color x = 4 y = index * 32 rect = Rect.new(x,y,self.width - 32,32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) endend class Commitem_Scene_Party def main @left_temp_command = 0 @right_temp_command = 0 @left_window = Commitem_Window_PartyLeft.new @left_window.active = true @right_window = Commitem_Window_PartyRight.new @right_window.active = false @base = Window_Base.new(0, 0, 640, 64) @base.contents = Bitmap.new(@base.width - 32, @base.height - 32) @base.contents.draw_text(4, 0, @base.width - 40, 32, "武器仓库", 1) Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @left_window.dispose @right_window.dispose @base.dispose end def update @left_window.update @right_window.update update_command end def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) #画面切换 $scene = Scene_Map.new return end if @left_window.active update_left return end if @right_window.active update_right return end end def update_left if Input.trigger?(Input::RIGHT) @left_temp_command = @left_window.index @left_window.index = -1 $game_system.se_play($data_system.cursor_se) @left_window.active = false @right_window.active = true @right_window.index = @right_temp_command return end if Input.trigger?(Input::C) id = @left_window.item.id if $game_party.weapon_number(id) > 0 && !$game_party.storage_full?(id) $game_system.se_play($data_system.decision_se) $game_party.lose_weapon(id, 1) $game_party.storage_import(id, 1) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end return end end def update_right if Input.trigger?(Input::LEFT) @right_temp_command = @right_window.index @right_window.index = -1 $game_system.se_play($data_system.cursor_se) @left_window.active = true @right_window.active = false @left_window.index = @left_temp_command return end if Input.trigger?(Input::C) id = @right_window.item.id if $game_party.weapon_number(id) < 99 && $game_party.storage_number(id) > 0 $game_system.se_play($data_system.decision_se) $game_party.gain_weapon(id, 1) $game_party.storage_export(id, 1) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end return end end end
class Game_Party alias rb_initialize initialize def initialize @weapon_storage = {} rb_initialize end def storage_import(item_id, number) @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil? current = @weapon_storage[item_id] @weapon_storage[item_id] = [number + current, 99].min end def storage_export(item_id, number) @weapon_storage[item_id] = 0 if @weapon_storage[item_id].nil? current = @weapon_storage[item_id] @weapon_storage[item_id] = [current - number, 0].max end def storage_number(item_id) @weapon_storage[item_id].nil? ? 0 : @weapon_storage[item_id] end def storage_full?(item_id) @weapon_storage[item_id] == 99 end end class Commitem_Window_PartyLeft < Window_Selectable def initialize super(0, 64, 320, 324) self.index = 0 refresh end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 1..$data_weapons.size #武器 if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] number = $game_party.weapon_number(item.id) self.contents.font.color = normal_color x = 4 y = index * 32 rect = Rect.new(x,y,self.width - 32,32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end end class Commitem_Window_PartyRight < Window_Selectable def initialize super(320, 64, 320, 324) self.index = -1 refresh end def item return @data[self.index] end def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] $data_weapons.each do |weapon| next if weapon.nil? @data.push(weapon) if $game_party.storage_number(weapon.id) > 0 end @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max draw_item(i) end end end def draw_item(index) item = @data[index] number = $game_party.storage_number(item.id) self.contents.font.color = normal_color x = 4 y = index * 32 rect = Rect.new(x,y,self.width - 32,32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end end class Commitem_Scene_Party def main @left_temp_command = 0 @right_temp_command = 0 @left_window = Commitem_Window_PartyLeft.new @left_window.active = true @right_window = Commitem_Window_PartyRight.new @right_window.active = false @base = Window_Base.new(0, 0, 640, 64) @base.contents = Bitmap.new(@base.width - 32, @base.height - 32) @base.contents.draw_text(4, 0, @base.width - 40, 32, "武器仓库", 1) Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @left_window.dispose @right_window.dispose @base.dispose end def update @left_window.update @right_window.update update_command end def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) #画面切换 $scene = Scene_Map.new return end if @left_window.active update_left return end if @right_window.active update_right return end end def update_left if Input.trigger?(Input::RIGHT) @left_temp_command = @left_window.index @left_window.index = -1 $game_system.se_play($data_system.cursor_se) @left_window.active = false @right_window.active = true @right_window.index = @right_temp_command return end if Input.trigger?(Input::C) id = @left_window.item.id if $game_party.weapon_number(id) > 0 && !$game_party.storage_full?(id) $game_system.se_play($data_system.decision_se) $game_party.lose_weapon(id, 1) $game_party.storage_import(id, 1) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end return end end def update_right if Input.trigger?(Input::LEFT) @right_temp_command = @right_window.index @right_window.index = -1 $game_system.se_play($data_system.cursor_se) @left_window.active = true @right_window.active = false @left_window.index = @left_temp_command return end if Input.trigger?(Input::C) id = @right_window.item.id if $game_party.weapon_number(id) < 99 && $game_party.storage_number(id) > 0 $game_system.se_play($data_system.decision_se) $game_party.gain_weapon(id, 1) $game_party.storage_export(id, 1) @left_window.refresh @right_window.refresh else $game_system.se_play($data_system.buzzer_se) end return end end end
查看全部评分
永燃的狂炎 发表于 2014-9-12 14:05 物品仓库不行吗?https://rpg.blue/forum.php?mod=viewthread&tid=365060&highlight=仓库
折叠内容标题(非必须)
折叠内容
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-11-26 22:00
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.