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

Project1

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

[已经解决] 如何做出 "第三、第四货币" 的效果?

 关闭 [复制链接]

Lv1.梦旅人

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

Lv2.观梦者

梦石
0
星屑
260
在线时间
1373 小时
注册时间
2005-10-16
帖子
5113

贵宾

2
发表于 2011-9-3 18:25:39 | 只看该作者
我觉得你写的地址里那个可以实现这个功能啊,你具体的功能是什么?

点评

对了!话说怎么弄签名档啊?  发表于 2011-9-3 19:15
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
86 小时
注册时间
2011-1-26
帖子
74
3
 楼主| 发表于 2011-9-3 19:12:03 | 只看该作者
本帖最后由 『89°の』 于 2011-9-3 19:12 编辑

据体功能就是 用 其他货币买的东西用另一种货币是无法卖掉的。。
如果用那个那么他的金钱设置是用原货币买的价钱/2=用该货币买的价钱额。。



                             ------呼,说完了。。不知道你有没有听懂额。。
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
260
在线时间
1373 小时
注册时间
2005-10-16
帖子
5113

贵宾

4
发表于 2011-9-3 19:19:54 | 只看该作者
这个功能需要重新写物品和商店部分,而不单是货币~
基本上就是要把物品区分为某几类,而不同种类的商店只能回收不同种类的物品,对应不同种类的货币。
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
86 小时
注册时间
2011-1-26
帖子
74
5
 楼主| 发表于 2011-9-3 19:21:36 | 只看该作者
额,可我是脚本盲的说、、、、
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
110
在线时间
153 小时
注册时间
2008-5-25
帖子
585
6
发表于 2011-9-3 22:15:43 | 只看该作者
脚本盲就用事件来实现。
[color=DimGray]TransFormer4[/color]
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
86 小时
注册时间
2011-1-26
帖子
74
7
 楼主| 发表于 2011-9-4 08:09:16 | 只看该作者
反正我记得以前就有一种脚本,可以做出第三货币效果,就是把SG 改成 TG ,然后变量和名字都改一下。然后.......  可是这个现在搜索不到了。。。
回复

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
77 小时
注册时间
2011-7-31
帖子
142
8
发表于 2011-9-4 08:14:59 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
86 小时
注册时间
2011-1-26
帖子
74
9
 楼主| 发表于 2011-9-4 10:32:54 | 只看该作者
|.мīss.чou 发表于 2011-9-4 08:14
用事件也一样可以实现啊……建一个事件商店 然后条件分支用那个物品去买你要的物品 就可以了!就是没那么华 ...

真是的,这样子用别的货币买的东西可以用 另一种货币买来啊!这都不知道额!

点评

想做“伸手党” 你还早一万年!人家伸手党!可以服服帖帖的让高手帮忙写脚本!就你这种态度!我有那脚本!就是不发给你!  发表于 2011-9-4 20:00
你懂不懂什么叫做指定交易?想简单又方便 用30VIP求人写脚本吧!不虚心 永远也得不到答案!  发表于 2011-9-4 12:58
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
260
在线时间
1373 小时
注册时间
2005-10-16
帖子
5113

贵宾

10
发表于 2011-9-4 10:40:09 | 只看该作者
问题的难点在于用货币1购买的东西在流通货币2的商店中无法卖掉,这个是关键,而对于不同商店显示不同的货币,确实是简单的一个事件操作~
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-28 04:03

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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