#============================================================================= # #【Cange_Equip】LAST UPDATA 2010/12/14 # # 【機能】 # 装備画面の配置変更。 # # 【使用法】 # 『▼ 素材』より下に差し込むだけです。 # #============================================================================= module Vocab # ステータス画面 ExpTotal = "EXP" ExpNext = "NEXT" end #============================================================================== # ■ Window_EquipItem #------------------------------------------------------------------------------ #  装備画面で、装備変更の候補となるアイテムの一覧を表示するウィンドウです。 #============================================================================== class Window_Item < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # width : ウィンドウの幅 # height : ウィンドウの高さ #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) if $scene.is_a?(Scene_Equip) @column_max = 1 self.width = 240 else @column_max = 2 end self.index = 0 refresh end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) item = @data[index] if item != nil number = $game_party.item_number(item) enabled = enable?(item) rect.width -= 4 draw_item_name(item, rect.x, rect.y, enabled) self.contents.draw_text(rect, sprintf(":%2d", number), 2) end end end class Window_EquipItem < Window_Item #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # width : ウィンドウの幅 # height : ウィンドウの高さ # actor : アクター # equip_type : 装備部位 (0〜4) #-------------------------------------------------------------------------- def initialize(x, y, width, height, actor, equip_type) @actor = actor if equip_type == 1 and actor.two_swords_style # 二刀流なら equip_type = 0 # 盾を武器に変更 end @equip_type = equip_type super(x, y, width, height) end #-------------------------------------------------------------------------- # ● アイテムをリストに含めるかどうか # item : アイテム #-------------------------------------------------------------------------- def include?(item) return true if item == nil if @equip_type == 0 return false unless item.is_a?(RPG::Weapon) else return false unless item.is_a?(RPG::Armor) return false unless item.kind == @equip_type - 1 end return @actor.equippable?(item) end #-------------------------------------------------------------------------- # ● アイテムを許可状態で表示するかどうか # item : アイテム #-------------------------------------------------------------------------- def enable?(item) return true end end #============================================================================== # ■ Window_Status #------------------------------------------------------------------------------ #  ステータス画面で表示する、フル仕様のステータスウィンドウです。 #============================================================================== class Window_Acst < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor : アクター #-------------------------------------------------------------------------- def initialize(actor) super(240, 56, 304, 208) @actor = actor refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear draw_actor_name(@actor, 4, 0) draw_actor_class(@actor, 128, 0) draw_actor_face(@actor, 8, 32) draw_basic_info(128, 32) draw_exp_info(4, 132) end #-------------------------------------------------------------------------- # ● 基本情報の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_basic_info(x, y) draw_actor_level(@actor, x, y + WLH * 0) draw_actor_state(@actor, x, y + WLH * 1) draw_actor_hp(@actor, x, y + WLH * 2) draw_actor_mp(@actor, x, y + WLH * 3) end #-------------------------------------------------------------------------- # ● 経験値情報の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_exp_info(x, y) s1 = @actor.exp_s s2 = @actor.next_rest_exp_s s_next = sprintf(Vocab::ExpNext, Vocab::level) self.contents.font.color = system_color self.contents.draw_text(x, y + WLH * 0, 180, WLH, Vocab::ExpTotal) self.contents.draw_text(x, y + WLH * 1, 180, WLH, s_next) self.contents.font.color = normal_color self.contents.draw_text(x, y + WLH * 0, 180, WLH, s1, 2) self.contents.draw_text(x, y + WLH * 1, 180, WLH, s2, 2) end end #============================================================================== # ■ Window_Equip #------------------------------------------------------------------------------ #  装備画面で、アクターが現在装備しているアイテムを表示するウィンドウです。 #============================================================================== class Window_Equip < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # actor : アクター #-------------------------------------------------------------------------- def initialize(x, y, actor) super(240, 264, 304, WLH * 5 + 32) @actor = actor refresh self.index = 0 end #-------------------------------------------------------------------------- # ● アイテムの取得 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear @data = [] for item in @actor.equips do @data.push(item) end @item_max = @data.size self.contents.font.color = system_color if @actor.two_swords_style self.contents.draw_text(4, WLH * 0, 92, WLH, Vocab::weapon1) self.contents.draw_text(4, WLH * 1, 92, WLH, Vocab::weapon2) else self.contents.draw_text(4, WLH * 0, 92, WLH, Vocab::weapon) self.contents.draw_text(4, WLH * 1, 92, WLH, Vocab::armor1) end self.contents.draw_text(4, WLH * 2, 92, WLH, Vocab::armor2) self.contents.draw_text(4, WLH * 3, 92, WLH, Vocab::armor3) self.contents.draw_text(4, WLH * 4, 92, WLH, Vocab::armor4) draw_item_name(@data[0], 92, WLH * 0) draw_item_name(@data[1], 92, WLH * 1) draw_item_name(@data[2], 92, WLH * 2) draw_item_name(@data[3], 92, WLH * 3) draw_item_name(@data[4], 92, WLH * 4) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(item == nil ? "" : item.description) end end #============================================================================== # ■ Window_EquipStatus #------------------------------------------------------------------------------ #  装備画面で、アクターの能力値変化を表示するウィンドウです。 #============================================================================== class Window_EquipStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 # actor : アクター #-------------------------------------------------------------------------- def initialize(x, y, actor) super(x, y, 240, WLH * 5 + 32) @actor = actor refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.draw_text(4, 0, 100, 24,"能力値") draw_parameter(0, WLH * 1, 0) draw_parameter(0, WLH * 2, 1) draw_parameter(0, WLH * 3, 2) draw_parameter(0, WLH * 4, 3) end #-------------------------------------------------------------------------- # ● 装備変更後の能力値設定 # new_atk : 装備変更後の攻撃力 # new_def : 装備変更後の防御力 # new_spi : 装備変更後の精神力 # new_agi : 装備変更後の敏捷性 #-------------------------------------------------------------------------- def set_new_parameters(new_atk, new_def, new_spi, new_agi) if @new_atk != new_atk or @new_def != new_def or @new_spi != new_spi or @new_agi != new_agi @new_atk = new_atk @new_def = new_def @new_spi = new_spi @new_agi = new_agi refresh end end #-------------------------------------------------------------------------- # ● 装備変更後の能力値の描画色取得 # old_value : 装備変更前の能力値 # new_value : 装備変更後の能力値 #-------------------------------------------------------------------------- def new_parameter_color(old_value, new_value) if new_value > old_value # 強くなる return power_up_color elsif new_value == old_value # 変わらず return normal_color else # 弱くなる return power_down_color end end #-------------------------------------------------------------------------- # ● 能力値の描画 # x : 描画先 X 座標 # y : 描画先 Y 座標 # type : 能力値の種類 (0〜3) #-------------------------------------------------------------------------- def draw_parameter(x, y, type) case type when 0 name = Vocab::atk value = @actor.atk new_value = @new_atk when 1 name = Vocab::def value = @actor.def new_value = @new_def when 2 name = Vocab::spi value = @actor.spi new_value = @new_spi when 3 name = Vocab::agi value = @actor.agi new_value = @new_agi end self.contents.font.color = system_color self.contents.draw_text(x + 4, y, 80, WLH, name) self.contents.font.color = normal_color self.contents.draw_text(x + 90, y, 30, WLH, value, 2) self.contents.font.color = system_color self.contents.draw_text(x + 122, y, 20, WLH, " →", 1) if new_value != nil self.contents.font.color = new_parameter_color(value, new_value) self.contents.draw_text(x + 142, y, 30, WLH, new_value, 2) end end end #============================================================================== # ■ Scene_Equip #------------------------------------------------------------------------------ #  装備画面の処理を行うクラスです。 #============================================================================== class Scene_Equip < Scene_Base #-------------------------------------------------------------------------- # ● 定数 #-------------------------------------------------------------------------- EQUIP_TYPE_MAX = 5 # 装備部位の数 #-------------------------------------------------------------------------- # ● オブジェクト初期化 # actor_index : アクターインデックス # equip_index : 装備インデックス #-------------------------------------------------------------------------- def initialize(actor_index = 0, equip_index = 0) @actor_index = actor_index @equip_index = equip_index end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_menu_background @actor = $game_party.members[@actor_index] @help_window = Window_Help.new @status_window2 = Window_Acst.new(@actor) create_item_windows @equip_window = Window_Equip.new(208, 56, @actor) @equip_window.help_window = @help_window @equip_window.index = @equip_index @status_window = Window_EquipStatus.new(0, 56, @actor) end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @help_window.dispose @equip_window.dispose @status_window.dispose @status_window2.dispose dispose_item_windows end #-------------------------------------------------------------------------- # ● 元の画面へ戻る #-------------------------------------------------------------------------- def return_scene $scene = Scene_Menu.new(2) end #-------------------------------------------------------------------------- # ● 次のアクターの画面に切り替え #-------------------------------------------------------------------------- def next_actor @actor_index += 1 @actor_index %= $game_party.members.size $scene = Scene_Equip.new(@actor_index, @equip_window.index) end #-------------------------------------------------------------------------- # ● 前のアクターの画面に切り替え #-------------------------------------------------------------------------- def prev_actor @actor_index += $game_party.members.size - 1 @actor_index %= $game_party.members.size $scene = Scene_Equip.new(@actor_index, @equip_window.index) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_menu_background @help_window.update update_equip_window update_status_window update_item_windows if @equip_window.active update_equip_selection elsif @item_window.active update_item_selection end end #-------------------------------------------------------------------------- # ● アイテムウィンドウの作成 #-------------------------------------------------------------------------- def create_item_windows @item_windows = [] for i in 0...EQUIP_TYPE_MAX @item_windows[i] = Window_EquipItem.new(0, 208, 544, 208, @actor, i) @item_windows[i].help_window = @help_window @item_windows[i].visible = (@equip_index == i) @item_windows[i].y = 208 @item_windows[i].height = 208 @item_windows[i].active = false @item_windows[i].index = -1 end end #-------------------------------------------------------------------------- # ● アイテムウィンドウの解放 #-------------------------------------------------------------------------- def dispose_item_windows for window in @item_windows window.dispose end end #-------------------------------------------------------------------------- # ● アイテムウィンドウの更新 #-------------------------------------------------------------------------- def update_item_windows for i in 0...EQUIP_TYPE_MAX @item_windows[i].visible = (@equip_window.index == i) @item_windows[i].update end @item_window = @item_windows[@equip_window.index] end #-------------------------------------------------------------------------- # ● 装備ウィンドウの更新 #-------------------------------------------------------------------------- def update_equip_window @equip_window.update end #-------------------------------------------------------------------------- # ● ステータスウィンドウの更新 #-------------------------------------------------------------------------- def update_status_window if @equip_window.active @status_window.set_new_parameters(nil, nil, nil, nil) elsif @item_window.active temp_actor = @actor.clone temp_actor.change_equip(@equip_window.index, @item_window.item, true) new_atk = temp_actor.atk new_def = temp_actor.def new_spi = temp_actor.spi new_agi = temp_actor.agi @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi) end @status_window.update end #-------------------------------------------------------------------------- # ● 装備部位選択の更新 #-------------------------------------------------------------------------- def update_equip_selection if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::R) Sound.play_cursor next_actor elsif Input.trigger?(Input::L) Sound.play_cursor prev_actor elsif Input.trigger?(Input::C) if @actor.fix_equipment Sound.play_buzzer else Sound.play_decision @equip_window.active = false @item_window.active = true @item_window.index = 0 end end end #-------------------------------------------------------------------------- # ● アイテム選択の更新 #-------------------------------------------------------------------------- def update_item_selection if Input.trigger?(Input::B) Sound.play_cancel @equip_window.active = true @item_window.active = false @item_window.index = -1 elsif Input.trigger?(Input::C) Sound.play_equip @actor.change_equip(@equip_window.index, @item_window.item) @equip_window.active = true @item_window.active = false @item_window.index = -1 @equip_window.refresh for item_window in @item_windows item_window.refresh end end end end