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

Project1

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

[已经解决] 请问多种货币该怎么做?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
126
在线时间
48 小时
注册时间
2016-2-9
帖子
31
跳转到指定楼层
1
发表于 2016-8-18 09:31:16 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 白风少侠 于 2016-8-18 14:19 编辑

{:2_253:} 伸手党总是这么无奈……



我的意思是说除了G之外还有其他的货币,比方说声望、XX币……




各位大神能告诉我修改方法吗?











另外我想问一下【已经解决】按钮什么时候在什么地方出现,我没找到哎……

Lv1.梦旅人

梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
帖子
151
2
发表于 2016-8-18 11:33:08 | 只看该作者
第二货币商店,完全可以照猫画虎添加第三.第四。。。第n货币 商店。
RUBY 代码复制
  1. #使用方法 :在事件商店处理前添加脚本:command_sgshop
  2. SG_ID = 100#存储第二货币的变量编号,把数字加入变量就是增加第二货币
  3. SG_NA = "第二货币"#第二货币的单位
  4. module RPG
  5.   class Weapon
  6.     def sgprice
  7.       arr = @description.split(/SG/)
  8.       return arr[1].to_i if arr[1] != nil
  9.       return 0
  10.     end
  11.     def description
  12.       arr = @description.split(/SG/)
  13.       return arr[0] if arr[1] != nil
  14.       return @description
  15.     end
  16.   end
  17.   class Armor
  18.     def sgprice
  19.       arr = @description.split(/SG/)
  20.       return arr[1].to_i if arr[1] != nil
  21.       return 0
  22.     end
  23.     def description
  24.       arr = @description.split(/SG/)
  25.       return arr[0] if arr[1] != nil
  26.       return @description
  27.     end
  28.   end
  29.   class Item
  30.     def sgprice
  31.       arr = @description.split(/SG/)
  32.       return arr[1].to_i if arr[1] != nil
  33.       return 0
  34.     end
  35.     def description
  36.       arr = @description.split(/SG/)
  37.       return arr[0] if arr[1] != nil
  38.       return @description
  39.     end
  40.   end
  41. end
  42. class Scene_SGShop < Scene_Shop
  43.   def main
  44.     # 生成帮助窗口
  45.     @help_window = Window_Help.new
  46.     # 生成指令窗口
  47.     @command_window = Window_ShopCommand.new
  48.     # 生成金钱窗口
  49.     @gold_window = Window_SGold.new
  50.     @gold_window.x = 480
  51.     @gold_window.y = 64
  52.     # 生成时间窗口
  53.     @dummy_window = Window_Base.new(0, 128, 640, 352)
  54.     # 生成购买窗口
  55.     @buy_window = Window_SGShopBuy.new($game_temp.shop_goods)
  56.     @buy_window.active = false
  57.     @buy_window.visible = false
  58.     @buy_window.help_window = @help_window
  59.     # 生成卖出窗口
  60.     @sell_window = Window_SGShopSell.new
  61.     @sell_window.active = false
  62.     @sell_window.visible = false
  63.     @sell_window.help_window = @help_window
  64.     # 生成数量输入窗口
  65.     @number_window = Window_ShopNumber.new
  66.     @number_window.active = false
  67.     @number_window.visible = false
  68.     # 生成状态窗口
  69.     @status_window = Window_ShopStatus.new
  70.     @status_window.visible = false
  71.     # 执行过渡
  72.     Graphics.transition
  73.     # 主循环
  74.     loop do
  75.       # 刷新游戏画面
  76.       Graphics.update
  77.       # 刷新输入信息
  78.       Input.update
  79.       # 刷新画面
  80.       update
  81.       # 如果画面切换的话就中断循环
  82.       if $scene != self
  83.         break
  84.       end
  85.     end
  86.     # 准备过渡
  87.     Graphics.freeze
  88.     # 释放窗口
  89.     @help_window.dispose
  90.     @command_window.dispose
  91.     @gold_window.dispose
  92.     @dummy_window.dispose
  93.     @buy_window.dispose
  94.     @sell_window.dispose
  95.     @number_window.dispose
  96.     @status_window.dispose
  97.   end
  98.   def update_buy
  99.     # 设置状态窗口的物品
  100.     @status_window.item = @buy_window.item
  101.     # 按下 B 键的情况下
  102.     if Input.trigger?(Input::B)
  103.       # 演奏取消 SE
  104.       $game_system.se_play($data_system.cancel_se)
  105.       # 窗口状态转向初期模式
  106.       @command_window.active = true
  107.       @dummy_window.visible = true
  108.       @buy_window.active = false
  109.       @buy_window.visible = false
  110.       @status_window.visible = false
  111.       @status_window.item = nil
  112.       # 删除帮助文本
  113.       @help_window.set_text("")
  114.       return
  115.     end
  116.     # 按下 C 键的情况下
  117.     if Input.trigger?(Input::C)
  118.       # 获取物品
  119.       @item = @buy_window.item
  120.       # 物品无效的情况下、或者价格在所持金以上的情况下
  121.       if @item == nil or @item.sgprice > $game_variables[SG_ID]
  122.         # 演奏冻结 SE
  123.         $game_system.se_play($data_system.buzzer_se)
  124.         return
  125.       end
  126.       # 获取物品所持数
  127.       case @item
  128.       when RPG::Item
  129.         number = $game_party.item_number(@item.id)
  130.       when RPG::Weapon
  131.         number = $game_party.weapon_number(@item.id)
  132.       when RPG::Armor
  133.         number = $game_party.armor_number(@item.id)
  134.       end
  135.       # 如果已经拥有了 99 个情况下
  136.       if number == 99
  137.         # 演奏冻结 SE
  138.         $game_system.se_play($data_system.buzzer_se)
  139.         return
  140.       end
  141.       # 演奏确定 SE
  142.       $game_system.se_play($data_system.decision_se)
  143.       # 计算可以最多购买的数量
  144.       max = @item.sgprice == 0 ? 99 : $game_variables[SG_ID] / @item.sgprice
  145.       max = [max, 99 - number].min
  146.       # 窗口状态转向数值输入模式
  147.       @buy_window.active = false
  148.       @buy_window.visible = false
  149.       @number_window.set(@item, max, @item.sgprice)
  150.       @number_window.active = true
  151.       @number_window.visible = true
  152.     end
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● 画面更新 (卖出窗口激活的情况下)
  156.   #--------------------------------------------------------------------------
  157.   def update_sell
  158.     # 按下 B 键的情况下
  159.     if Input.trigger?(Input::B)
  160.       # 演奏取消 SE
  161.       $game_system.se_play($data_system.cancel_se)
  162.       # 窗口状态转向初期模式
  163.       @command_window.active = true
  164.       @dummy_window.visible = true
  165.       @sell_window.active = false
  166.       @sell_window.visible = false
  167.       @status_window.item = nil
  168.       # 删除帮助文本
  169.       @help_window.set_text("")
  170.       return
  171.     end
  172.     # 按下 C 键的情况下
  173.     if Input.trigger?(Input::C)
  174.       # 获取物品
  175.       @item = @sell_window.item
  176.       # 设置状态窗口的物品
  177.       @status_window.item = @item
  178.       # 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
  179.       if @item == nil or @item.sgprice == 0
  180.         # 演奏冻结 SE
  181.         $game_system.se_play($data_system.buzzer_se)
  182.         return
  183.       end
  184.       # 演奏确定 SE
  185.       $game_system.se_play($data_system.decision_se)
  186.       # 获取物品的所持数
  187.       case @item
  188.       when RPG::Item
  189.         number = $game_party.item_number(@item.id)
  190.       when RPG::Weapon
  191.         number = $game_party.weapon_number(@item.id)
  192.       when RPG::Armor
  193.         number = $game_party.armor_number(@item.id)
  194.       end
  195.       # 最大卖出个数 = 物品的所持数
  196.       max = number
  197.       # 窗口状态转向个数输入模式
  198.       @sell_window.active = false
  199.       @sell_window.visible = false
  200.       @number_window.set(@item, max, @item.sgprice / 2)
  201.       @number_window.active = true
  202.       @number_window.visible = true
  203.       @status_window.visible = true
  204.     end
  205.   end
  206.   def update_number
  207.     # 按下 B 键的情况下
  208.     if Input.trigger?(Input::B)
  209.       # 演奏取消 SE
  210.       $game_system.se_play($data_system.cancel_se)
  211.       # 设置个数输入窗口为不活动·非可视状态
  212.       @number_window.active = false
  213.       @number_window.visible = false
  214.       # 命令窗口光标位置分支
  215.       case @command_window.index
  216.       when 0  # 购买
  217.         # 窗口状态转向购买模式
  218.         @buy_window.active = true
  219.         @buy_window.visible = true
  220.       when 1  # 卖出
  221.         # 窗口状态转向卖出模式
  222.         @sell_window.active = true
  223.         @sell_window.visible = true
  224.         @status_window.visible = false
  225.       end
  226.       return
  227.     end
  228.     # 按下 C 键的情况下
  229.     if Input.trigger?(Input::C)
  230.       # 演奏商店 SE
  231.       $game_system.se_play($data_system.shop_se)
  232.       # 设置个数输入窗口为不活动·非可视状态
  233.       @number_window.active = false
  234.       @number_window.visible = false
  235.       # 命令窗口光标位置分支
  236.       case @command_window.index
  237.       when 0  # 购买
  238.         # 购买处理
  239.         $game_variables[SG_ID] -= (@number_window.number * @item.sgprice)
  240.         case @item
  241.         when RPG::Item
  242.           $game_party.gain_item(@item.id, @number_window.number)
  243.         when RPG::Weapon
  244.           $game_party.gain_weapon(@item.id, @number_window.number)
  245.         when RPG::Armor
  246.           $game_party.gain_armor(@item.id, @number_window.number)
  247.         end
  248.         # 刷新各窗口
  249.         @gold_window.refresh
  250.         @buy_window.refresh
  251.         @status_window.refresh
  252.         # 窗口状态转向购买模式
  253.         @buy_window.active = true
  254.         @buy_window.visible = true
  255.       when 1  # 卖出
  256.         # 卖出处理
  257.         $game_variables[SG_ID] += (@number_window.number * (@item.sgprice/2))
  258.         case @item
  259.         when RPG::Item
  260.           $game_party.lose_item(@item.id, @number_window.number)
  261.         when RPG::Weapon
  262.           $game_party.lose_weapon(@item.id, @number_window.number)
  263.         when RPG::Armor
  264.           $game_party.lose_armor(@item.id, @number_window.number)
  265.         end
  266.         # 刷新各窗口
  267.         @gold_window.refresh
  268.         @sell_window.refresh
  269.         @status_window.refresh
  270.         # 窗口状态转向卖出模式
  271.         @sell_window.active = true
  272.         @sell_window.visible = true
  273.         @status_window.visible = false
  274.       end
  275.       return
  276.     end
  277.   end
  278. end
  279. #=============
  280. #窗口
  281. #=============
  282. class Window_SGold < Window_Base
  283.   def initialize
  284.     super(0, 0, 160, 64)
  285.     self.contents = Bitmap.new(width - 32, height - 32)
  286.     refresh
  287.   end
  288.   def refresh
  289.     self.contents.clear
  290.     cx = contents.text_size(SG_NA).width
  291.     self.contents.font.color = normal_color
  292.     self.contents.draw_text(4, 0, 120-cx-2, 32, $game_variables[SG_ID].to_s, 2)
  293.     self.contents.font.color = system_color
  294.     self.contents.draw_text(124-cx, 0, cx, 32, SG_NA, 2)
  295.   end
  296. end
  297. class Window_SGShopBuy < Window_ShopBuy
  298.   def draw_item(index)
  299.     item = @data[index]
  300.     # 获取物品所持数
  301.     case item
  302.     when RPG::Item
  303.       number = $game_party.item_number(item.id)
  304.     when RPG::Weapon
  305.       number = $game_party.weapon_number(item.id)
  306.     when RPG::Armor
  307.       number = $game_party.armor_number(item.id)
  308.     end
  309.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
  310.     # 除此之外的情况设置为无效文字色
  311.     if item.sgprice <= $game_variables[SG_ID] and number < 99
  312.       self.contents.font.color = normal_color
  313.     else
  314.       self.contents.font.color = disabled_color
  315.     end
  316.     x = 4
  317.     y = index * 32
  318.     rect = Rect.new(x, y, self.width - 32, 32)
  319.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  320.     bitmap = RPG::Cache.icon(item.icon_name)
  321.     opacity = self.contents.font.color == normal_color ? 255 : 128
  322.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  323.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  324.     self.contents.draw_text(x + 240, y, 88, 32, item.sgprice.to_s, 2)
  325.   end
  326. end
  327. class Window_SGShopSell < Window_ShopSell
  328.   def draw_item(index)
  329.     item = @data[index]
  330.     case item
  331.     when RPG::Item
  332.       number = $game_party.item_number(item.id)
  333.     when RPG::Weapon
  334.       number = $game_party.weapon_number(item.id)
  335.     when RPG::Armor
  336.       number = $game_party.armor_number(item.id)
  337.     end
  338.     # 可以卖掉的显示为普通文字颜色、除此之外设置成无效文字颜色
  339.     if item.sgprice > 0
  340.       self.contents.font.color = normal_color
  341.     else
  342.       self.contents.font.color = disabled_color
  343.     end
  344.     x = 4 + index % 2 * (288 + 32)
  345.     y = index / 2 * 32
  346.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  347.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  348.     bitmap = RPG::Cache.icon(item.icon_name)
  349.     opacity = self.contents.font.color == normal_color ? 255 : 128
  350.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  351.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  352.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  353.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  354.   end
  355. end
  356. class Window_SGShopNumber < Window_ShopNumber
  357.   def refresh
  358.     self.contents.clear
  359.     draw_item_name(@item, 4, 96)
  360.     self.contents.font.color = normal_color
  361.     self.contents.draw_text(272, 96, 32, 32, "×")
  362.     self.contents.draw_text(308, 96, 24, 32, @number.to_s, 2)
  363.     self.cursor_rect.set(304, 96, 32, 32)
  364.     # 描绘合计价格和货币单位
  365.     domination = SG_NA
  366.     cx = contents.text_size(domination).width
  367.     total_price = @price * @number
  368.     self.contents.font.color = normal_color
  369.     self.contents.draw_text(4, 160, 328-cx-2, 32, total_price.to_s, 2)
  370.     self.contents.font.color = system_color
  371.     self.contents.draw_text(332-cx, 160, cx, 32, domination, 2)
  372.   end
  373. end
  374. class Scene_Map
  375.   def call_shop
  376.     # 清除商店调用标志
  377.     $game_temp.shop_calling = false
  378.     # 矫正主角姿势
  379.     $game_player.straighten
  380.     # 切换到商店画面
  381.     if $game_temp.sgshop_calling
  382.       $scene = Scene_SGShop.new
  383.     else
  384.       $scene = Scene_Shop.new
  385.     end
  386.     $game_temp.sgshop_calling = false
  387.   end
  388. end
  389. class Interpreter
  390.   def command_sgshop
  391.     $game_temp.sgshop_calling = true
  392.   end
  393. end
  394. class Game_Temp
  395.   attr_accessor:sgshop_calling
  396.   alias initialize_new initialize
  397.   def initialize
  398.     initialize_new
  399.     @sgshop_calling = false
  400.   end
  401. end

捕获.PNG (30.18 KB, 下载次数: 6)

捕获.PNG

评分

参与人数 1梦石 +1 收起 理由
RyanBern + 1 认可答案

查看全部评分

Vanyogin
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
126
在线时间
48 小时
注册时间
2016-2-9
帖子
31
3
 楼主| 发表于 2016-8-18 14:17:35 | 只看该作者
2357691704 发表于 2016-8-18 11:33
第二货币商店,完全可以照猫画虎添加第三.第四。。。第n货币 商店。
#使用方法 :在事件商店处理前添加脚本 ...

谢谢你的帮助{:2_249:}
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-22 04:37

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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