Project1
标题:
关于物品描绘的问题。。
[打印本页]
作者:
夏萝酱
时间:
2010-10-10 14:06
提示:
作者被禁止或删除 内容自动屏蔽
作者:
禾西
时间:
2010-10-10 14:54
本帖最后由 禾西 于 2010-10-11 02:54 编辑
沒測試
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
class Game_Party
#--------------------------------------------------------------------------
# ● 增加物品
#--------------------------------------------------------------------------
def gain_item(item_id, n)
if item_id > 0
@items[item_id] = [item_number(item_id) + n, 0].max
end
end
#--------------------------------------------------------------------------
# ● 增加武器
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
if weapon_id > 0
@weapons[weapon_id] = [weapon_number(weapon_id) + n, 0].max
end
end
#--------------------------------------------------------------------------
# ● 增加防具
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
if armor_id > 0
@armors[armor_id] = [armor_number(armor_id) + n, 0].max
end
end
end
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
#---------------------------------------------
# 添加报务
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
( ( $game_party.item_number(i) - 1 ) /99 + 1).times do
@data.push($data_items[i])
end
end
end
# 在战斗中以外添加武器、防具
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
( ( $game_party.weapon_number(i) - 1 ) /99 + 1).times do
@data.push($data_weapons[i])
end
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
( ( $game_party.armor_number(i) - 1 ) /99 + 1).times do
@data.push($data_armors[i])
end
end
end
end
#---------------------------------------------
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
@last_item = []
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)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
#---------------------------------------------
if number > 99
if @last_item[0] != index
@last_item = [index, number]
end
@last_item[1] -= 99
number = [ 99, @last_item[1] ].min
end
#---------------------------------------------
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 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
复制代码
作者:
夏萝酱
时间:
2010-10-10 22:39
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1