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

Project1

 找回密码
 注册会员
搜索
查看: 2541|回复: 3

[已经过期] 物品仓库修改请教~

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3981
在线时间
603 小时
注册时间
2017-4-21
帖子
228
发表于 2018-8-11 17:18:22 | 显示全部楼层 |阅读模式

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

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

x
下面是在论坛找到的物品仓库脚本,然后根据自己游戏的特殊性进行了一点修改
有两个问题处理不了,想请教大大们
1. 在256行是取出物品之后刷新界面,刷新不起来~~(会生成一个新的窗口覆盖旧窗口,由于我改成了透明窗口,所有会重叠)
2.存物品会记录当前的指针位置,但是取物品之后会自动返回第一个指针。


  1. #==============================================================================
  2. # 本脚本来自www.66rpg.com,转载和使用请保留此信息
  3. # ikki,根据柳柳真实商店改编。存东西收费1元,取东西不收费。
  4. #==============================================================================
  5. #
  6. # 调用:$scene = Scene_Shop_Va.new(1)  
  7. #删除仓库某物品
  8. # kind = 0~2(0=物品,1=武器,2=防具)
  9. #id = 要消除的物品(武器、防具)ID
  10. #del = 消除数量
  11. #for goods in $game_system.goods[仓库编号]
  12. #  if goods[0] == kind && goods[1] == id
  13. #    goods[2] -= del
  14. #    if goods[2] <= 0
  15. #      $game_system.goods[仓库编号].delete(goods)
  16. #    end
  17. #    break
  18. #  end
  19. #end
  20. #==============================================================================
  21. # ■ Scene_Shop
  22. #------------------------------------------------------------------------------
  23. #  处理商店画面的类。
  24. #==============================================================================
  25. class Game_System
  26. attr_accessor :goods   
  27. alias vaule_shop_66RPG_initialize initialize
  28. def initialize
  29.    vaule_shop_66RPG_initialize
  30.    @goods = []
  31. ###########################################################################
  32.    # 初期的时候的商店物品,编号顺序:种类,ID,可卖数量
  33.    @goods[1] = [[-1,-1,-1]]  
  34. ###########################################################################
  35. end
  36. def shop_change(shop,kind,id,delnumber)
  37.    dl = delnumber
  38.    for dt in $game_system.goods[shop]
  39.      if (dt[0]==kind) and (dt[1]==id)
  40.        dt[2] -= dl
  41.        dt[2] = [dt[2],99].min
  42.        if dt[2] == 0
  43.          $game_system.goods[shop].delete(dt)
  44.        end
  45.        return
  46.      end
  47.    end
  48.    $game_system.goods[shop].push([kind,id,-delnumber])
  49. end
  50. end

  51. class Scene_Shop_Va
  52. def initialize(shop_number)
  53.    # 当前商店编号
  54.    @shop_now = shop_number     
  55. end   
  56. #--------------------------------------------------------------------------
  57. # ● 主处理
  58. #--------------------------------------------------------------------------
  59. def main
  60.    @spriteset = Spriteset_Map.new
  61.    # 生成帮助窗口
  62.    @help_window = Window_Help.new
  63.    # 生成指令窗口
  64.    @command_window = Window_ShopCommand_Va.new
  65.    # 生成金钱窗口
  66.    @gold_window = Window_Gold.new
  67.    @gold_window.x = 480
  68.    @gold_window.y = 64
  69.    # 生成时间窗口
  70.    @dummy_window = Window_Base.new(0, 128, 640, 352)
  71.    # 生成购买窗口
  72.    @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  73.    @buy_window.active = false
  74.    @buy_window.visible = false
  75.    @buy_window.help_window = @help_window
  76.    # 生成卖出窗口
  77.    @sell_window = Window_ShopSell_Va.new
  78.    @sell_window.active = false
  79.    @sell_window.visible = false
  80.    @sell_window.help_window = @help_window
  81.    # 生成数量输入窗口
  82.    @number_window = Window_ShopNumber_Va.new
  83.    @number_window.active = false
  84.    @number_window.visible = false
  85.    # 生成状态窗口
  86.    @status_window = Window_ShopStatus_Va.new
  87.    @status_window.visible = false
  88.    # 执行过渡
  89.    Graphics.transition
  90.    # 主循环
  91.    loop do
  92.      # 刷新游戏画面
  93.      Graphics.update
  94.      # 刷新输入信息
  95.      Input.update
  96.      # 刷新画面
  97.      update
  98.      # 如果画面切换的话就中断循环
  99.      if $scene != self
  100.        break
  101.      end
  102.    end
  103.    # 准备过渡
  104.    Graphics.freeze
  105.    # 释放窗口
  106.    @spriteset.dispose
  107.    @help_window.dispose
  108.    @command_window.dispose
  109.    @gold_window.dispose
  110.    @dummy_window.dispose
  111.    @buy_window.dispose
  112.    @sell_window.dispose
  113.    @number_window.dispose
  114.    @status_window.dispose
  115. end
  116. #--------------------------------------------------------------------------
  117. # ● 刷新画面
  118. #--------------------------------------------------------------------------
  119. def update
  120.    # 刷新窗口
  121.    @help_window.update
  122.    @command_window.update
  123.    @gold_window.update
  124.    @dummy_window.update
  125.    @buy_window.update
  126.    @sell_window.update
  127.    @number_window.update
  128.    @status_window.update
  129.    # 指令窗口激活的情况下: 调用 update_command
  130.    if @command_window.active
  131.      update_command
  132.      return
  133.    end
  134.    # 购买窗口激活的情况下: 调用 update_buy
  135.    if @buy_window.active
  136.      update_buy
  137.      return
  138.    end
  139.    # 卖出窗口激活的情况下: 调用 update_sell
  140.    if @sell_window.active
  141.      update_sell
  142.      return
  143.    end
  144.    # 个数输入窗口激活的情况下: 调用 update_number
  145.    if @number_window.active
  146.      update_number
  147.      return
  148.    end
  149. end
  150. #--------------------------------------------------------------------------
  151. # ● 刷新画面 (指令窗口激活的情况下)
  152. #--------------------------------------------------------------------------
  153. def update_command
  154.    # 按下 B 键的情况下
  155.    if Input.trigger?(Input::B)
  156.      # 演奏取消 SE
  157.      $game_system.se_play($data_system.cancel_se)
  158.      # 切换到地图画面
  159.      $scene = Scene_Map.new
  160.      return
  161.    end
  162.    # 按下 C 键的情况下
  163.    if Input.trigger?(Input::C)
  164.      # 命令窗口光标位置分支
  165.      case @command_window.index
  166.      when 0  # 购买
  167.        # 演奏确定 SE
  168.        $game_system.se_play($data_system.decision_se)
  169.        # 窗口状态转向购买模式
  170.        @command_window.active = false
  171.        @dummy_window.visible = false
  172.        @buy_window.active = true
  173.        @buy_window.visible = true
  174.        @buy_window.refresh
  175.        @status_window.visible = true
  176.      when 1  # 卖出
  177.        # 演奏确定 SE
  178.        $game_system.se_play($data_system.decision_se)
  179.        # 窗口状态转向卖出模式
  180.        @command_window.active = false
  181.        @dummy_window.visible = false
  182.        @sell_window.active = true
  183.        @sell_window.visible = true
  184.        @sell_window.refresh
  185.      when 2  # 取消
  186.        # 演奏确定 SE
  187.        $game_system.se_play($data_system.decision_se)
  188.        # 切换到地图画面
  189.        $scene = Scene_Map.new
  190.      end
  191.      return
  192.    end
  193. end
  194. #--------------------------------------------------------------------------
  195. # ● 刷新画面 (购买窗口激活的情况下)
  196. #--------------------------------------------------------------------------
  197. def update_buy
  198.    # 设置状态窗口的物品
  199.    @status_window.item = @buy_window.item
  200.    # 按下 B 键的情况下
  201.    if Input.trigger?(Input::B)
  202.      # 演奏取消 SE
  203.      $game_system.se_play($data_system.cancel_se)
  204.      # 窗口状态转向初期模式
  205.      @command_window.active = true
  206.      @dummy_window.visible = true
  207.      @buy_window.active = false
  208.      @buy_window.visible = false
  209.      @status_window.visible = false
  210.      @status_window.item = nil
  211.      # 删除帮助文本
  212.      @help_window.set_text("")
  213.      return
  214.    end
  215.    
  216.    
  217.    # 按下 C 键的情况下
  218.    if Input.trigger?(Input::C)
  219.      # 获取物品
  220.      @item = @buy_window.item
  221.      # 物品无效的情况下、或者价格在所持金以上的情况下
  222.      if @item == nil# or @item.price > $game_party.gold
  223.        # 演奏冻结 SE
  224.        $game_system.se_play($data_system.buzzer_se)
  225.        return
  226.      end
  227.      # 获取物品所持数
  228.      case @item
  229.      when RPG::Item
  230.        number = $game_party.item_number(@item.id)
  231.      when RPG::Weapon
  232.        number = $game_party.weapon_number(@item.id)
  233.      when RPG::Armor
  234.        number = $game_party.armor_number(@item.id)
  235.      end
  236.      # 如果已经拥有了 99 个情况下
  237.      if number == 99
  238.        # 演奏冻结 SE
  239.        $game_system.se_play($data_system.buzzer_se)
  240.        return
  241.      end
  242.      # 演奏确定 SE
  243.      $game_system.se_play($data_system.decision_se)
  244.      # 计算可以最多购买的数量
  245.      max = @item.price == 0 ? 99 : $game_party.gold / @item.price
  246.      max = [[max, 99 - number].min,@buy_window.item_number].min
  247.      # 窗口状态转向数值输入模式
  248.      #@buy_window.active = false
  249.      #@buy_window.visible = false
  250.      #@number_window.set(@item, max, @item.price)
  251.      #@number_window.active = true
  252.      #@number_window.visible = true
  253.      $game_party.gain_item(@item.id, 1)
  254.        goods_del(0,@item.id,1)
  255.        @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  256.        @buy_window.help_window = @help_window
  257.        @gold_window.refresh
  258.        @sell_window.refresh
  259.        @status_window.refresh
  260.      end
  261. end
  262. #--------------------------------------------------------------------------
  263. # ● 画面更新 (卖出窗口激活的情况下)
  264. #--------------------------------------------------------------------------
  265. def update_sell
  266.    # 按下 B 键的情况下
  267.    if Input.trigger?(Input::B)
  268.      # 演奏取消 SE
  269.      $game_system.se_play($data_system.cancel_se)
  270.      # 窗口状态转向初期模式
  271.      @command_window.active = true
  272.      @dummy_window.visible = true
  273.      @sell_window.active = false
  274.      @sell_window.visible = false
  275.      @status_window.item = nil
  276.      # 删除帮助文本
  277.      @help_window.set_text("")
  278.      return
  279.    end
  280.    # 按下 C 键的情况下
  281.    if Input.trigger?(Input::C)
  282.      # 获取物品
  283.      @item = @sell_window.item
  284.      case @item
  285.      when RPG::Item
  286.        kind = 0
  287.      when RPG::Weapon
  288.        kind = 1
  289.      when RPG::Armor
  290.        kind = 2
  291.      end
  292.      goods_num = 0
  293.      for goods in $game_system.goods[@shop_now]
  294.        if goods[0] == kind && goods[1] == @item.id
  295.          goods_num = goods[2]
  296.          break
  297.        end
  298.      end
  299.      # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  300.      if @item == nil || goods_num >= 99# or @item.price == 0  #########加了数量判定
  301.        # 演奏冻结 SE
  302.        $game_system.se_play($data_system.buzzer_se)
  303.        return
  304.      end
  305.      # 演奏确定 SE
  306.      $game_system.se_play($data_system.decision_se)
  307.      # 获取物品的所持数
  308.      case @item
  309.      when RPG::Item
  310.        number = $game_party.item_number(@item.id)
  311.      when RPG::Weapon
  312.        number = $game_party.weapon_number(@item.id)
  313.      when RPG::Armor
  314.        number = $game_party.armor_number(@item.id)
  315.      end
  316.      # 最大卖出个数 = 物品的所持数 如果$cangku = number  
  317.      max = number
  318.      # 窗口状态转向个数输入模式
  319.      #@sell_window.active = false
  320.      #@sell_window.visible = false
  321.      #@number_window.set(@item, max, @item.price / 2)
  322.      #@number_window.active = true
  323.      #@number_window.visible = true
  324.      #@status_window.visible = true
  325.      $game_party.lose_item(@item.id, 1)
  326.        goods_del(0,@item.id,-1)
  327.        @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  328.        @buy_window.active = false
  329.        @buy_window.visible = false
  330.        @buy_window.help_window = @help_window
  331.        @gold_window.refresh
  332.        @sell_window.refresh
  333.        @status_window.refresh
  334.    end
  335. end
  336. #--------------------------------------------------------------------------
  337. # ● 刷新画面 (个数输入窗口激活的情况下)
  338. #--------------------------------------------------------------------------
  339. def update_number
  340.    # 按下 B 键的情况下
  341.    if Input.trigger?(Input::B)
  342.      # 演奏取消 SE
  343.      $game_system.se_play($data_system.cancel_se)
  344.      # 设置个数输入窗口为不活动·非可视状态
  345.      @number_window.active = false
  346.      @number_window.visible = false
  347.      # 命令窗口光标位置分支
  348.      case @command_window.index
  349.      when 0  # 购买
  350.        # 窗口状态转向购买模式
  351.        @buy_window.active = true
  352.        @buy_window.visible = true
  353.      when 1  # 卖出
  354.        # 窗口状态转向卖出模式
  355.        @sell_window.active = true
  356.        @sell_window.visible = true
  357.        @status_window.visible = false
  358.      end
  359.      return
  360.    end
  361.    # 按下 C 键的情况下
  362.    if Input.trigger?(Input::C)
  363.      # 演奏商店 SE
  364.      $game_system.se_play($data_system.shop_se)
  365.      # 设置个数输入窗口为不活动·非可视状态
  366.      @number_window.active = false
  367.      @number_window.visible = false
  368.      # 命令窗口光标位置分支
  369.      case @command_window.index
  370.      when 0  # 购买
  371.        # 购买处理
  372.        temp = 0
  373.        case @item
  374.        when RPG::Item
  375.          $game_party.gain_item(@item.id, @number_window.number)
  376.        when RPG::Weapon
  377.          $game_party.gain_weapon(@item.id, @number_window.number)
  378.          temp = 1
  379.        when RPG::Armor
  380.          $game_party.gain_armor(@item.id, @number_window.number)
  381.          temp = 2
  382.        end
  383.        # 刷新各窗口
  384.        goods_del(temp,@item.id,@number_window.number)
  385.        @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  386.        @buy_window.active = false
  387.        @buy_window.visible = false
  388.        @buy_window.help_window = @help_window
  389.        @gold_window.refresh
  390.        @sell_window.refresh
  391.        @status_window.refresh
  392.        # 窗口状态转向购买模式
  393.        @buy_window.active = true
  394.        @buy_window.visible = true
  395.      when 1  # 卖出
  396.        # 卖出处理
  397.        temp = 0
  398.        case @item
  399.        when RPG::Item
  400.          $game_party.lose_item(@item.id, @number_window.number)
  401.        when RPG::Weapon
  402.          $game_party.lose_weapon(@item.id, @number_window.number)
  403.          temp = 1
  404.        when RPG::Armor
  405.          $game_party.lose_armor(@item.id, @number_window.number)
  406.          temp = 2
  407.        end
  408.        # 刷新各窗口
  409.        goods_del(temp,@item.id,-@number_window.number)
  410.        @buy_window = Window_ShopBuy_Va.new($game_system.goods[@shop_now])
  411.        @buy_window.active = false
  412.        @buy_window.visible = false
  413.        @buy_window.help_window = @help_window
  414.        @gold_window.refresh
  415.        @sell_window.refresh
  416.        @status_window.refresh
  417.        # 窗口状态转向卖出模式
  418.        @sell_window.active = true
  419.        @sell_window.visible = true
  420.        @status_window.visible = false
  421.      end
  422.      return
  423.    end
  424. end
  425. # 删除可出售商品内容
  426. def goods_del(kind,id,delnumber)
  427.    dl = delnumber
  428.    for dt in $game_system.goods[@shop_now]
  429.      if (dt[0]==kind) and (dt[1]==id)
  430.        dt[2] -= dl
  431.        dt[2] = [dt[2],99].min
  432.        if dt[2] == 0
  433.          $game_system.goods[@shop_now].delete(dt)
  434.        end
  435.        return
  436.      end
  437.    end
  438.    $game_system.goods[@shop_now].push([kind,id,-delnumber])
  439. end
  440. end

  441. #==============================================================================
  442. # ■ Window_ShopBuy_Va
  443. #------------------------------------------------------------------------------
  444. #  商店画面、浏览显示可以购买的商品的窗口。
  445. #==============================================================================

  446. class Window_ShopBuy_Va < Window_Selectable
  447. attr_accessor :shop_goods
  448. #--------------------------------------------------------------------------
  449. # ● 初始化对像
  450. #     shop_goods : 商品
  451. #--------------------------------------------------------------------------
  452. def initialize(shop_goods)
  453.    super(0, 128, 640, 352)
  454.    @column_max = 3
  455.    @shop_goods = shop_goods
  456.    refresh
  457.    self.index = 0
  458. end
  459. #--------------------------------------------------------------------------
  460. # ● 获取物品
  461. #--------------------------------------------------------------------------
  462. def item
  463.    return @data[self.index]
  464. end
  465. #--------------------------------------------------------------------------
  466. # ● 获取物品
  467. #--------------------------------------------------------------------------
  468. def item_number
  469.    return @data_number[self.index]
  470. end
  471. #--------------------------------------------------------------------------
  472. # ● 刷新
  473. #--------------------------------------------------------------------------
  474. def refresh
  475.    if self.contents != nil
  476.      self.contents.dispose
  477.      self.contents = nil
  478.    end
  479.    @data = []
  480.    @data_number = []
  481.    for goods_item in @shop_goods
  482.      case goods_item[0]
  483.      when 0
  484.        item = $data_items[goods_item[1]]
  485.      when 1
  486.        item = $data_weapons[goods_item[1]]
  487.      when 2
  488.        item = $data_armors[goods_item[1]]
  489.      end
  490.      if (item != nil) and (goods_item[2] != 0)
  491.        @data.push(item)
  492.        @data_number.push(goods_item[2])
  493.      else
  494.        @data.delete(item)
  495.      end
  496.    end
  497.    # 如果项目数不是 0 就生成位图、描绘全部项目
  498.    @item_max = @data.size
  499.    if @item_max > 0
  500.      self.contents = Bitmap.new(width - 32, row_max * 32)
  501.      for i in 0...@item_max
  502.        draw_item(i)
  503.      end
  504.    end
  505. end
  506. #--------------------------------------------------------------------------
  507. # ● 描绘羡慕
  508. #     index : 项目编号
  509. #--------------------------------------------------------------------------
  510. def draw_item(index)
  511.    item = @data[index]
  512.    # 获取物品所持数
  513.    case item
  514.    when RPG::Item
  515.      number = $game_party.item_number(item.id)
  516.    when RPG::Weapon
  517.      number = $game_party.weapon_number(item.id)
  518.    when RPG::Armor
  519.      number = $game_party.armor_number(item.id)
  520.    end
  521.    x = 4 + index % 3 * (192 + 32)
  522.    y = index / 3 * 32
  523.    rect = Rect.new(x, y, self.width / @column_max - 32, 32)#rect = Rect.new(x, y, self.width - 32, 32)
  524.    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  525.    bitmap = RPG::Cache.icon(item.icon_name)
  526.    opacity = self.contents.font.color == normal_color ? 255 : 128
  527.    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  528.    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  529. #   self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  530. #   self.contents.draw_text(x + 256, y, 24, 32, @data_number[index].to_s, 2)
  531. #    self.contents.draw_text(x + 180, y, 88, 32, item.price.to_s, 2)
  532. end
  533. #--------------------------------------------------------------------------
  534. # ● 刷新帮助文本
  535. #--------------------------------------------------------------------------
  536. def update_help
  537.    @help_window.set_text(self.item == nil ? "" : self.item.description)
  538. end
  539. end
  540. #==============================================================================
  541. # ■ Window_ShopCommand_Va
  542. #------------------------------------------------------------------------------
  543. #  商店画面、选择要做的事的窗口
  544. #==============================================================================

  545. class Window_ShopCommand_Va < Window_Selectable
  546. #--------------------------------------------------------------------------
  547. # ● 初始化对像
  548. #--------------------------------------------------------------------------
  549. def initialize
  550.    super(0, 64, 480, 64)
  551.    self.contents = Bitmap.new(width - 32, height - 32)
  552.    @item_max = 3
  553.    @column_max = 3
  554.    @commands = ["取出物品", "存入电脑", "离开"]
  555.    refresh
  556.    self.index = 0
  557. end
  558. #--------------------------------------------------------------------------
  559. # ● 刷新
  560. #--------------------------------------------------------------------------
  561. def refresh
  562.    self.contents.clear
  563.    for i in 0...@item_max
  564.      draw_item(i)
  565.    end
  566. end
  567. #--------------------------------------------------------------------------
  568. # ● 描绘项目
  569. #     index : 项目编号
  570. #--------------------------------------------------------------------------
  571. def draw_item(index)
  572.    x = 4 + index * 160
  573.    self.contents.draw_text(x, 0, 128, 32, @commands[index])
  574. end
  575. end




  576. #==============================================================================
  577. # ■ Window_ShopSell_Va
  578. #------------------------------------------------------------------------------
  579. #  商店画面、浏览显示可以卖掉的商品的窗口。
  580. #==============================================================================

  581. class Window_ShopSell_Va < Window_Selectable
  582. #--------------------------------------------------------------------------
  583. # ● 初始化对像
  584. #--------------------------------------------------------------------------
  585. def initialize
  586.    super(0, 128, 640, 352)
  587.    @column_max = 3
  588.    refresh
  589.    self.index = 0
  590. end
  591. #--------------------------------------------------------------------------
  592. # ● 获取物品
  593. #--------------------------------------------------------------------------
  594. def item
  595.    return @data[self.index]
  596. end
  597. #--------------------------------------------------------------------------
  598. # ● 刷新
  599. #--------------------------------------------------------------------------
  600. def refresh
  601.    if self.contents != nil
  602.      self.contents.dispose
  603.      self.contents = nil
  604.    end
  605.    @data = []
  606.    for i in 1...807#$data_items.size#这个1~807是物品id在这个范围才能被卖掉
  607.      if $game_party.item_number(i) > 0
  608.        @data.push($data_items[i])
  609.      end
  610.    end
  611.    #for i in 1...$data_weapons.size
  612.    #  if $game_party.weapon_number(i) > 0
  613.    #    @data.push($data_weapons[i])
  614.    #  end
  615.    #end
  616.    #for i in 1...$data_armors.size
  617.    #  if $game_party.armor_number(i) > 0
  618.    #    @data.push($data_armors[i])
  619.    #  end
  620.    #end
  621.    # 如果项目数不是 0 就生成位图、描绘全部项目
  622.    @item_max = @data.size
  623.    if @item_max > 0
  624.      self.contents = Bitmap.new(width - 32, row_max * 32)
  625.      for i in 0...@item_max
  626.        draw_item(i)
  627.      end
  628.    end
  629. end
  630. #--------------------------------------------------------------------------
  631. # ● 描绘项目
  632. #     index : 项目标号
  633. #--------------------------------------------------------------------------
  634. def draw_item(index)
  635.    item = @data[index]
  636.    case item
  637.    when RPG::Item
  638.      number = $game_party.item_number(item.id)
  639.    when RPG::Weapon
  640.      number = $game_party.weapon_number(item.id)
  641.    when RPG::Armor
  642.      number = $game_party.armor_number(item.id)
  643.    end
  644.    x = 4 + index % 3 * (192 + 32)
  645.    y = index / 3 * 32
  646.    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  647.    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  648.    bitmap = RPG::Cache.icon(item.icon_name)
  649.    opacity = self.contents.font.color == normal_color ? 255 : 128
  650.    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  651.    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  652.    #self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  653.    #self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  654. end
  655. #--------------------------------------------------------------------------
  656. # ● 刷新帮助文本
  657. #--------------------------------------------------------------------------
  658. def update_help
  659.    @help_window.set_text(self.item == nil ? "" : self.item.description)
  660. end
  661. end



  662. #==============================================================================
  663. # ■ Window_ShopNumber_Va
  664. #------------------------------------------------------------------------------
  665. #  商店画面、输入买卖数量的窗口。
  666. #==============================================================================

  667. class Window_ShopNumber_Va < Window_Base
  668. #--------------------------------------------------------------------------
  669. # ● 初始化对像
  670. #--------------------------------------------------------------------------
  671. def initialize
  672.    super(0, 128, 640, 352)
  673.    self.contents = Bitmap.new(width - 32, height - 32)
  674.    @item = nil
  675.    @max = 1
  676.    @price = 0
  677.    @number = 1
  678. end
  679. #--------------------------------------------------------------------------
  680. # ● 设置物品、最大个数、价格
  681. #--------------------------------------------------------------------------
  682. def set(item, max, price)
  683.    @item = item
  684.    @max = max
  685.    @price = price
  686.    @number = 1
  687.    refresh
  688. end
  689. #--------------------------------------------------------------------------
  690. # ● 被输入的件数设置
  691. #--------------------------------------------------------------------------
  692. def number
  693.    return @number
  694. end
  695. #--------------------------------------------------------------------------
  696. # ● 刷新
  697. #--------------------------------------------------------------------------
  698. def refresh
  699.    self.contents.clear
  700.    draw_item_name(@item, 4, 96)
  701.    self.contents.font.color = normal_color
  702.    self.contents.draw_text(272, 96, 32, 32, "×")
  703.    self.contents.draw_text(308, 96, 24, 32, @number.to_s, 2)
  704.    self.cursor_rect.set(304, 96, 32, 32)
  705. end
  706. #--------------------------------------------------------------------------
  707. # ● 刷新画面
  708. #--------------------------------------------------------------------------
  709. def update
  710.    super
  711.    if self.active
  712.      # 光标右 (+1)
  713.      if Input.repeat?(Input::RIGHT) and @number < @max
  714.        $game_system.se_play($data_system.cursor_se)
  715.        @number += 1
  716.        refresh
  717.      end
  718.      # 光标左 (-1)
  719.      if Input.repeat?(Input::LEFT) and @number > 1
  720.        $game_system.se_play($data_system.cursor_se)
  721.        @number -= 1
  722.        refresh
  723.      end
  724.      # 光标上 (+10)
  725.      if Input.repeat?(Input::UP) and @number < @max
  726.        $game_system.se_play($data_system.cursor_se)
  727.        @number = [@number + 10, @max].min
  728.        refresh
  729.      end
  730.      # 光标下 (-10)
  731.      if Input.repeat?(Input::DOWN) and @number > 1
  732.        $game_system.se_play($data_system.cursor_se)
  733.        @number = [@number - 10, 1].max
  734.        refresh
  735.      end
  736.    end
  737. end
  738. end




  739. #==============================================================================
  740. # ■ Window_ShopStatus_Va
  741. #------------------------------------------------------------------------------
  742. #  商店画面、显示物品所持数与角色装备的窗口。
  743. #==============================================================================

  744. class Window_ShopStatus_Va < Window_Base
  745. #--------------------------------------------------------------------------
  746. # ● 初始化对像
  747. #--------------------------------------------------------------------------
  748. def initialize
  749.    super(640, 128, 272, 352)#640本来是382
  750.    self.contents = Bitmap.new(width - 32, height - 32)
  751.    @item = nil
  752.    refresh
  753. end
  754. #--------------------------------------------------------------------------
  755. # ● 刷新
  756. #--------------------------------------------------------------------------
  757. def refresh
  758.    self.contents.clear
  759.    self.contents.font.color = system_color
  760.    self.contents.font.size -= 4
  761.    self.contents.draw_text(0, 0, 252, 32, "每次存入需要1元的传输费.")
  762.    self.contents.draw_text(0, 34, 252, 32, "取出物品无须任何费用.")
  763.    self.contents.font.size += 4
  764. end
  765. #--------------------------------------------------------------------------
  766. # ● 设置物品
  767. #     item : 新的物品
  768. #--------------------------------------------------------------------------
  769. def item=(item)
  770.    if @item != item
  771.      @item = item
  772.      refresh
  773.    end
  774. end
  775. end
复制代码

Lv5.捕梦者

梦石
0
星屑
37641
在线时间
5311 小时
注册时间
2006-11-10
帖子
6541
发表于 2018-8-11 17:24:10 | 显示全部楼层
本帖最后由 灯笼菜刀王 于 2018-8-11 17:26 编辑

重复生成实例的关系, 非要这样做的话, 先把之前的窗口释放掉再生成

256行前面加一句
if @buy_window != nil then ; @buy_window.dispose ; @buy_window = nil ; end

点评

大大厉害,第二个问题也能帮忙解决吗*-*  发表于 2018-8-11 17:57

评分

参与人数 1星屑 +50 收起 理由
RyanBern + 50 精品文章

查看全部评分

回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

遠航の猫咪

梦石
3
星屑
22393
在线时间
2335 小时
注册时间
2005-10-15
帖子
1160

开拓者

发表于 2018-8-11 20:09:06 | 显示全部楼层
如果冲突太大,你可以试试这个仓库系统,(几乎)是用纯事件实现的
https://rpg.blue/thread-404988-1-1.html
SailCat (小猫子·要开心一点) 共上站 24 次,发表过 11 篇文章 上 次 在: [2006年01月28日11:41:18 星期六] 从 [162.105.120.91] 到本站一游。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-3-29 20:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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