赞 | 46 |
VIP | 271 |
好人卡 | 233 |
积分 | 94 |
经验 | 181865 |
最后登录 | 2024-9-17 |
在线时间 | 2748 小时 |
Lv4.逐梦者 「Pemercyia」 泱 银 Urhurrenna
- 梦石
- 0
- 星屑
- 9397
- 在线时间
- 2748 小时
- 注册时间
- 2008-9-5
- 帖子
- 3543
|
本帖最后由 cinderelmini 于 2015-9-19 14:35 编辑
【Window_ShopBuy】改成这样(添加的东西放到了顶格,然后draw_item方法改了):- #==============================================================================
- # ■ Window_ShopBuy
- #------------------------------------------------------------------------------
- # 商店画面、浏览显示可以购买的商品的窗口。
- #==============================================================================
- # 公开背包武器防具
- class Game_Party
- attr_accessor :weapons
- attr_accessor :armors
- end
- class Window_ShopBuy < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # shop_goods : 商品
- #--------------------------------------------------------------------------
- def initialize(shop_goods)
- super(0, 128, 368, 352)
- @shop_goods = shop_goods
- refresh
- self.index = 0
- end
-
- # 刷新背包持有数
- def reset_wea_arm_number
- @wea_arm_number = 0
- $game_party.weapons.each_value{|value| @wea_arm_number += value}
- $game_party.armors.each_value{|value| @wea_arm_number += value}
- end
- # 不可购买的场合
- def cant_buy(item)
- return (item == nil || item.price > $game_party.gold) if item.is_a?(RPG::Item)
- return (item == nil || item.price > $game_party.gold || @wea_arm_number >= 60) if (item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor))
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- reset_wea_arm_number
- @data = []
- for goods_item in @shop_goods
- case goods_item[0]
- when 0
- item = $data_items[goods_item[1]]
- when 1
- item = $data_weapons[goods_item[1]]
- when 2
- item = $data_armors[goods_item[1]]
- end
- if item != nil
- @data.push(item)
- end
- end
- # 如果项目数不是 0 就生成位图、描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- # 获取物品所持数
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- # 价格在所持金以下、并且所持数不是 99 的情况下为普通颜色
- # 除此之外的情况设置为无效文字色
- if item.price <= $game_party.gold and number < 99
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
-
- if item.price <= $game_party.gold && @wea_arm_number < 60
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
-
- when RPG::Armor
- number = $game_party.armor_number(item.id)
-
- if item.price <= $game_party.gold && @wea_arm_number < 60
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- end
- 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 == disabled_color ? 128 : 255
- 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, 88, 32, item.price.to_s, 2)
- end
-
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
复制代码 然后到【Scene_Shop】里面的【update_buy】方法里面,
把按下C键的场合的第一个不能购买的分歧条件改成:- if @buy_window.cant_buy(@item)
复制代码 大概就可以了。 |
评分
-
查看全部评分
|