设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1447|回复: 3
打印 上一主题 下一主题

[已经过期] 请问那个限量商店能进货么..

[复制链接]

Lv1.梦旅人

梦石
0
星屑
65
在线时间
208 小时
注册时间
2013-10-10
帖子
43
跳转到指定楼层
1
发表于 2015-3-15 16:26:37 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
就是这个..用@stock[] =   可以给商店的物品数量定初始数量,,但不知道怎么更改数量,比如在某个事件后某个商店的1号物品剩余数量增加20个什么的..
  1. =begin
  2. #===============================================================================
  3. Title: Shop Stock
  4. Author: Tsukihime
  5. Date: Feb 22, 2013
  6. --------------------------------------------------------------------------------
  7. ** Change log
  8. Feb 22, 2013
  9.    - Initial release
  10. --------------------------------------------------------------------------------   
  11. ** 使用协议
  12. * 免费用于商业或非商业项目
  13. * 自由使用
  14. * 会有BUG修复,但没有兼容性补丁
  15. * 功能可能没有保证
  16. * Preserve this header
  17. --------------------------------------------------------------------------------
  18. ** 必需

  19. -商店库存-基础 以下网址为外站Hime Works,请开在线代理浏览
  20. ([url]http://himeworks.wordpress.com/2013/02/22/shop-manager/[/url])
  21. --------------------------------------------------------------------------------
  22. ** 说明

  23. 这个脚本添加了一个stock到每个商店
  24. 一旦一个商品的stock达到零,它将不能在商店继续售卖

  25. --------------------------------------------------------------------------------
  26. ** 用法

  27. 在你的事件中,在商店处理命令的上面添加以下脚本

  28.    @shop_stock[id] = 数值
  29.    
  30. 名词解用
  31.    id为商店处理中商品列表的id
  32.    第一项商品的id为1,依此类推
  33.    
  34.    数值是该商品有多少存货在该商店
  35.    
  36. --------------------------------------------------------------------------------
  37. ** 作者的话

  38. 一个店的商品存货有多少全取决于stock

  39.    stock < 0, 没有限制
  40.    stock == 0, 没有库存
  41.    stock > 0, 还有那么多库存

  42. #===============================================================================
  43. =end
  44. $imported = {} if $imported.nil?
  45. $imported["TH_ShopStock"] = true
  46. #===============================================================================
  47. # ** Configuration  配置
  48. #===============================================================================
  49. module TH
  50.   module Shop_Stock
  51.   end
  52. end
  53. #===============================================================================
  54. # ** Rest of the Script
  55. #===============================================================================
  56. class Game_Interpreter

  57.   alias :th_shop_stock_clear :clear
  58.   def clear
  59.     th_shop_stock_clear
  60.     @shop_stock = []
  61.   end

  62.   alias :th_shop_stock_setup_good :setup_good
  63.   def setup_good(good, id)
  64.     th_shop_stock_setup_good(good, id)
  65.     stock = @shop_stock[id]
  66.     return unless stock
  67.     good.stock = stock
  68.   end
  69. end

  70. class Game_ShopGood
  71.   attr_reader :stock

  72.   alias :th_shop_stock_init :initialize
  73.   def initialize(*args)
  74.     th_shop_stock_init(*args)
  75.     @stock = -1
  76.     @unlimited = true
  77.   end

  78.   def stock=(amount)
  79.     @stock = amount
  80.    @unlimited = (amount < 0)
  81.   end

  82.   def unlimited?
  83.     @unlimited
  84.   end

  85.   def increase_stock(amount)
  86.     @stock += amount
  87.   end

  88.   def decrease_stock(amount)
  89.     return if @unlimited
  90.     @stock = [@stock - amount, 0].max
  91.   end
  92. end

  93. class Game_Shop

  94.   alias :th_shop_stock_include? :include?
  95.   def include?(index)
  96.     return false if stock(index) == 0
  97.     th_shop_stock_include?(index)
  98.   end

  99.   def stock(index)
  100.     @shop_goods[index].stock
  101.   end
  102. end

  103. class Window_ShopBuy < Window_Selectable

  104.   alias :th_shop_stock_include? :include?
  105.   def include?(shopGood)
  106.     return false if shopGood.stock == 0
  107.     th_shop_stock_include?(shopGood)
  108.   end

  109.   alias :th_shop_stock_draw_item :draw_item
  110.   def draw_item(index)
  111.     th_shop_stock_draw_item(index)
  112.     rect = item_rect(index)
  113.     item = @data[index]
  114.     shopGood = @goods[item]
  115.     draw_text(rect, sprintf("                                                           余:%d", shopGood.stock), 1) unless shopGood.unlimited?
  116.   end

  117.   alias :th_shop_stock_process_ok :process_ok
  118.   def process_ok
  119.     unless @data[index]
  120.       Sound.play_buzzer
  121.       return
  122.     end
  123.     th_shop_stock_process_ok
  124.   end
  125. end

  126. class Scene_Shop < Scene_MenuBase

  127.   #--------------------------------------------------------------------------
  128.   # Get amount you could buy, compared to the amount in-stock
  129.   #--------------------------------------------------------------------------
  130.   alias :th_shop_stock_max_buy :max_buy
  131.   def max_buy
  132.     party_max = th_shop_stock_max_buy
  133.     @selected_good.unlimited? ? party_max : [party_max, @selected_good.stock].min
  134.   end

  135.   #--------------------------------------------------------------------------
  136.   # Decrease the amount of stock of the selected good
  137.   #--------------------------------------------------------------------------
  138.   alias :th_shop_stock_do_buy :do_buy
  139.   def do_buy(number)
  140.     th_shop_stock_do_buy(number)
  141.     @selected_good.decrease_stock(number)
  142.   end
  143. end
复制代码
  1. =begin
  2. #===============================================================================
  3. Title: Shop Manager
  4. Author: Tsukihime
  5. Date: Mar 29, 2013
  6. --------------------------------------------------------------------------------
  7. ** Change log
  8. 1.5 Mar 29
  9.    - added simple shop refreshing on page change. Will need a better solution
  10.      since this does not track the state of a shop on a different page
  11. 1.4 Mar 13
  12.    - fixed bug where common event shops were not handled appropriately when
  13.      called through effects
  14. 1.3 Mar 1
  15.    - Game_ShopGood now determines whether it should be included or enabled
  16.    - Two shop options implemented: hidden, disabled
  17. 1.2 Feb 25
  18.    - fixed issue where common event shops were not handled correctly
  19.    - exposed Shop Good variables as readers
  20. 1.1
  21.    - ShopManager handles shop scene changing depending on the type of shop
  22.    - added handling for different "types" of shops
  23.    - all goods in a shop can be accessed via shop.shop_goods
  24.    - reference to shop added to shop scene
  25.    - added support for adding and removing goods from a shop
  26. 1.0 Feb 22, 2013
  27.    - Initial Release
  28. --------------------------------------------------------------------------------   
  29. ** Terms of Use
  30. * Free to use in commercial/non-commercial projects
  31. * No real support. The script is provided as-is
  32. * Will do bug fixes, but no compatibility patches
  33. * Features may be requested but no guarantees, especially if it is non-trivial
  34. * Credits to Tsukihime in your project
  35. * Preserve this header
  36. --------------------------------------------------------------------------------
  37. ** Description

  38. This script serves as a base for all shop-related scripts.

  39. This script provides functionality for remember a shop's "state".
  40. Each shop is uniquely identified by a shop ID, and if you visit the same
  41. shop repeatedly, you should see the same settings.

  42. For example, if a shop holds 10 potions, and you bought 5, then you can
  43. expect that the next time you visit the shop, it will only have 5 potions
  44. remaining.

  45. Of course, you will need extra plugins to have that kind of functionality.
  46. Several new classes have been defined for working with shops, and in
  47. particular, shop goods.

  48. In summary:
  49.    -more control over your shops
  50.    -simple API for developers to write shop-related scripts

  51. --------------------------------------------------------------------------------
  52. ** Usage

  53. --------------------------------------------------------------------------------
  54. ** Developers

  55. Here are some specifications that I have written.

  56. Have a look through each class to see what is available for use.
  57. If you have any suggestions that will improve the base script (ie: this),
  58. I will consider adding them.

  59. -- Shop Manager --

  60. This module serves are the interface for all shop-related queries. It handles
  61. how shops are stored for you so that it is easy to properly obtain a reference
  62. to a shop.

  63. You should use the Shop Manager whenever possible.

  64. -- Game Shop --

  65. This script treats a shop as a concrete object. A shop is created the first
  66. time it is accessed, and will be stored with the game for the remainder of
  67. the game.

  68. A very basic shop is provided, which manages what items are available for sale.
  69. All shops are stored in a global Game_Shops hash in $game_shops

  70. -- Shop Type --

  71. On top of the basic Game_Shop class, you can define your own shops and
  72. associate them with custom scenes specific to those shops.

  73. The Shop Manager only requires you to be consistent with your shop name.
  74. For example, if your shop type is "CraftShop", then you must define a

  75.    Game_CraftShop  - the shop object that the shop will be instantiated with
  76.    Scene_CraftShop - the scene that will be called when visiting a CraftShop
  77.    
  78. Users will set a @shop_type attribute in Game_Interpreter to determine
  79. what type of shop should be created

  80. -- Managing shops --

  81. This script assumes shops are only called through events or common events.
  82. Troop events are not supported.

  83. A shop is identified by a map ID and an event ID.
  84. Shops that are called via common events will have a map ID of 0.

  85. In order to determine whether a normal event or a common event called the
  86. shop, the "depth" of the interpreter is used.

  87.     When depth = 0, then it is a normal event
  88.     When depth > 0, then it is a common event
  89.    
  90. The shop processing should be handled appropriately depending on the depth

  91. This script assumes that an event is triggered through "normal" interaction;
  92. that is, you can only interact with events within a map. Any events that should
  93. be treated as the same event should be done as a common event call.

  94. --- Shop Goods ---

  95. Rather than storing all goods as a simple array of values, this script
  96. provides a Game_ShopGood class. You can use this to store any additional
  97. information that you want.

  98. All shop related scenes and windows MUST provide support for handling shop
  99. goods. While backwards compatibility is provided for the default scripts,
  100. additional methods have been defined to allow you to retrieve the currently
  101. selected shop good.

  102. --- Shop Options ---

  103. Since there isn't actually a way to setup individual shop goods, external
  104. approaches must be used. There is not much specification here yet, so it
  105. is up to you how you wish to populate your ShopGood objects. I have provided
  106. a "setup_goods" method in Game_Interpreter that you can alias.

  107. --------------------------------------------------------------------------------
  108. ** Compatibility

  109. This script changes the following from the default scripts

  110.    DataManager
  111.      aliased  - create_game_objects   
  112.      aliased  - make_save_contents
  113.      aliased  - extract_save_contents
  114.    Game_Interpreter
  115.      replaced - command_302
  116.    Window_ShopBuy
  117.      replaced - prepare
  118.    Scene_Shop
  119.      replaced - make_item_list
  120. #===============================================================================
  121. =end
  122. $imported = {} if $imported.nil?
  123. $imported["TH_ShopManager"] = 1.5
  124. #===============================================================================
  125. # ** Rest of the Script
  126. #===============================================================================

  127. #-------------------------------------------------------------------------------
  128. # 作为商店和其他对象之间的界面的主力店经理
  129. # ShopManager 的主要作用是本质上是管理店里的任何在游戏中存在的对象
  130. # 尤其是,它提供了所有的方法
  131. # 创建、 检索和删除商店。
  132. # 所有的商店都存储在 全局变量$game_shops 的 Game_Shops哈希表
  133. #-------------------------------------------------------------------------------
  134. module ShopManager

  135.   #-----------------------------------------------------------------------------
  136.   # 返回一个引用到一个特定的商店
  137.   #-----------------------------------------------------------------------------
  138.   def self.get_shop(map_id, event_id)
  139.     return $game_shops[map_id, event_id]
  140.   end

  141.   #-----------------------------------------------------------------------------
  142.   # 表明一家店需要刷新
  143.   #-----------------------------------------------------------------------------
  144.   def self.refresh_shop(map_id, event_id)
  145.     shop = get_shop(map_id, event_id)
  146.     shop.need_refresh = true if shop
  147.   end

  148.   #-----------------------------------------------------------------------------
  149.   # 设置商店,如果第一次访问
  150.   #-----------------------------------------------------------------------------
  151.   def self.setup_shop(map_id, event_id, goods, purchase_only, shop_type)
  152.     shop = get_shop(map_id, event_id)
  153.     return shop if shop && !shop.need_refresh
  154.     shop = shop_class(shop_type).new(goods, purchase_only)
  155.     $game_shops[map_id, event_id] = shop
  156.     return shop
  157.   end

  158.   #-----------------------------------------------------------------------------
  159.   # 返回给定商店类型的适当店类
  160.   #-----------------------------------------------------------------------------
  161.   def self.shop_class(shop_type)
  162.     shop_type = "Game_" + shop_type.to_s
  163.     return Object.const_get(shop_type.to_sym)
  164.   end

  165.   #-----------------------------------------------------------------------------
  166.   # 返回与这家商店关联的场景
  167.   # TO DO
  168.   #-----------------------------------------------------------------------------
  169.   def self.shop_scene(shop)
  170.     shop_scene = "Scene_" + shop.class.name.gsub("Game_", "")
  171.     return Object.const_get(shop_scene.to_sym)
  172.   end

  173.   #-----------------------------------------------------------------------------
  174.   # 在适当的舞台上调用 SceneManager.call
  175.   #-----------------------------------------------------------------------------
  176.   def self.call_scene(shop)

  177.     SceneManager.call(shop_scene(shop))
  178.     SceneManager.scene.prepare(shop)
  179.   end

  180.   #-----------------------------------------------------------------------------
  181.   # 在适当的舞台上调用 SceneManager.goto
  182.   #-----------------------------------------------------------------------------
  183.   def self.goto_scene(shop)
  184.     SceneManager.goto(shop_scene(shop))
  185.     SceneManager.scene.prepare(shop)
  186.   end

  187.   #-----------------------------------------------------------------------------
  188.   # Returns a good ID, given a shop and an item. If the item is already in
  189.   # the shop, it will return that good's ID. Otherwise, it will return a new ID
  190.   # 给定一个商店和一个项目的情况下返回一个好的 ID。如果该项目已在
  191.   # 店里,它将返回货物的 id。否则,它将返回一个新的 ID
  192.   #-----------------------------------------------------------------------------
  193.   def self.get_good_id(shop, item)
  194.     good = shop.shop_goods.detect {|good| good.item == item}
  195.     return good.nil? ? shop.shop_goods.size + 1 : good.id
  196.   end

  197.   #-----------------------------------------------------------------------------
  198.   # Returns a good, given a shop and an item. If the shop already has that good
  199.   # just return it. Otherwise, make a new good. If the price is negative, then
  200.   # the price is the default price. Otherwise, it is the specified price.
  201.   # 给定一个商店和一个项目的情况下返回一个货物。如果店里已经有货物
  202.   # 只返回它。否则,造就了一个新的货物。如果价格是消极的那么
  203.   # 价格是默认价格。否则,它是指定的价格。
  204.   #-----------------------------------------------------------------------------
  205.   def self.get_good(shop, item, price=-1)
  206.     good = shop.shop_goods.detect {|good| good.item == item}
  207.     return good if good
  208.     good_id = shop.shop_goods.size + 1
  209.     type = item_type(item)
  210.     if price < 0
  211.       price_type = price = 0
  212.     else
  213.       price_type = 1
  214.     end
  215.     return Game_ShopGood.new(good_id, type, item.id, price_type, price)
  216.   end

  217.   #-----------------------------------------------------------------------------
  218.   # 返回的项的类型。
  219.   #-----------------------------------------------------------------------------
  220.   def self.item_type(item)
  221.     return 0 if item.is_a?(RPG::Item)
  222.     return 1 if item.is_a?(RPG::Weapon)
  223.     return 2 if item.is_a?(RPG::Armor)
  224.     return -1
  225.   end
  226. end

  227. #-------------------------------------------------------------------------------
  228. # Shops are stored in a global variable `$game_shops`. This is dumped and
  229. # loaded appropriately.
  230. # 商店都存储在全局变量 '$game_shops'。这是适当的倾倒和加载
  231. #-------------------------------------------------------------------------------
  232. module DataManager

  233.   class << self
  234.     alias :th_shop_manager_create_game_objects :create_game_objects
  235.     alias :th_shop_manager_make_save_contents :make_save_contents
  236.     alias :th_shop_manager_extract_save_contents :extract_save_contents
  237.   end

  238.   def self.create_game_objects
  239.     th_shop_manager_create_game_objects
  240.     $game_shops = Game_Shops.new
  241.   end

  242.   def self.make_save_contents
  243.     contents = th_shop_manager_make_save_contents
  244.     contents[:shops] = $game_shops
  245.     contents
  246.   end

  247.   #-----------------------------------------------------------------------------
  248.   # Load shop data 商店数据加载
  249.   #-----------------------------------------------------------------------------
  250.   def self.extract_save_contents(contents)
  251.     th_shop_manager_extract_save_contents(contents)
  252.     $game_shops = contents[:shops]
  253.   end
  254. end

  255. class Game_Temp

  256.   # even if we're not actually calling a shop, it shouldn't affect anything
  257.   # because we are always setting this at each common event call by an event
  258.   attr_accessor :shop_common_event_id

  259.   alias :th_shop_manager_reserve_common_event :reserve_common_event
  260.   def reserve_common_event(common_event_id)
  261.     th_shop_manager_reserve_common_event(common_event_id)
  262.     @shop_common_event_id = common_event_id
  263.   end
  264. end

  265. class Game_Event < Game_Character

  266.   alias :th_shop_manager_setup_page :setup_page
  267.   def setup_page(page)
  268.     th_shop_manager_setup_page(page)
  269.     ShopManager.refresh_shop(@map_id, @id)
  270.   end
  271. end

  272. class Game_Interpreter

  273.   alias :th_shop_manager_clear :clear
  274.   def clear
  275.     th_shop_manager_clear
  276.     clear_shop_options
  277.     @shop_type = nil
  278.   end

  279.   #-----------------------------------------------------------------------------
  280.   # New.
  281.   #-----------------------------------------------------------------------------
  282.   def clear_shop_options
  283.     @shop_options = {}
  284.     @shop_options[:hidden] = {}
  285.     @shop_options[:disabled] = {}
  286.   end

  287.   #-----------------------------------------------------------------------------
  288.   # New. We are in a common event only if the shop common event ID is set.
  289.   #-----------------------------------------------------------------------------
  290.   def shop_map_id
  291.     $game_temp.shop_common_event_id ? 0 : @map_id
  292.   end

  293.   def shop_event_id
  294.     $game_temp.shop_common_event_id ? $game_temp.shop_common_event_id : @event_id
  295.   end

  296.   #--------------------------------------------------------------------------
  297.   # Set the shop's common event ID
  298.   #--------------------------------------------------------------------------
  299.   alias :th_shop_manager_command_117 :command_117
  300.   def command_117
  301.     $game_temp.shop_common_event_id = @params[0]
  302.     th_shop_manager_command_117
  303.   end

  304.   #-----------------------------------------------------------------------------
  305.   # Replaced. A shop is setup only once, and is retrieved whenever it is
  306.   # called in the future. This assumes the shop is invoked through "normal"
  307.   # event interactions.
  308.   #-----------------------------------------------------------------------------
  309.   def command_302
  310.     return if $game_party.in_battle
  311.     shop_type = @shop_type || :Shop
  312.     good_id = 1
  313.     goods = []

  314.     # setup goods
  315.     good = make_good(@params[0..-1], good_id) # last param is for the shop
  316.     goods.push(good)
  317.     good_id +=1

  318.     while next_event_code == 605
  319.       @index += 1
  320.       good = make_good(@list[@index].parameters, good_id)
  321.       goods.push(good)
  322.       good_id +=1
  323.     end
  324.     # Setup shop if needed
  325.     shop = ShopManager.setup_shop(shop_map_id, shop_event_id, goods, @params[4], shop_type)

  326.     # prepare the shop with a reference to the actual shop
  327.     ShopManager.call_scene(shop)
  328.     Fiber.yield

  329.     # clear out the shop common event ID.
  330.     $game_temp.shop_common_event_id = nil
  331.   end

  332.   #-----------------------------------------------------------------------------
  333.   # New. This is where the goods are setup.
  334.   #-----------------------------------------------------------------------------
  335.   def make_good(goods_array, good_id)
  336.     item_type, item_id, price_type, price = goods_array
  337.     good = Game_ShopGood.new(good_id, item_type, item_id, price_type, price)

  338.     # additional setup
  339.     setup_good(good, good_id)
  340.     return good
  341.   end

  342.   #-----------------------------------------------------------------------------
  343.   # New. You can do more things with your good here
  344.   #-----------------------------------------------------------------------------
  345.   def setup_good(good, good_id)
  346.     setup_hidden_option(good, good_id)
  347.     setup_disabled_option(good, good_id)
  348.   end

  349.   #-----------------------------------------------------------------------------
  350.   # New. Shop options
  351.   #-----------------------------------------------------------------------------
  352.   def hide_good(good_id, condition)
  353.     @shop_options[:hidden][good_id] = condition
  354.   end

  355.   def disable_good(good_id, condition)
  356.     @shop_options[:disabled][good_id] = condition
  357.   end

  358.   def setup_hidden_option(good, good_id)
  359.     return unless @shop_options[:hidden][good_id]
  360.     good.hidden_condition = @shop_options[:hidden][good_id]
  361.   end

  362.   def setup_disabled_option(good, good_id)
  363.     return unless @shop_options[:disabled][good_id]
  364.     good.disable_condition = @shop_options[:disabled][good_id]
  365.   end
  366. end

  367. #-------------------------------------------------------------------------------
  368. # A shop good.
  369. # This is a wrapper around a raw item (RPG::Item, RPG::Weapon, etc).
  370. #-------------------------------------------------------------------------------

  371. class Game_ShopGood

  372.   attr_reader :id         # ID of this good
  373.   attr_reader :item_type
  374.   attr_reader :item_id
  375.   attr_reader :price_type
  376.   attr_accessor :hidden_condition
  377.   attr_accessor :disable_condition

  378.   def initialize(id, item_type, item_id, price_type, price)
  379.     @id = id
  380.     @item_type = item_type
  381.     @item_id = item_id
  382.     @price_type = price_type
  383.     @price = price
  384.     @hidden_condition = ""
  385.     @disable_condition = ""
  386.   end

  387.   def include?
  388.     return false if eval(@hidden_condition)
  389.     return true
  390.   end

  391.   def enable?
  392.     return false if eval(@disable_condition)
  393.     return true
  394.   end

  395.   def item
  396.     return $data_items[@item_id] if @item_type == 0
  397.     return $data_weapons[@item_id] if @item_type == 1
  398.     return $data_armors[@item_id] if @item_type == 2
  399.   end

  400.   def price
  401.     return item.price if @price_type == 0
  402.     return @price
  403.   end
  404. end

  405. #-------------------------------------------------------------------------------
  406. # A shop object. Stores information about the shop such as its inventory
  407. # and other shop-related data
  408. #-------------------------------------------------------------------------------
  409. class Game_Shop
  410.   attr_reader :purchase_only
  411.   attr_reader :shop_goods      # all goods that this shop has.
  412.   attr_accessor :need_refresh  # shop needs to be refreshed

  413.   def initialize(goods, purchase_only=false)
  414.     @shop_goods = goods
  415.     @purchase_only = purchase_only
  416.     @need_refresh = false
  417.   end
  418.   #-----------------------------------------------------------------------------
  419.   # Returns true if the goods should be included
  420.   #-----------------------------------------------------------------------------
  421.   def include?(index)
  422.     true
  423.   end

  424.   #-----------------------------------------------------------------------------
  425.   # Return a set of goods for sale
  426.   #-----------------------------------------------------------------------------
  427.   def goods
  428.     @shop_goods
  429.   end

  430.   #-----------------------------------------------------------------------------
  431.   # Add a new good to the shop
  432.   #-----------------------------------------------------------------------------
  433.   def add_good(good)
  434.     @shop_goods.push(good) unless @shop_goods.include?(good)
  435.   end

  436.   #-----------------------------------------------------------------------------
  437.   # Remove the specified good from the shop
  438.   #-----------------------------------------------------------------------------
  439.   def remove_good(good_id)
  440.     @shop_goods.delete_at(good_id - 1)
  441.   end
  442. end

  443. #-------------------------------------------------------------------------------
  444. # 包含在游戏中的所有商店的包装。
  445. #-------------------------------------------------------------------------------
  446. class Game_Shops

  447.   #-----------------------------------------------------------------------------
  448.   # Initializes a hash of game shops. Each key is a map ID, pointing to another
  449.   # hash whose keys are event ID's and values are Game_Shop objects.
  450.   # 初始化游戏商店的哈希。每个键是一个地图 ID 指向另一个哈希,那个
  451.   # 哈希的键是事件 ID    值是 Game_Shop 对象。
  452.   #-----------------------------------------------------------------------------
  453.   def initialize
  454.     @data = {}
  455.   end

  456.   def [](i, j)
  457.     @data[i] ||= {}
  458.     @data[i][j]
  459.   end

  460.   def []=(i, j, shop)
  461.     @data[i] ||= {}
  462.     @data[i][j] = shop
  463.   end
  464. end

  465. #-------------------------------------------------------------------------------
  466. # The shop scene now works with the Shop and ShopGood objects
  467. #-------------------------------------------------------------------------------
  468. class Scene_Shop < Scene_MenuBase
  469.   #--------------------------------------------------------------------------
  470.   # Replaced. The scene now takes a Game_Shop object
  471.   #--------------------------------------------------------------------------
  472.   def prepare(shop)
  473.     @shop = shop
  474.     @goods = shop.goods
  475.     @purchase_only = shop.purchase_only
  476.   end

  477.   alias :th_shop_manager_on_buy_ok :on_buy_ok
  478.   def on_buy_ok
  479.     @selected_good = @buy_window.current_good
  480.     th_shop_manager_on_buy_ok
  481.   end
  482. end

  483. #-------------------------------------------------------------------------------
  484. # @shop_goods is now an array of Game_ShopGoods
  485. #-------------------------------------------------------------------------------
  486. class Window_ShopBuy < Window_Selectable

  487.   #--------------------------------------------------------------------------
  488.   # New. Returns true if the good should be included in the shop inventory
  489.   #--------------------------------------------------------------------------
  490.   def include?(shopGood)
  491.     shopGood.include?
  492.   end

  493.   alias :th_shop_manager_enable? :enable?
  494.   def enable?(item)
  495.     return false unless @goods[item].enable?
  496.     th_shop_manager_enable?(item)
  497.   end

  498.   #--------------------------------------------------------------------------
  499.   # New. Get the currently selected good
  500.   #--------------------------------------------------------------------------
  501.   def current_good
  502.     @goods[item]
  503.   end

  504.   #-----------------------------------------------------------------------------
  505.   # Replaced. ShopGood takes care of most information. The data still contains
  506.   # a list of RPG items for now since I don't want to change them to goods yet
  507.   # A separate list of goods for sale is used for 1-1 correspondence
  508.   #-----------------------------------------------------------------------------
  509.   def make_item_list
  510.     @data = []
  511.     @goods = {}
  512.     @price = {}
  513.     @shop_goods.each do |shopGood|
  514.       next unless include?(shopGood)
  515.       item = shopGood.item
  516.       @data.push(item)
  517.       @goods[item] = shopGood
  518.       @price[item] = shopGood.price
  519.     end
  520.   end
  521. end
复制代码

Lv5.捕梦者 (暗夜天使)

只有笨蛋才会看到

梦石
1
星屑
21621
在线时间
9413 小时
注册时间
2012-6-19
帖子
7118

开拓者短篇九导演组冠军

2
发表于 2015-3-15 18:53:22 | 只看该作者
在执行某个事件后打开一个开关,为这个商店处理新切换一个事件页呗

或者:
  1. @shop_stock[id] = 数值 + $game_variables[1]
复制代码
商店的库存增加 变量1的值 个
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
208 小时
注册时间
2013-10-10
帖子
43
3
 楼主| 发表于 2015-3-15 20:27:21 | 只看该作者
喵呜喵5 发表于 2015-3-15 18:53
在执行某个事件后打开一个开关,为这个商店处理新切换一个事件页呗

或者:商店的库存增加 变量1的值 个 ...

好像不行..它似乎只读取一次@shop_stock来着..后面再用这个好像就无效..用新建事件页的话,似乎只能固定刷新剩余物品的数量,而不能在原商店剩余物品的数量的基础上增加....我试过输出@shop_stock[1]的值,一开始定的是20,它就输出了20,然后我去买了几个物品,继续输出,发现物品剩余量已经减少了,但是@shop_stock[1]的值仍然是20....大概来说就是,不知道怎么得到当前状态各个物品的剩余量是多少...
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
208 小时
注册时间
2013-10-10
帖子
43
4
 楼主| 发表于 2015-3-15 21:56:05 | 只看该作者
大概设置成这样,然后不管买了多少,不管第几次和这个事件对话总是会显示一次40,一次60..但是商店货物的剩余量还是没法通过除了购买以外的方式改变..然后就不知道怎么进货了...

1.jpg (119.27 KB, 下载次数: 19)

1.jpg
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-15 06:10

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表