#============================================================================== # ■ 動くアクター(基本セット) Ver.3.2.0 by Claimh #------------------------------------------------------------------------------ #  ・ウィンドウでアクターを動かすための基本セットです。 #============================================================================== module Move_Actor CORPSE_FILE = [] CORPSE_LU = [] #============================================================================== # カスタマイズSTART #============================================================================== # 歩くスピードの調整 WALK_SPEED = 10 # 回るスピードの調整 TURN_SPEED = 10 # ステートアニメーションの表示をする STATE_ANIME = false # 動作停止時に向きを強制的に下向きにする DIREC_DOWN = true # 戦闘不能時には別画像を表示する CORPSE = true # アクターごとの戦闘不能時の画像ファイル(Graphic/Characters) # 規格としては4×4のファイルを使用する。 # CORPSE_FILE[アクターID] = ["ファイル名", 左から何番目?, 上から何番目?] CORPSE_FILE[1] = ["189-Down01", 1, 1] CORPSE_FILE[2] = ["189-Down01", 2, 3] CORPSE_FILE[7] = ["190-Down02", 1, 4] CORPSE_FILE[8] = ["191-Down03", 2, 2] #============================================================================== # カスタマイズEND #============================================================================== module_function #-------------------------------------------------------------------------- # ● 汎用データチェッカー #-------------------------------------------------------------------------- def get_exe_data(data, actor_id) if data[actor_id].nil? return data[0] else return data[actor_id] end end end class Sprite_MoveActor < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :move_actor # アクター attr_accessor :move_type # 動作タイプ attr_accessor :move_stop # 動作停止フラグ attr_accessor :direction # 歩行向き #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(viewport, actor = nil) super(viewport) @move_actor = actor @move_type = 0 @move_stop = false @move_index = 0 @dead_already = false @stop_already = false @state_animation_id = nil @direction = 2 end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- # ● 初期表示 #-------------------------------------------------------------------------- def setup @move_index = 0 # 停止 if self.move_stop and Move_Actor::DIREC_DOWN @stop_already = true draw_actor_down_direc # 戦闘不能 elsif @move_actor.dead? and Move_Actor::CORPSE @dead_already = true draw_actor_corpse # 通所 else draw_move_actor end end #-------------------------------------------------------------------------- # ● アニメーション実行 #-------------------------------------------------------------------------- def exe_animation(anime_data) # アニメIDの取得 animation_id = Move_Actor.get_exe_data(anime_data, @move_actor.id) # アニメデータの取得 animation = $data_animations[animation_id] # アニメ実行 animation(animation, true) end #-------------------------------------------------------------------------- # ● 明暗実行 #-------------------------------------------------------------------------- def exe_blink(flag) if flag blink_on else blink_off end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # アクターが nil の場合 if @move_actor == nil self.bitmap = nil loop_animation(nil) return end # アニメーション ID が現在のものと異なる場合 if @move_actor.state_animation_id != @state_animation_id and Move_Actor::STATE_ANIME @state_animation_id = @move_actor.state_animation_id loop_animation($data_animations[@state_animation_id]) end # 戦闘不能なら別画面表示 if @move_actor.dead? and Move_Actor::CORPSE # 二重描画はしない unless @dead_already @move_index = 0 draw_actor_corpse @dead_already = true end return end # 動作停止状態か? if self.move_stop # 二重描画はしない unless @stop_already @move_index = 0 @stop_already = true # 停止時は強制下向き表示 if Move_Actor::DIREC_DOWN draw_actor_down_direc end end return else @stop_already = false end # 動作タイプごとの定数 case @move_type when 0 move_refect = Move_Actor::WALK_SPEED when 1 move_refect = Move_Actor::TURN_SPEED else return end # 動作カウント(フレームカウント) @move_index += 1 # アクターの描画 if (@move_index % move_refect) == 0 @move_index = 0 if @move_index == move_refect * 4 draw_move_actor end end #-------------------------------------------------------------------------- # ● アクター表示 #-------------------------------------------------------------------------- def draw_move_actor # ビットマップを取得、設定 @actor_name = @move_actor.character_name @actor_hue = @move_actor.character_hue self.bitmap = RPG::Cache.character(@actor_name, @actor_hue) @width = self.bitmap.width / 4 @height = self.bitmap.height / 4 # 動作変更 case @move_type when 0 # 歩く x_index = @move_index / Move_Actor::WALK_SPEED * @width case @direction when 2 y_index = 0 when 4 y_index = @height when 6 y_index = @height * 2 when 8 y_index = @height * 3 else p "err:向き設定", @direction end when 1 # 回る cc = @move_index / Move_Actor::TURN_SPEED % 4 case cc when 0 y_index = 0 when 1 y_index = @height when 2 y_index = @height * 3 when 3 y_index = @height * 2 end x_index = 0 else p "error:move_type err" end self.src_rect.set(x_index, y_index, @width, @height) self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● アクター表示(下向き) #-------------------------------------------------------------------------- def draw_actor_down_direc # ビットマップを取得、設定 @actor_name = @move_actor.character_name @actor_hue = @move_actor.character_hue self.bitmap = RPG::Cache.character(@actor_name, @actor_hue) @width = self.bitmap.width / 4 @height = self.bitmap.height / 4 # 動作変更 x_index = @move_index / Move_Actor::WALK_SPEED * @width y_index = 0 self.src_rect.set(x_index, y_index, @width, @height) self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● 戦闘不能表示 #-------------------------------------------------------------------------- def draw_actor_corpse # ビットマップを取得、設定 @actor_name = Move_Actor::CORPSE_FILE[@move_actor.id][0] @actor_hue = @move_actor.character_hue self.bitmap = RPG::Cache.character(@actor_name, @actor_hue) @width = self.bitmap.width / 4 @height = self.bitmap.height / 4 x_index = @width * (Move_Actor::CORPSE_FILE[@move_actor.id][1]-1) y_index = @height * (Move_Actor::CORPSE_FILE[@move_actor.id][2]-1) # 転送元の矩形を設定 self.src_rect.set(x_index, y_index, @width, @height) self.ox = @width / 2 self.oy = @height end end