#如果切換畫面就中斷循環
break if $scene != self
end
end
#--------------------------------------------------------------------------
# ● 生成主要窗口
#--------------------------------------------------------------------------
def window_create
end
#--------------------------------------------------------------------------
# ● 刷新畫面
#--------------------------------------------------------------------------
def update
end
#--------------------------------------------------------------------------
# ● 釋放窗口
#--------------------------------------------------------------------------
def window_dispose
end
#--------------------------------------------------------------------------
# ● 背景釋放
#--------------------------------------------------------------------------
def background_dispose
@background.dispose unless @background.nil?
end
end
end
# 如果人物窗口活躍,調用 update_actor
if @actor_window.active
update_actor
return
end
# 如果選項窗口活躍,調用 update_command
if @command_window.active
update_command
return
end
end
#--------------------------------------------------------------------------
# ● 如果人物窗口激活,調用 update_actor
#--------------------------------------------------------------------------
def update_actor
# 按下 B or Esc 键的情况下
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se) # 演奏确定 SE
$scene = Scene_Map.new # 切换回地圖畫面
#->切換到地圖畫面
return
end
# 按下 C or Space 键的情况下
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se) # 演奏确定 SE
@actor_window.active = false # 凍結角色窗口
@actor = @actor_window.index # 記錄當前選擇角色
@command_window.active = true # 活躍選項窗口
@command_window.index = 0 # 修正初始光標位置
#->切換到選項窗口
end
end
#--------------------------------------------------------------------------
# ● 如果選項窗口激活,調用 update_command
#--------------------------------------------------------------------------
def update_command
# 按下 B or Esc 鍵的情况下
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se) # 演奏确定 SE
@actor_window.active = true # 活躍角色窗口
@command_window.active = false # 凍結選項窗口
@command_window.index = -1 # 隱藏光標
#->切換到人物窗口
return
end
# 按下 C or Space 鍵的情况下
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se) # 演奏确定 SE
case @command_window.index
when 0: $scene = Deatwo_Smith_Shop2.new(@actor) # 轉入强化畫面
when 1: $scene = Deatwo_Smith_Shop3.new(@actor) # 轉入裝備畫面
end
end
end
end
#==============================================================================
# ■ Deatwo_Smith_Help
#------------------------------------------------------------------------------
# 描述角色裝備的幫助窗口
#==============================================================================
class Deatwo_Smith_Help < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(300, 150, 640-300, 420-90)
self.z = 120
self.opacity = 190
self.visible = true
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# ● 設置文本
#--------------------------------------------------------------------------
def set_text(data)
@data = data
set_actor_text(@data)
end
#--------------------------------------------------------------------------
# ● 描绘物品名
# item : 物品
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_item_name(item, x, y)
if item == nil
return
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)
end
#--------------------------------------------------------------------------
# ● 描繪全裝備
#
#--------------------------------------------------------------------------
def set_actor_text(actor)
@actor = actor
y=0
self.contents.clear
@data = [$data_weapons[@actor.weapon_id],
$data_armors[@actor.armor1_id],
$data_armors[@actor.armor2_id],
$data_armors[@actor.armor3_id],
$data_armors[@actor.armor4_id]
]
self.contents.font.color = system_color
self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4)
for i in [0,1,2,3,4]
draw_item_name(@data, 92, 32 * i)
end
end
end
#==============================================================================
# ■ Deatwo_Smith_Status
#------------------------------------------------------------------------------
# 顯示角色狀態的窗口。
#==============================================================================
class Deatwo_Smith_Status < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化目標
#--------------------------------------------------------------------------
def initialize
super(0, 0, 300, 480)
@item_max = $game_party.actors.size
self.contents = Bitmap.new(width - 32, height - 32)
self.active = true
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# ● 獲取人物
#--------------------------------------------------------------------------
def actor
return $game_party.actors[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = 64
y = i * 116
actor = $game_party.actors
draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_exp(actor, x, y + 64)
draw_actor_name(actor, x, y)
draw_actor_level(actor, x, y + 32)
draw_actor_class(actor, x + 144, y)
draw_actor_state(actor, x + 90, y + 32)
draw_actor_hp(actor, x + 236, y + 32)
draw_actor_sp(actor, x + 236, y + 64)
end
end
#--------------------------------------------------------------------------
# ● 刷新幫助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(actor)
end
#--------------------------------------------------------------------------
# ● 刷新光標矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#==============================================================================
# ■ Deatwo_Smith_Command
#------------------------------------------------------------------------------
# 選擇行爲的窗口
#==============================================================================
class Deatwo_Smith_Command < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化對象
#--------------------------------------------------------------------------
def initialize
super(300, 0, 340, 150)
@commands = [Vocab::Smith_Strenthen,Vocab::Smith_Dress]
@item_max = 2
@column_max = 2
self.index = -1
self.active = false
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 描繪文字
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(35, 5, 240, 45, @commands[0])
self.contents.draw_text(self.height + 35, 5, 240, 45, @commands[1])
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index * (self.height), 0, (self.width/2-35), (self.height-35))
end
end
end
# 如果强化窗口活躍: 调用 update_upgrade
if @upgrade_window.active
update_upgrade
return
end
# 如果確認窗口活躍:調用 update_confirm
if @confirm_window.active
update_confirm
return
end
end
#--------------------------------------------------------------------------
# ● 如果强化窗口活躍: 调用 update_upgrade
#--------------------------------------------------------------------------
def update_upgrade
# 按下 B or Esc 鍵的情况下
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se) #演奏確認 SE
$scene = Deatwo_Smith_Shop1.new(@actor) #切換到 Step1
#->切換到 Step1 界面
return
end
# 按下 C or Space 鍵的情况下
if Input.trigger?(Input::C)
# 取得需要强化之物品
@item = @upgrade_window.item
# 如果不可强化則中止
unless judgement(@item)
$game_system.se_play($data_system.buzzer_se) #演奏凍結 SE
return
end
$game_system.se_play($data_system.decision_se) #演奏確認 SE
@confirm_window.visible = true #顯示「確認窗口」
@confirm_window.active = true #活躍「確認窗口」
@upgrade_window.active = false #凍結「强化窗口」
#->切換到確認窗口
end
end
#--------------------------------------------------------------------------
# ● 判斷物品是否可以强化
#--------------------------------------------------------------------------
def judgement(item)
# 沒有裝備的情况不能强化
return false if item.nil?
# 達到最高級不能强化
return false if item.lv >= Upgrade::Max_lv
@price = Upgrade::Price # 取得代價資料
# 代價不足不能强化
equipment_kind = 0 if item.is_a?(RPG::Weapon)
equipment_kind = (item.kind + 1) if item.is_a?(RPG::Armor)
lv = 0
lv += (item.lv + 1) if (@price[equipment_kind].size - 1) >= (item.lv + 1)
@items = @price[equipment_kind][lv][0]
@gold = @price[equipment_kind][lv][1]
pass = 0
if @items.nil?
item_enough = true
else
for item_id in @items.keys
pass += 1 if $game_party.item_number(item_id) >= @items[item_id]
end
item_enough = true if pass == @items.size
end
if @gold.nil?
gold_enough = true
else
gold_enough = true if $game_party.gold >= @gold
end
return false unless item_enough
return false unless gold_enough
return true
end
#--------------------------------------------------------------------------
# ● 如果確認窗口活躍:調用 update_confirm
#--------------------------------------------------------------------------
def update_confirm
# 按下 B or Esc 鍵的情况下
if Input.trigger?(Input::B)
$game_system.se_play($data_system.decision_se) #演奏確認 SE
@confirm_window.visible = false #隱藏「確認窗口」
@confirm_window.active = false #凍結「確認窗口」
@upgrade_window.active = true #活躍「强化窗口」
#->切換到强化窗口
return
end
# 按下 C or Space 鍵的情况下
if Input.trigger?(Input::C)
case @confirm_window.index
when 0 # 確認
# 扣除代價
$game_party.lose_gold(@gold) unless @gold.nil?
@items.each{|item_id, num| $game_party.lose_item(item_id, num)} unless @items.nil?
kind = 0 if @item.is_a?(RPG::Weapon)
kind = 1 if @item.is_a?(RPG::Armor)
Upgrade.up_grade(@item.id, kind)
@confirm_window.visible = false
@confirm_window.active = false
@upgrade_window.active = true
# 刷新各窗口
@price_window.non_auto_update
@help_window.non_auto_update
@upgrade_window.refresh(@actor)
@gold_window.refresh
when 1 # 取消
@confirm_window.visible = false
@confirm_window.active = false
@upgrade_window.active = true
return
end
end
end
end