class Window_EquipRight < Window_Selectable
def initialize(actor)
super(0, 64, 640, 280)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
@ax=0
@ay=20
@bx=310
@by=100
@cx=0
@cy=70
@dx=280
@dy=0
@fx=60
@fy= 150
refresh
self.index = 1
end
def item
return @data[self.index]
end
def refresh
self.contents.clear
self.contents.fill_rect(370,180,260,4,crisis_color )
self.contents.fill_rect(370,245,260,4,crisis_color )
self.contents.fill_rect(370,180,4,80,crisis_color)
self.contents.fill_rect(605,180,4,80,crisis_color)
self.contents.fill_rect(500,0,260,4,crisis_color)
self.contents.fill_rect(500,45,260,4,crisis_color)
self.contents.fill_rect(500,0,4,45,crisis_color)
self.contents.fill_rect(605,0,4,45,crisis_color)
draw_actor_name(@actor, 520, 0)
draw_actor_level(@actor, 520, 20)
draw_actor_parameter(@actor, 380, 180, 0)
draw_actor_parameter(@actor, 380, 200, 1)
draw_actor_parameter(@actor, 380, 220, 2)
if @new_atk != nil
self.contents.font.color = system_color
self.contents.draw_text(530, 180, 40, 32, "→", 1)
self.contents.font.color = normal_color
self.contents.draw_text(570, 180, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = system_color
self.contents.draw_text(530, 200, 40, 32, "→", 1)
self.contents.font.color = normal_color
self.contents.draw_text(570, 200, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
self.contents.font.color = system_color
self.contents.draw_text(530, 220, 40, 32, "→", 1)
self.contents.font.color = normal_color
self.contents.draw_text(570, 220, 36, 32, @new_mdef.to_s, 2)
end
#--------------------------------------------------------------------------
@battler = Sprite.new
@battler.bitmap = RPG::Cache.battler(@actor.battler_name, @actor.battler_hue)
@cw = @battler.bitmap.width / 2
@ch = @battler.bitmap.height / 2
@ccc = @ch / 85.0
@aaa = @ccc * 0.1
if @ch >= 86
@zoom_xy = 1/@ccc
else
@zoom_xy = 1.5
end
if @cw >= 110
@ccc = @cw / 110.0
@aaa = @ccc * 0.1
@zoom_xy = 1/@ccc
end
@battler.zoom_x = @zoom_xy
@battler.zoom_y = @zoom_xy
@battler.x = 240 - (@cw*@zoom_xy)
@battler.y = 200- (@ch*@zoom_xy)
@battler.z = 100
#--------------------------------------------------------------------------
@data = []
@data.push($data_weapons[@actor.weapon_id])
@data.push($data_armors[@actor.armor1_id])
@data.push($data_armors[@actor.armor2_id])
@data.push($data_armors[@actor.armor3_id])
@data.push($data_armors[@actor.armor4_id])
@item_max = @data.size
self.contents.font.color = system_color
draw_item_name(@data[0], @ax, @ay)
draw_item_name(@data[1], @bx, @by)
draw_item_name(@data[2], @dx, @dy)
draw_item_name(@data[3], @cx, @cy)
draw_item_name(@data[4], @fx, @fy)
#--------------------------------------------------------------------------
end
def dispose
super
@battler.bitmap.dispose
@battler.dispose
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
refresh
end
end
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
#------------------------------
def update_cursor_rect
if @index < 1
self.cursor_rect.set(0, 20, 155, 35)
else
if @index < 2
self.cursor_rect.set(310, 100, 155, 35)
else
if @index < 3
self.cursor_rect.set(280, 0, 155, 35)
else
if @index < 4
self.cursor_rect.set(0, 70, 155, 35)
else
self.cursor_rect.set(50, 150, 155, 35)
end
end
end
end
end
#-----------------
end
class Window_EquipItem < Window_Selectable
def initialize(actor, equip_type)
super(0, 345, 640, 135)
@actor = actor
@equip_type = equip_type
@column_max = 2
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 装備可能な武器を追加
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
# 装備可能な防具を追加
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
# 空白を追加
@data.push(nil)
# ビットマップを作成し、全項目を描
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max-1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
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
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#_________________________________________________ ________________
class Scene_Equip
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
@equip_index = equip_index
end
def main
@actor = $game_party.actors[@actor_index]
@help_window = Window_Help.new
@right_window = Window_EquipRight.new(@actor)
@item_window1 = Window_EquipItem.new(@actor, 0)
@item_window2 = Window_EquipItem.new(@actor, 1)
@item_window3 = Window_EquipItem.new(@actor, 2)
@item_window4 = Window_EquipItem.new(@actor, 3)
@item_window5 = Window_EquipItem.new(@actor, 4)
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
@right_window.index = @equip_index
refresh
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@help_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
end
def refresh
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
item1 = @right_window.item
case @right_window.index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
if @right_window.active
@right_window.set_new_parameters(nil, nil, nil)
end
if @item_window.active
item2 = @item_window.item
last_hp = @actor.hp
last_sp = @actor.sp
@actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
@actor.hp = last_hp
@actor.sp = last_sp
@right_window.set_new_parameters(new_atk, new_pdef, new_mdef)
end
end
def update
@right_window.update
@item_window.update
refresh
if @right_window.active
update_right
return
end
if @item_window.active
update_item
return
end
end
def update_right
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(2)
return
end
if Input.trigger?(Input::C)
if @actor.equip_fix?(@right_window.index)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
if Input.trigger?(Input::R)
$game_system.se_play($data_system.cursor_se)
@actor_index += 1
@actor_index %= $game_party.actors.size
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
if Input.trigger?(Input::L)
$game_system.se_play($data_system.cursor_se)
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
end
def update_item
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.equip_se)
item = @item_window.item
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
@right_window.active = true
@item_window.active = false
@item_window.index = -1
@right_window.refresh
@item_window.refresh
return
end
end
end
Социальные закладки