#============================================================================== # ■ Window_BtArrowHelp #============================================================================== class Window_BtArrowHelp < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, Graphics.width, fitting_height(1)) self.openness = 0 end #-------------------------------------------------------------------------- # ● バトラー設定 #-------------------------------------------------------------------------- def set_battler(battler, height) if battler != @battler [url=home.php?mod=space&uid=133701]@battler[/url] = battler w = contents.text_size(@battler.name).width self.width = w + standard_padding * 2 create_contents refresh update_position(height) self.openness = 0 open end end #-------------------------------------------------------------------------- # ● 表示位置 #-------------------------------------------------------------------------- def update_position(height) if @battler.actor?#角色帮助窗口坐标 xx = [0, @battler.sv.x / 100 - self.width / 2 - 44].max #~~ yy = [0, @battler.sv.y / 100 - height - 60].max #~~ else#敌人帮助窗口坐标 xx = [0, @battler.screen_x - self.width / 2 -20].max #~~ yy = [0, @battler.screen_y - height - 60].max #~~ end self.x = [xx, Graphics.width - self.width ].min self.y = [yy, Graphics.height - self.height].min end #-------------------------------------------------------------------------- # ● クリア #-------------------------------------------------------------------------- def clear contents.clear @battler = nil self end #-------------------------------------------------------------------------- # ● リフレッシュ(バトラーステータス) #-------------------------------------------------------------------------- def refresh contents.clear draw_text(0, 0, contents.width, line_height, @battler.name, 1) #~ draw_battler_states end #-------------------------------------------------------------------------- # ● ステート描画 #-------------------------------------------------------------------------- def draw_battler_states w = contents.text_size(@battler.name).width + 4 draw_actor_icons(@battler, w, 0) end end
#============================================================================== # ■ BtArrow_Base #============================================================================== class BtArrow_Base < Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :active attr_reader :index #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(viewport=nil) @count = 0 @index = -1 @handler = {} @cursor_fix = false @cursor_all = false super(viewport) self.bitmap = Cache.system(arrow_file) self.ox = arrow_width / 2 self.src_rect = Rect.new(0, 0, arrow_width, bitmap.height) deactivate.hide end #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max return 1 end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max return 0 end #-------------------------------------------------------------------------- # ● アロー画像分割数 #-------------------------------------------------------------------------- def arrow_col return 4 end #-------------------------------------------------------------------------- # ● アロー画像幅 #-------------------------------------------------------------------------- def arrow_width bitmap.width / arrow_col end #-------------------------------------------------------------------------- # ● アロー画像 #-------------------------------------------------------------------------- def arrow_file return "Arrow" end #-------------------------------------------------------------------------- # ● アローの表示 #-------------------------------------------------------------------------- def show self.visible = true self end #-------------------------------------------------------------------------- # ● アローの非表示 #-------------------------------------------------------------------------- def hide self.visible = false self end #-------------------------------------------------------------------------- # ● ウィンドウのアクティブ化 #-------------------------------------------------------------------------- def activate self.active = true self end #-------------------------------------------------------------------------- # ● ウィンドウの非アクティブ化 #-------------------------------------------------------------------------- def deactivate self.active = false self end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update return unless self.visible super update_cursor process_cursor_move process_handling end #-------------------------------------------------------------------------- # ● フレーム更新 : アロー更新 #-------------------------------------------------------------------------- def update_cursor @count = (@count + 1) % arrow_round if (@count % arrow_mtn) == 0 x = (@count / arrow_mtn) * arrow_width self.src_rect = Rect.new(x, 0, arrow_width, bitmap.height) end end #-------------------------------------------------------------------------- # ● アローアニメーションの更新間隔 #-------------------------------------------------------------------------- def arrow_mtn return 4 end #-------------------------------------------------------------------------- # ● アローアニメーション #-------------------------------------------------------------------------- def arrow_round arrow_col * arrow_mtn end #-------------------------------------------------------------------------- # ● アクティブ状態の変更 #-------------------------------------------------------------------------- def active=(active) @active = active update_cursor call_update_help end #-------------------------------------------------------------------------- # ● カーソル位置の設定 #-------------------------------------------------------------------------- def index=(index) @index = index update_cursor call_update_help end #-------------------------------------------------------------------------- # ● 項目の選択 #-------------------------------------------------------------------------- def select(index) self.index = index if index end #-------------------------------------------------------------------------- # ● 項目の選択解除 #-------------------------------------------------------------------------- def unselect self.index = -1 end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの設定 #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window call_update_help end #-------------------------------------------------------------------------- # ● ヘルプウィンドウ更新メソッドの呼び出し #-------------------------------------------------------------------------- def call_update_help update_help if active && @help_window end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの更新 #-------------------------------------------------------------------------- def update_help @help_window.clear end #-------------------------------------------------------------------------- # ● 選択項目の有効状態を取得 #-------------------------------------------------------------------------- def current_item_enabled? return true end #-------------------------------------------------------------------------- # ● 動作に対応するハンドラの設定 # method : ハンドラとして設定するメソッド (Method オブジェクト) #-------------------------------------------------------------------------- def set_handler(symbol, method) @handler[symbol] = method end #-------------------------------------------------------------------------- # ● ハンドラの存在確認 #-------------------------------------------------------------------------- def handle?(symbol) @handler.include?(symbol) end #-------------------------------------------------------------------------- # ● ハンドラの呼び出し #-------------------------------------------------------------------------- def call_handler(symbol) @handler[symbol].call if handle?(symbol) end #-------------------------------------------------------------------------- # ● カーソルを下に移動 #-------------------------------------------------------------------------- def cursor_down(wrap = false) if index < item_max - col_max || (wrap && col_max == 1) select((index + col_max) % item_max) end end #-------------------------------------------------------------------------- # ● カーソルを上に移動 #-------------------------------------------------------------------------- def cursor_up(wrap = false) if index >= col_max || (wrap && col_max == 1) select((index - col_max + item_max) % item_max) end end #-------------------------------------------------------------------------- # ● カーソルを右に移動 #-------------------------------------------------------------------------- def cursor_right(wrap = false) if col_max >= 2 && (index < item_max - 1 || wrap) select((index + 1) % item_max) end end #-------------------------------------------------------------------------- # ● カーソルを左に移動 #-------------------------------------------------------------------------- def cursor_left(wrap = false) if col_max >= 2 && (index > 0 || wrap) select((index - 1 + item_max) % item_max) end end #-------------------------------------------------------------------------- # ● カーソルの移動処理 #-------------------------------------------------------------------------- def process_cursor_move last_index = @index cursor_right (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN) cursor_left (Input.trigger?(:UP)) if Input.repeat?(:UP) cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT) cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT) Sound.play_cursor if @index != last_index end #-------------------------------------------------------------------------- # ● 決定やキャンセルなどのハンドリング処理 #-------------------------------------------------------------------------- def process_handling return unless active return process_ok if ok_enabled? && Input.trigger?(:C) return process_cancel if cancel_enabled? && Input.trigger?(:B) return process_pagedown if handle?(:pagedown) && Input.trigger?(:R) return process_pageup if handle?(:pageup) && Input.trigger?(:L) end #-------------------------------------------------------------------------- # ● 決定処理の有効状態を取得 #-------------------------------------------------------------------------- def ok_enabled? handle?(:ok) end #-------------------------------------------------------------------------- # ● キャンセル処理の有効状態を取得 #-------------------------------------------------------------------------- def cancel_enabled? handle?(:cancel) end #-------------------------------------------------------------------------- # ● 決定ボタンが押されたときの処理 #-------------------------------------------------------------------------- def process_ok if current_item_enabled? Sound.play_ok Input.update deactivate call_ok_handler else Sound.play_buzzer end end #-------------------------------------------------------------------------- # ● 決定ハンドラの呼び出し #-------------------------------------------------------------------------- def call_ok_handler call_handler(:ok) end #-------------------------------------------------------------------------- # ● キャンセルボタンが押されたときの処理 #-------------------------------------------------------------------------- def process_cancel Sound.play_cancel Input.update deactivate call_cancel_handler end #-------------------------------------------------------------------------- # ● キャンセルハンドラの呼び出し #-------------------------------------------------------------------------- def call_cancel_handler call_handler(:cancel) end end #============================================================================== # ■ BtArrow_Actor #============================================================================== class BtArrow_Actor < BtArrow_Base #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max item_max end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max $game_party.battle_members.size end #-------------------------------------------------------------------------- # ● アクターオブジェクト取得 #-------------------------------------------------------------------------- def actor $game_party.battle_members[@index] end #-------------------------------------------------------------------------- # ● フレーム更新 : アロー更新 #-------------------------------------------------------------------------- def update_cursor super self.x = actor.sv.x / 100 - 44 #~~ self.y = actor.sv.y / 100 - actor.sv.ch #~~ end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの更新 #-------------------------------------------------------------------------- def update_help @help_window.set_battler(actor,actor.sv.ch) end end #============================================================================== # ■ BtArrow_Enemy #============================================================================== class BtArrow_Enemy < BtArrow_Base #-------------------------------------------------------------------------- # ● 桁数の取得 #-------------------------------------------------------------------------- def col_max item_max end #-------------------------------------------------------------------------- # ● 項目数の取得 #-------------------------------------------------------------------------- def item_max $game_troop.alive_members.size end #-------------------------------------------------------------------------- # ● エネミーオブジェクト取得 #-------------------------------------------------------------------------- def enemy $game_troop.alive_members[@index] end #-------------------------------------------------------------------------- # ● バトラーの高さ #-------------------------------------------------------------------------- def battler Cache.battler(enemy.battler_name, enemy.battler_hue) end #-------------------------------------------------------------------------- # ● フレーム更新 : アロー更新 #-------------------------------------------------------------------------- def update_cursor super self.x = enemy.screen_x - 20 #~~ self.y = enemy.screen_y - battler.height #~~ end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの更新 #-------------------------------------------------------------------------- def update_help @help_window.set_battler(enemy, battler.height) end end
#============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 更新全部窗口 #-------------------------------------------------------------------------- def update_all_windows super @actor_window.update @enemy_window.update end #-------------------------------------------------------------------------- # ● 生成帮助窗口 #-------------------------------------------------------------------------- def create_help_window @help_window = Window_Help.new @help_window.visible = false @arrow_help_window = Window_BtArrowHelp.new end #-------------------------------------------------------------------------- # ● 生成角色窗口 #-------------------------------------------------------------------------- def create_actor_window @actor_window = BtArrow_Actor.new @actor_window.set_handler(:ok, method(:on_actor_ok)) @actor_window.set_handler(:cancel, method(:on_actor_cancel)) end #-------------------------------------------------------------------------- # ● 生成敌人窗口 #-------------------------------------------------------------------------- def create_enemy_window @enemy_window = BtArrow_Enemy.new @enemy_window.set_handler(:ok, method(:on_enemy_ok)) @enemy_window.set_handler(:cancel, method(:on_enemy_cancel)) end #-------------------------------------------------------------------------- # ● 角色选择开始 #-------------------------------------------------------------------------- def select_actor_selection @actor_window.index = 0 @actor_window.help_window = @arrow_help_window @actor_window.show.activate end #-------------------------------------------------------------------------- # ● 角色“确定” #-------------------------------------------------------------------------- alias on_actor_ok_origi on_actor_ok def on_actor_ok @arrow_help_window.clear.close on_actor_ok_origi end #-------------------------------------------------------------------------- # ● 角色“取消” #-------------------------------------------------------------------------- def on_actor_cancel @actor_window.hide @arrow_help_window.clear.close case @actor_command_window.current_symbol when :skill @skill_window.show.activate when :item @item_window.show.activate end end #-------------------------------------------------------------------------- # ● 开始选择敌人 #-------------------------------------------------------------------------- def select_enemy_selection @enemy_window.index = 0 @enemy_window.help_window = @arrow_help_window @enemy_window.show.activate end #-------------------------------------------------------------------------- # ● 敌人“确定” #-------------------------------------------------------------------------- alias on_enemy_ok_origi on_enemy_ok def on_enemy_ok @arrow_help_window.clear.close on_enemy_ok_origi end #-------------------------------------------------------------------------- # ● 敌人“取消” #-------------------------------------------------------------------------- def on_enemy_cancel @enemy_window.hide @arrow_help_window.clear.close case @actor_command_window.current_symbol when :attack @actor_command_window.open.activate when :skill @skill_window.show.activate when :item @item_window.show.activate end end #-------------------------------------------------------------------------- # ● 技能“确定” #-------------------------------------------------------------------------- alias on_skill_ok_origi on_skill_ok def on_skill_ok @skill_window.hide on_skill_ok_origi end #-------------------------------------------------------------------------- # ● 物品“确定” #-------------------------------------------------------------------------- alias on_item_ok_origi on_item_ok def on_item_ok @item_window.hide on_item_ok_origi end end
QQ截图20141123120058.png (278.37 KB, 下载次数: 20)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |