Auteur: Yukihiro matsumoto
#============================================
# ‘ Scene_Shop
#----------------------------------------------
# @VbvζΚΜπs€NXΕ·B
#============================================
class Scene_Shop
#------------------------------------------
# C
#------------------------------------------
def main
# wvEBhEπμ¬
@help_window = Window_Help.new
# R}hEBhEπμ¬
@command_window = Window_ShopCommand.new
# S[hEBhEπμ¬
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 64
# _~[EBhEπμ¬
@dummy_window = Window_Base.new(0, 128, 640, 352)
# wόEBhEπμ¬
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# pEBhEπμ¬
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
# ΒόΝEBhEπμ¬
@number_window = Window_ShopNumber.new
@number_window.active = false
@number_window.visible = false
# Xe[^XEBhEπμ¬
@status_window = Window_ShopStatus.new
@status_window.visible = false
# gWVΐs
Graphics.transition
# C[v
loop do
# Q[ζΚπXV
Graphics.update
# όΝξρπXV
Input.update
# t[XV
update
# ζΚͺΨθΦνΑ½η[vπf
if $scene != self
break
end
end
# gWVυ
Graphics.freeze
# EBhEππϊ
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
end
#------------------------------------------
# t[XV
#------------------------------------------
def update
# EBhEπXV
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
# R}hEBhEͺANeBuΜκ: update_command πΔΤ
if @command_window.active
update_command
return
end
# wόEBhEͺANeBuΜκ: update_buy πΔΤ
if @buy_window.active
update_buy
return
end
# pEBhEͺANeBuΜκ: update_sell πΔΤ
if @sell_window.active
update_sell
return
end
# ΒόΝEBhEͺANeBuΜκ: update_number πΔΤ
if @number_window.active
update_number
return
end
end
#------------------------------------------
# t[XV (R}hEBhEͺANeBuΜκ)
#------------------------------------------
def update_command
# B {^ͺ³κ½κ
if Input.trigger?(Input::B)
# LZ SE πt
$game_system.se_play($data_system.cancel_se)
# }bvζΚΙΨθΦ¦
$scene = Scene_Map.new
return
end
# C {^ͺ³κ½κ
if Input.trigger?(Input::C)
# R}hEBhEΜJ[ΚuΕͺς
case @command_window.index
when 0 # wό·ι
# θ SE πt
$game_system.se_play($data_system.decision_se)
# EBhEΜσΤπwό[hΦ
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 1 # p·ι
# θ SE πt
$game_system.se_play($data_system.decision_se)
# EBhEΜσΤπp[hΦ
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
when 2 # βίι
# θ SE πt
$game_system.se_play($data_system.decision_se)
# }bvζΚΙΨθΦ¦
$scene = Scene_Map.new
end
return
end
end
#------------------------------------------
# t[XV (wόEBhEͺANeBuΜκ)
#------------------------------------------
def update_buy
# Xe[^XEBhEΜACeπέθ
@status_window.item = @buy_window.item
# B {^ͺ³κ½κ
if Input.trigger?(Input::B)
# LZ SE πt
$game_system.se_play($data_system.cancel_se)
# EBhEΜσΤπϊ[hΦ
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
# wveLXgπΑ
@help_window.set_text("")
return
end
# C {^ͺ³κ½κ
if Input.trigger?(Input::C)
# ACeπζΎ
@item = @buy_window.item
# ACeͺ³ψΜκAά½ΝΏiͺΰζθγΜκ
if @item == nil or @item.price > $game_party.gold
# uU[ SE πt
$game_system.se_play($data_system.buzzer_se)
return
end
# ACeΜπζΎ
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
# ·ΕΙ 99 Β΅Δ’ικ
if number == 99
# uU[ SE πt
$game_system.se_play($data_system.buzzer_se)
return
end
# θ SE πt
$game_system.se_play($data_system.decision_se)
# ΕεwόΒΒπvZ
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
# EBhEΜσΤπΒόΝ[hΦ
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
#------------------------------------------
# t[XV (pEBhEͺANeBuΜκ)
#------------------------------------------
def update_sell
# B {^ͺ³κ½κ
if Input.trigger?(Input::B)
# LZ SE πt
$game_system.se_play($data_system.cancel_se)
# EBhEΜσΤπϊ[hΦ
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@status_window.item = nil
# wveLXgπΑ
@help_window.set_text("")
return
end
# C {^ͺ³κ½κ
if Input.trigger?(Input::C)
# ACeπζΎ
@item = @sell_window.item
# Xe[^XEBhEΜACeπέθ
@status_window.item = @item
# ACeͺ³ψΜκAά½ΝΏiͺ 0 (psΒ) Μκ
if @item == nil or @item.price == 0
# uU[ SE πt
$game_system.se_play($data_system.buzzer_se)
return
end
# θ SE πt
$game_system.se_play($data_system.decision_se)
# ACeΜπζΎ
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
# ΕεpΒ = ACeΜ
max = number
# EBhEΜσΤπΒόΝ[hΦ
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
#------------------------------------------
# t[XV (ΒόΝEBhEͺANeBuΜκ)
#------------------------------------------
def update_number
# B {^ͺ³κ½κ
if Input.trigger?(Input::B)
# LZ SE πt
$game_system.se_play($data_system.cancel_se)
# ΒόΝEBhEπρANeBuEsΒΙέθ
@number_window.active = false
@number_window.visible = false
# R}hEBhEΜJ[ΚuΕͺς
case @command_window.index
when 0 # wό·ι
# EBhEΜσΤπwό[hΦ
@buy_window.active = true
@buy_window.visible = true
when 1 # p·ι
# EBhEΜσΤπp[hΦ
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
# C {^ͺ³κ½κ
if Input.trigger?(Input::C)
# Vbv SE πt
$game_system.se_play($data_system.shop_se)
# ΒόΝEBhEπρANeBuEsΒΙέθ
@number_window.active = false
@number_window.visible = false
# R}hEBhEΜJ[ΚuΕͺς
case @command_window.index
when 0 # wό·ι
# wό
$game_party.lose_gold(@number_window.number * @item.price)
case @item
when RPG::Item
$game_party.gain_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.gain_armor(@item.id, @number_window.number)
end
# eEBhEπtbV
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
# EBhEΜσΤπwό[hΦ
@buy_window.active = true
@buy_window.visible = true
when 1 # p·ι
# p
$game_party.gain_gold(@number_window.number * (@item.price / 2))
case @item
when RPG::Item
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.lose_armor(@item.id, @number_window.number)
end
# eEBhEπtbV
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
# EBhEΜσΤπp[hΦ
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
end
end |
|