#============================================================================== # ■ Window_RingCommand #------------------------------------------------------------------------------ #  リングコマンドのウィンドウです。 #============================================================================== class Window_RingCommand < Window_Base #-------------------------------------------------------------------------- # ○ カスタマイズポイントだッ! # アイコン名に別名をつけ、それによってアイコンを呼び出す事を可能に。 # "別名" => "アイコン名" と使いましょうね。 #-------------------------------------------------------------------------- COMMAND_ALIAS = {"攻撃" => "001-Weapon01", "スキル" => "044-Skill01", "防御" => "009-Shield01", "アイテム" => "021-Potion01"} #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :index # カーソル位置 attr_reader :help_window # ヘルプウィンドウ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : 中心の X 座標 # y : 中心の Y 座標 # hankei : コマンドの半径 # commands : コマンド文字列の配列 #-------------------------------------------------------------------------- def initialize(x, y, hankei, *commands) # まあ色々と初期化 @sprites = [] @commands = commands @hankei = hankei super(x, y, 56, 56) # スプライトの作成 for i in 0...@commands.size add_command(@commands[i], i) end self.contents = Bitmap.new(width - 32, height - 32) self.cursor_rect.set(0, 0, 24, 24) self.opacity = 0 # 普段は6フレーム移動ね。 if Input.const_defined?("REPERT_TIME") @time = Input::REPERT_TIME else @time = 6 end # 1フレーム辺りの移動角度を計算 @one_angle = 360 / @time / @commands.size @index = 0 @angle = 0 @mode = 0 end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose @sprites.each{|s| s.dispose} super end #-------------------------------------------------------------------------- # ● コマンド追加 #-------------------------------------------------------------------------- def add_command(name, index = 0) s = Sprite.new if COMMAND_ALIAS.include?(name) c = COMMAND_ALIAS[name] else c = name end s.bitmap = RPG::Cache.icon(c) s.ox = 12 s.oy = 12 s.z = 100 @sprites.insert(index, s) end #-------------------------------------------------------------------------- # ● カーソル位置の設定 # index : 新しいカーソル位置 #-------------------------------------------------------------------------- def index=(index) @index = index # ヘルプテキストを更新 (update_help は継承先で定義される) if self.active and @help_window != nil update_help end end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの設定 # help_window : 新しいヘルプウィンドウ #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window # ヘルプテキストを更新 (update_help は継承先で定義される) if self.active and @help_window != nil update_help end end #-------------------------------------------------------------------------- # ● X 座標の設定 #-------------------------------------------------------------------------- def x=(value) super(value - 28) @x = value end #-------------------------------------------------------------------------- # ● Y 座標の設定 #-------------------------------------------------------------------------- def y=(value) super(value - @hankei - 28) @y = value end #-------------------------------------------------------------------------- # ● 表示状態の変更 #-------------------------------------------------------------------------- def visible=(value) super(value) @sprites.each{|s| s.visible = value} end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # 移動中でない場合 if @angle % (360 / @commands.size) == 0 @angle %= 360 if Input.const_defined?("REPERT_TIME") @index = @angle / @one_angle / Input::REPERT_TIME else @index = @angle / @one_angle / 6 end if Input.press?(Input::LEFT) # リングを左回転 $game_system.se_play($data_system.cursor_se) @angle += @one_angle @mode = 1 elsif Input.press?(Input::RIGHT) # リングを右回転 $game_system.se_play($data_system.cursor_se) @angle -= @one_angle @mode = 2 else @mode = 0 end else # 移動中は移動に徹する case @mode when 1 @angle += @one_angle when 2 @angle -= @one_angle end end # アイコンの位置を計算 for s in @sprites angle = (720 - @angle - @sprites.index(s) * 360 / @commands.size) % 360 * Math::PI / 180 s.x = @x - @hankei * Math.sin(angle) s.y = @y - @hankei * Math.cos(angle) end # ヘルプテキストを更新 (update_help は継承先で定義される) if self.active and @help_window != nil update_help end end end # ここから先の(=begin)と(=end)を除くと、デフォルトの戦闘コマンドがリングです。 =begin def main # 戦闘用の各種一時データを初期化 $game_temp.in_battle = true $game_temp.battle_turn = 0 $game_temp.battle_event_flags.clear $game_temp.battle_abort = false $game_temp.battle_main_phase = false $game_temp.battleback_name = $game_map.battleback_name $game_temp.forcing_battler = nil # バトルイベント用インタプリタを初期化 $game_system.battle_interpreter.setup(nil, 0) # トループを準備 @troop_id = $game_temp.battle_troop_id $game_troop.setup(@troop_id) # アクターコマンドウィンドウを作成 s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item @actor_command_window = Window_RingCommand.new(320, 0, 64, s1, s2, s3, s4) @actor_command_window.y = 160 @actor_command_window.back_opacity = 160 @actor_command_window.active = false @actor_command_window.visible = false # その他のウィンドウを作成 @party_command_window = Window_PartyCommand.new @help_window = Window_Help.new @help_window.back_opacity = 160 @help_window.visible = false @status_window = Window_BattleStatus.new @message_window = Window_Message.new # スプライトセットを作成 @spriteset = Spriteset_Battle.new # ウェイトカウントを初期化 @wait_count = 0 # トランジション実行 if $data_system.battle_transition == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition) end # プレバトルフェーズ開始 start_phase1 # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # マップをリフレッシュ $game_map.refresh # トランジション準備 Graphics.freeze # ウィンドウを解放 @actor_command_window.dispose @party_command_window.dispose @help_window.dispose @status_window.dispose @message_window.dispose if @skill_window != nil @skill_window.dispose end if @item_window != nil @item_window.dispose end if @result_window != nil @result_window.dispose end # スプライトセットを解放 @spriteset.dispose # タイトル画面に切り替え中の場合 if $scene.is_a?(Scene_Title) # 画面をフェードアウト Graphics.transition Graphics.freeze end # 戦闘テストからゲームオーバー画面以外に切り替え中の場合 if $BTEST and not $scene.is_a?(Scene_Gameover) $scene = nil end end class Scene_Battle def phase3_setup_command_window # パーティコマンドウィンドウを無効化 @party_command_window.active = false @party_command_window.visible = false # アクターコマンドウィンドウを有効化 @actor_command_window.active = true @actor_command_window.visible = true # アクターコマンドウィンドウの位置を設定 @actor_command_window.x = @actor_index * 160 + 80 # インデックスを 0 に設定 @actor_command_window.index = 0 end end =end