#============================================================================== # ショップレイアウトテンプレート [タイプB-1] ver1.01 (2007/8/25) #   by 水夜 Zenith Creation (http://zenith.ifdef.jp/) #============================================================================== =begin ◆変数の処理:[店員指定用変数] = ○ ◆ショップの処理 という感じで =end module SHOP # ここはそのままにしておいてください PICTURES = [] MESSAGES = [] BACK_PICTURE = {} #============================================================================== # □ カスタマイズポイント #============================================================================== # 店員を指定する変数のID VARIABLE_ID = 1 # 店員画像のフォルダ (1:Pictures , 2:Battlers) PICTURES_FOLDER = 2 # 店員画像 PICTURES[変数の値] = "画像ファイル名" PICTURES[0] = "038-Mage06" PICTURES[1] = "044-Trader01" # # PICTURES[0] = ["画像1", "画像2", "画像3", "画像4", "画像5"] # # のように配列で指定すると、 # # [コマンド時, 品選び中, 個数入力中, 個数入力決定時, 個数入力キャンセル時] で # # 個別の画像を表示することが出来ます。 # (この場合同じ画像でもいいので必ず5つ指定してください) # ピクチャ画像 X 原点 (1:左端 , 2:中央) PICTURE_OX = 2 # ピクチャ画像 Y 原点 (1:上端 , 2:中央) PICTURE_OY = 1 # ピクチャ表示座標 [x, y] PICTURE_POSITION = [470, 200] # 店員のウィンドウとの前後関係 # (0:ウィンドウの後ろ, 1:ウィンドウの前&文字の後ろ, 3:文字の前) PICTURE_Z = 1 # 店員メッセージ MESSAGES[変数の値][状況] = ["1行目", "2行目", "3行目"] # # ※ 最大3行まで(2行目や3行目を省略すると自動的に高さは中央に揃います) #===================================================================== # ※ 「状況」 # 0:コマンド時, 1:購入品選択中, 2:購入個数入力中, 3:購入完了時, # 4:購入個数キャンセル時, 5:売却品選択中, 6:売却個数入力中, # 7:売却完了時, 8:売却個数キャンセル時 #===================================================================== # # ↓ 店員 ID 0 MESSAGES[0] = [] # メッセージ設定の前に必ず左のように記述してください。 MESSAGES[0][0] = ["こんにちは", "道具屋です", "ごゆっくりどうぞ"] MESSAGES[0][1] = ["何買いますか?"] MESSAGES[0][2] = ["何個買いますか?", "いっぱい買ってね"] MESSAGES[0][3] = ["どーもです"] MESSAGES[0][4] = ["あれ、やめるんですか?"] MESSAGES[0][5] = ["買い取りますよ"] MESSAGES[0][6] = ["何個売ってくれますか?"] MESSAGES[0][7] = ["はい、どーも"] MESSAGES[0][8] = ["やっぱり必要ですか"] # # ↓ 店員 ID 1 MESSAGES[1] = [] MESSAGES[1][0] = ["色々あるよ"] # メッセージウィンドウ Y 座標 MESSAGE_Y = 48 # メッセージウィンドウの代わりに自作の吹き出し画像を使う場合は # 下の nil を "画像ファイル名" に書きかえてください ( Picturesフォルダ ) # ※参考:ウィンドウサイズは 272×128 です MESSAGE_PICTURE = nil MESSAGE_OPACITY = 192 # その際のピクチャの不透明度 # メッセージ文字アラインメント(0:左揃え, 1:中央揃え, 2: 右揃え) MESSAGE_ALIGN = 1 # メッセージフォント MESSAGE_FONTNAME = "MS Pゴシック" # フォント名 MESSAGE_FONTSIZE = 20 # フォントサイズ MESSAGE_COLOR = Color.new(255, 255, 255, 255) # フォント色 # 個数入力決定時画像&メッセージの表示時間(0で表示しない) DECIDE_TIME = 20 # フレーム # 個数入力キャンセル時画像&メッセージの表示時間(0で表示しない) CANCEL_TIME = 20 # フレーム # 背景にマップを表示するか BACK_MAP = true # 基本背景画像 (""で使用しない) # ※ Titles フォルダ BACK_PICTURE.default = "001-Title01" # # BACK_PICTURE.default = ["画像1", "画像2", "画像3", "画像4"] # # のように配列で指定すると、 # # [コマンド時, 購入時, 売却時, 個数入力時] で # # 個別の背景画像を表示することが出来ます。 # (この場合同じ画像でもいいので必ず4つ指定してください) # # 店員別背景設定 BACK_PICTURES[変数の値] = "画像ファイル名" # # ※ 設定していない店員には上の「基本背景」が表示されます # ※ 右辺は基本背景と同様に配列指定可能です。 # BACK_PICTURE[0] = "001-Title01" # 背景不透明度 BACK_OPACITY = 192 # ウィンドウ不透明度 WINDOWS_OPACITY = 192 # ゴールドウィンドウの座標 [x, y] GOLD_POSITION = [480, 352] # 能力変化表示タイプ # (1:顔+現在の装備+能力変化 , 2:顔+能力変化) # 2 にすると 1ページあたりの商品の表示数が少し増えます S_WINDOW_TYPE = 2 # 各種文字色 Color.new(R,G,B[,不透明度]) HELP_COLOR = Color.new(255, 255, 255, 255) # ヘルプウィンドウ GOLD_COLOR = Color.new(255, 255, 255, 255) # お金 GOLD_G_COLOR = Color.new(192, 224, 255, 255) # 通貨単位 COMMAND_COLOR = Color.new(255, 255, 255, 255) # コマンドウィンドウ BUY_COLOR = Color.new(255, 255, 255, 255) # 購入ウィンドウ(有効色) BUY_D_COLOR = Color.new(255, 255, 255, 128) # 購入ウィンドウ(無効色) SELL_COLOR = Color.new(255, 255, 255, 255) # 売却ウィンドウ(有効色) SELL_D_COLOR = Color.new(255, 255, 255, 128) # 売却ウィンドウ(無効色) NUMBER_COLOR = Color.new(255, 255, 255, 255) # 個数入力ウィンドウ STATUS_COLOR = Color.new(255, 255, 255, 255) # ステータスウィンドウ(有効色) STATUS_D_COLOR = Color.new(255, 255, 255, 128)# ステータスウィンドウ(無効色) STATUS_S_COLOR = Color.new(192, 224, 255, 255)# ステータスウィンドウ「所持数」 #============================================================================== # □ カスタマイズポイント終了 #============================================================================== end class Window_ShopHelp < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 64) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = SHOP::WINDOWS_OPACITY end #-------------------------------------------------------------------------- # ● テキスト設定 # text : ウィンドウに表示する文字列 # align : アラインメント (0..左揃え、1..中央揃え、2..右揃え) #-------------------------------------------------------------------------- def set_text(text, align = 0) # テキストとアラインメントの少なくとも一方が前回と違っている場合 if text != @text or align != @align # テキストを再描画 self.contents.clear self.contents.font.color = SHOP::HELP_COLOR self.contents.draw_text(4, 0, self.width - 40, 32, text, align) @text = text @align = align @actor = nil end self.visible = true end end class Window_ShopMessage < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(368, SHOP::MESSAGE_Y, 272, 128) if SHOP::MESSAGE_PICTURE == nil self.opacity = SHOP::WINDOWS_OPACITY else self.opacity = 0 @back_sprite = Sprite.new @back_sprite.bitmap = RPG::Cache.picture(SHOP::MESSAGE_PICTURE) @back_sprite.opacity = SHOP::MESSAGE_OPACITY @back_sprite.x = self.x @back_sprite.y = self.y end self.contents = Bitmap.new(width - 32, height - 32) end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def disopse super if @back_sprite != nil @back_sprite.bitmap.dispose @back_sprite.dispose end end #-------------------------------------------------------------------------- # ● テキスト設定 # texts : ウィンドウに表示する文字列の配列 #-------------------------------------------------------------------------- def set_text(texts) # テキストが前回と違っている場合 if texts != @texts # テキストを再描画 self.contents.clear if texts == nil @texts = texts return end self.contents.font.color = SHOP::MESSAGE_COLOR self.contents.font.name = SHOP::MESSAGE_FONTNAME self.contents.font.size = SHOP::MESSAGE_FONTSIZE align = SHOP::MESSAGE_ALIGN y = -(texts.size - 3) * 16 for i in 0...texts.size text = texts[i] self.contents.draw_text(4, y + 32 * i, self.width - 40, 32, text, align) end @texts = texts end self.visible = true end end class Window_ShopGold < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear cx = contents.text_size($data_system.words.gold).width self.contents.font.color = SHOP::GOLD_COLOR self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2) self.contents.font.color = SHOP::GOLD_G_COLOR self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2) end end class Window_ShopCommand < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 368, 64) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = SHOP::WINDOWS_OPACITY @item_max = 3 @column_max = 3 @commands = ["購入する", "売却する", "やめる"] refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) x = 4 + index * 122 self.contents.draw_text(x, 0, 128, 32, @commands[index]) end end class Window_ShopBuy < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 # shop_goods : 商品 #-------------------------------------------------------------------------- def initialize(shop_goods) case SHOP::S_WINDOW_TYPE when 1 h = 160 when 2 h = 224 end super(0, 64, 368, h) self.opacity = SHOP::WINDOWS_OPACITY @shop_goods = shop_goods refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] # アイテムの所持数を取得 case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end # 価格が所持金以下、かつ所持数が 99 でなければ通常文字色に、 # そうでなければ無効文字色に設定 if item.price <= $game_party.gold and number < 99 self.contents.font.color = SHOP::BUY_COLOR else self.contents.font.color = SHOP::BUY_D_COLOR end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == SHOP::BUY_COLOR ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2) end end class Window_ShopSell < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 64, 368, 352) self.opacity = SHOP::WINDOWS_OPACITY refresh self.index = 0 end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] case item when RPG::Item number = $game_party.item_number(item.id) when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end # 売却可能なら通常文字色に、そうでないなら無効文字色に設定 if item.price > 0 self.contents.font.color = SHOP::SELL_COLOR else self.contents.font.color = SHOP::SELL_D_COLOR end x = 4 y = index * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == SHOP::SELL_COLOR ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end end class Window_ShopNumber < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize case SHOP::S_WINDOW_TYPE when 1 h = 160 when 2 h = 224 end super(0, 64, 368, h) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = SHOP::WINDOWS_OPACITY @item = nil @max = 1 @price = 0 @number = 1 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh case SHOP::S_WINDOW_TYPE when 1 y = 32 when 2 y = 64 end self.contents.clear draw_item_name(@item, 4, y) self.contents.font.color = SHOP::NUMBER_COLOR self.contents.draw_text(272, y, 32, 32, "×") self.contents.draw_text(308, y, 24, 32, @number.to_s, 2) self.cursor_rect.set(304, y, 32, 32) # 合計価格と通貨単位を描画 domination = $data_system.words.gold cx = contents.text_size(domination).width total_price = @price * @number self.contents.font.color = SHOP::GOLD_COLOR self.contents.draw_text(4, y + 64, 328-cx-2, 32, total_price.to_s, 2) self.contents.font.color = SHOP::GOLD_G_COLOR self.contents.draw_text(332-cx, y + 64, cx, 32, domination, 2) end end class Window_ShopStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize case SHOP::S_WINDOW_TYPE when 1 h = 192 when 2 h = 128 end super(0, 416-h, 368, h) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = SHOP::WINDOWS_OPACITY @item = nil refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear if @item == nil return end case @item when RPG::Item number = $game_party.item_number(@item.id) when RPG::Weapon number = $game_party.weapon_number(@item.id) when RPG::Armor number = $game_party.armor_number(@item.id) end self.contents.font.color = SHOP::STATUS_S_COLOR self.contents.draw_text(4, 0, 200, 32, "所持数") self.contents.font.color = SHOP::STATUS_COLOR self.contents.draw_text(128, 0, 32, 32, number.to_s, 2) if @item.is_a?(RPG::Item) return end case SHOP::S_WINDOW_TYPE when 1 draw_status1 when 2 draw_status2 end end #-------------------------------------------------------------------------- # ● 能力変化描画(タイプ1) #-------------------------------------------------------------------------- def draw_status1 # 装備品追加情報 for i in 0...$game_party.actors.size # アクターを取得 actor = $game_party.actors[i] # 装備可能なら通常文字色に、不可能なら無効文字色に設定 if actor.equippable?(@item) self.contents.font.color = SHOP::STATUS_COLOR else self.contents.font.color = SHOP::STATUS_D_COLOR end # アクターの顔を描画 self.contents.draw_battler_facesquare(actor, 4, 32 + 32 * i) # 現在の装備品を取得 if @item.is_a?(RPG::Weapon) item1 = $data_weapons[actor.weapon_id] elsif @item.kind == 0 item1 = $data_armors[actor.armor1_id] elsif @item.kind == 1 item1 = $data_armors[actor.armor2_id] elsif @item.kind == 2 item1 = $data_armors[actor.armor3_id] else item1 = $data_armors[actor.armor4_id] end # 装備可能な場合 if actor.equippable?(@item) # 武器の場合 if @item.is_a?(RPG::Weapon) atk1 = item1 != nil ? item1.atk : 0 atk2 = @item != nil ? @item.atk : 0 change = atk2 - atk1 end # 防具の場合 if @item.is_a?(RPG::Armor) pdef1 = item1 != nil ? item1.pdef : 0 mdef1 = item1 != nil ? item1.mdef : 0 pdef2 = @item != nil ? @item.pdef : 0 mdef2 = @item != nil ? @item.mdef : 0 change = pdef2 - pdef1 + mdef2 - mdef1 end # パラメータの変化値を描画 self.contents.draw_text(220, 32 + 32 * i, 112, 32, sprintf("%+d", change), 2) end # アイテムを描画 if item1 != nil x = 48 y = 32 + 32 * i bitmap = RPG::Cache.icon(item1.icon_name) opacity = self.contents.font.color == SHOP::STATUS_COLOR ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item1.name) end end end #-------------------------------------------------------------------------- # ● 能力変化描画(タイプ2) #-------------------------------------------------------------------------- def draw_status2 # 装備品追加情報 for i in 0...$game_party.actors.size # アクターを取得 actor = $game_party.actors[i] # 装備可能なら通常文字色に、不可能なら無効文字色に設定 if actor.equippable?(@item) self.contents.font.color = SHOP::STATUS_COLOR else self.contents.font.color = SHOP::STATUS_D_COLOR end # アクターの顔を描画 x = i%2 == 0 ? 32 : 32 + 164 y = i < 2 ? 34 : 66 self.contents.draw_battler_facesquare(actor, x, y) # 現在の装備品を取得 if @item.is_a?(RPG::Weapon) item1 = $data_weapons[actor.weapon_id] elsif @item.kind == 0 item1 = $data_armors[actor.armor1_id] elsif @item.kind == 1 item1 = $data_armors[actor.armor2_id] elsif @item.kind == 2 item1 = $data_armors[actor.armor3_id] else item1 = $data_armors[actor.armor4_id] end # 装備可能な場合 if actor.equippable?(@item) # 武器の場合 if @item.is_a?(RPG::Weapon) atk1 = item1 != nil ? item1.atk : 0 atk2 = @item != nil ? @item.atk : 0 change = atk2 - atk1 end # 防具の場合 if @item.is_a?(RPG::Armor) pdef1 = item1 != nil ? item1.pdef : 0 mdef1 = item1 != nil ? item1.mdef : 0 pdef2 = @item != nil ? @item.pdef : 0 mdef2 = @item != nil ? @item.mdef : 0 change = pdef2 - pdef1 + mdef2 - mdef1 end # パラメータの変化値を描画 x = i%2 == 0 ? 16 : 16 + 164 y = i < 2 ? 32 : 64 self.contents.draw_text(x, y, 112, 32, sprintf("%+d", change), 2) end end end end class Scene_Shop #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # 背景 @back_map = Spriteset_Map.new if SHOP::BACK_MAP @back_name = SHOP::BACK_PICTURE[$game_variables[SHOP::VARIABLE_ID]] @back_name = nil if @back_name == "" if @back_name != nil @back_sprite = Sprite.new set_back_picture(0) @back_sprite.opacity = SHOP::BACK_OPACITY end # ヘルプウィンドウを作成 @help_window = Window_ShopHelp.new @help_window.y = 416 # メッセージウィンドウを作成 @message_window = Window_ShopMessage.new set_message(0) # コマンドウィンドウを作成 commands = ["購入する", "売却する", "やめる"] @command_window = Window_ShopCommand.new # ゴールドウィンドウを作成 @gold_window = Window_ShopGold.new @gold_window.x = SHOP::GOLD_POSITION[0] @gold_window.y = SHOP::GOLD_POSITION[1] @gold_window.opacity = SHOP::WINDOWS_OPACITY # ダミーウィンドウを作成 @dummy_window = Window_Base.new(0, 64, 368, 352) @dummy_window.opacity = SHOP::WINDOWS_OPACITY # 購入ウィンドウを作成 @buy_window = Window_ShopBuy.new($game_temp.shop_goods) @buy_window.active = false @buy_window.visible = false @buy_window.help_window = @help_window # 売却ウィンドウを作成 @sell_window = Window_ShopSell.new @sell_window.active = false @sell_window.visible = false @sell_window.help_window = @help_window # 個数入力ウィンドウを作成 @number_window = Window_ShopNumber.new @number_window.active = false @number_window.visible = false # ステータスウィンドウを作成 @status_window = Window_ShopStatus.new @status_window.visible = false # 店員画像 @storekeeper_name = SHOP::PICTURES[$game_variables[SHOP::VARIABLE_ID]] if @storekeeper_name != nil @storekeeper = Sprite.new set_picture(0) if SHOP::PICTURE_OX == 2 @storekeeper.ox = @storekeeper.bitmap.width / 2 end if SHOP::PICTURE_OY == 2 @storekeeper.oy = @storekeeper.bitmap.height / 2 end @storekeeper.x = SHOP::PICTURE_POSITION[0] @storekeeper.y = SHOP::PICTURE_POSITION[1] @storekeeper.z = 100 * SHOP::PICTURE_Z end # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @back_map.dispose if SHOP::BACK_MAP if @back_name != nil @back_sprite.bitmap.dispose @back_sprite.dispose end @help_window.dispose @message_window.dispose @command_window.dispose @gold_window.dispose @dummy_window.dispose @buy_window.dispose @sell_window.dispose @number_window.dispose @status_window.dispose if @storekeeper_name != nil @storekeeper.bitmap.dispose @storekeeper.dispose end end #-------------------------------------------------------------------------- # ● 背景ピクチャをセット #-------------------------------------------------------------------------- def set_back_picture(index = 0) # 画像が無効なら終了 if @back_name == nil return end # 画像名取得 if @back_name.is_a?(Array) picture_name = @back_name[index] else picture_name = @back_name end # 画像を変える必要がなければ終了 if picture_name == @pre_back_name return end @back_sprite.bitmap = RPG::Cache.title(picture_name) @pre_back_name = picture_name end #-------------------------------------------------------------------------- # ● 店員ピクチャをセット #-------------------------------------------------------------------------- def set_picture(index = 0, forced = false) # 画像が無効なら終了 if @storekeeper_name == nil return end # 画像名取得 if @storekeeper_name.is_a?(Array) picture_name = @storekeeper_name[index] else picture_name = @storekeeper_name end # 画像を変える必要がなければ終了 if picture_name == @pre_keeper_name return end # 画像変更 case SHOP::PICTURES_FOLDER when 1 @storekeeper.bitmap = RPG::Cache.picture(picture_name) when 2 @storekeeper.bitmap = RPG::Cache.battler(picture_name, 0) end @pre_keeper_name = picture_name end #-------------------------------------------------------------------------- # ● 店員メッセージをセット #-------------------------------------------------------------------------- def set_message(index = 0, forced = false) # 強制変更ではなくて、カウントが残っている場合 終了 if !forced and @picture_count != nil return end # カウント設定 case index when 0 @picture_count = nil p_index = 0 when 1, 5 @picture_count = nil p_index = 1 when 2, 6 @picture_count = nil p_index = 2 when 3, 7 @picture_count = SHOP::DECIDE_TIME * 2 p_index = 3 when 4, 8 @picture_count = SHOP::CANCEL_TIME * 2 p_index = 4 end # ピクチャセット set_picture(p_index) # 無効なテキストなら終了 if SHOP::MESSAGES[$game_variables[SHOP::VARIABLE_ID]] == nil return end texts = SHOP::MESSAGES[$game_variables[SHOP::VARIABLE_ID]][index] @message_window.set_text(texts) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ピクチャ・メッセージ更新 if @picture_count != nil @picture_count -= 1 if @picture_count < 0 @picture_count = nil if @command_window.active set_message(0) elsif @buy_window.active set_message(1) elsif @sell_window.active set_message(5) elsif @number_window.active case @command_window.index when 0 set_message(2) when 1 set_message(6) end end end end # ウィンドウを更新 @help_window.update @message_window.update @command_window.update @gold_window.update @dummy_window.update @buy_window.update @sell_window.update @number_window.update @status_window.update # コマンドウィンドウがアクティブの場合: update_command を呼ぶ if @command_window.active update_command return end # 購入ウィンドウがアクティブの場合: update_buy を呼ぶ if @buy_window.active update_buy return end # 売却ウィンドウがアクティブの場合: update_sell を呼ぶ if @sell_window.active update_sell return end # 個数入力ウィンドウがアクティブの場合: update_number を呼ぶ if @number_window.active update_number return end end #-------------------------------------------------------------------------- # ● フレーム更新 (コマンドウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_command # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # マップ画面に切り替え $scene = Scene_Map.new return end # C ボタンが押された場合 if Input.trigger?(Input::C) # コマンドウィンドウのカーソル位置で分岐 case @command_window.index when 0 # 購入する # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # ウィンドウの状態を購入モードへ @command_window.active = false @dummy_window.visible = false @buy_window.active = true @buy_window.visible = true @buy_window.refresh @status_window.visible = true set_back_picture(1) set_message(1, true) when 1 # 売却する # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # ウィンドウの状態を売却モードへ @command_window.active = false @dummy_window.visible = false @sell_window.active = true @sell_window.visible = true @sell_window.refresh set_back_picture(2) set_message(5, true) when 2 # やめる # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # マップ画面に切り替え $scene = Scene_Map.new end return end end #-------------------------------------------------------------------------- # ● フレーム更新 (購入ウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_buy # ステータスウィンドウのアイテムを設定 @status_window.item = @buy_window.item # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ウィンドウの状態を初期モードへ @command_window.active = true @dummy_window.visible = true @buy_window.active = false @buy_window.visible = false @status_window.visible = false @status_window.item = nil set_back_picture(0) set_message(0) # ヘルプテキストを消去 @help_window.set_text("") return end # C ボタンが押された場合 if Input.trigger?(Input::C) # アイテムを取得 @item = @buy_window.item # アイテムが無効の場合、または価格が所持金より上の場合 if @item == nil or @item.price > $game_party.gold # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # アイテムの所持数を取得 case @item when RPG::Item number = $game_party.item_number(@item.id) when RPG::Weapon number = $game_party.weapon_number(@item.id) when RPG::Armor number = $game_party.armor_number(@item.id) end # すでに 99 個所持している場合 if number == 99 # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # 最大購入可能個数を計算 max = @item.price == 0 ? 99 : $game_party.gold / @item.price max = [max, 99 - number].min # ウィンドウの状態を個数入力モードへ @buy_window.active = false @buy_window.visible = false @number_window.set(@item, max, @item.price) @number_window.active = true @number_window.visible = true set_back_picture(3) set_message(2, true) end end #-------------------------------------------------------------------------- # ● フレーム更新 (売却ウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_sell # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # ウィンドウの状態を初期モードへ @command_window.active = true @dummy_window.visible = true @sell_window.active = false @sell_window.visible = false @status_window.item = nil set_back_picture(0) set_message(0) # ヘルプテキストを消去 @help_window.set_text("") return end # C ボタンが押された場合 if Input.trigger?(Input::C) # アイテムを取得 @item = @sell_window.item # ステータスウィンドウのアイテムを設定 @status_window.item = @item # アイテムが無効の場合、または価格が 0 (売却不可) の場合 if @item == nil or @item.price == 0 # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アイテムの所持数を取得 case @item when RPG::Item number = $game_party.item_number(@item.id) when RPG::Weapon number = $game_party.weapon_number(@item.id) when RPG::Armor number = $game_party.armor_number(@item.id) end # 最大売却個数 = アイテムの所持数 max = number # ウィンドウの状態を個数入力モードへ @sell_window.active = false @sell_window.visible = false @number_window.set(@item, max, @item.price / 2) @number_window.active = true @number_window.visible = true @status_window.visible = true set_back_picture(3) set_message(6, true) end end #-------------------------------------------------------------------------- # ● フレーム更新 (個数入力ウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_number # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # 個数入力ウィンドウを非アクティブ・不可視に設定 @number_window.active = false @number_window.visible = false # コマンドウィンドウのカーソル位置で分岐 case @command_window.index when 0 # 購入する # ウィンドウの状態を購入モードへ @buy_window.active = true @buy_window.visible = true set_back_picture(1) set_message(4) when 1 # 売却する # ウィンドウの状態を売却モードへ @sell_window.active = true @sell_window.visible = true @status_window.visible = false set_back_picture(2) set_message(8) end return end # C ボタンが押された場合 if Input.trigger?(Input::C) # ショップ SE を演奏 $game_system.se_play($data_system.shop_se) # 個数入力ウィンドウを非アクティブ・不可視に設定 @number_window.active = false @number_window.visible = false # コマンドウィンドウのカーソル位置で分岐 case @command_window.index when 0 # 購入する # 購入処理 $game_party.lose_gold(@number_window.number * @item.price) case @item when RPG::Item $game_party.gain_item(@item.id, @number_window.number) when RPG::Weapon $game_party.gain_weapon(@item.id, @number_window.number) when RPG::Armor $game_party.gain_armor(@item.id, @number_window.number) end # 各ウィンドウをリフレッシュ @gold_window.refresh @buy_window.refresh @status_window.refresh # ウィンドウの状態を購入モードへ @buy_window.active = true @buy_window.visible = true set_back_picture(1) set_message(3) when 1 # 売却する # 売却処理 $game_party.gain_gold(@number_window.number * (@item.price / 2)) case @item when RPG::Item $game_party.lose_item(@item.id, @number_window.number) when RPG::Weapon $game_party.lose_weapon(@item.id, @number_window.number) when RPG::Armor $game_party.lose_armor(@item.id, @number_window.number) end # 各ウィンドウをリフレッシュ @gold_window.refresh @sell_window.refresh @status_window.refresh # ウィンドウの状態を売却モードへ @sell_window.active = true @sell_window.visible = true @status_window.visible = false set_back_picture(2) set_message(7) end return end end end