| 赞 | 3 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2017-7-16 |
| 在线时间 | 66 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 66 小时
- 注册时间
- 2015-4-1
- 回帖
- 8
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 RyanBern 于 2015-8-27 14:17 编辑
我用的是和哆啦A梦解救小夫上面一样的银行脚本,要输入:“$scene = Scene_Bank.new”才会生效,但是每次都显示银行脚本31行发生NameError,大神们能不能教教我
脚本:
- #银行脚本
- class Game_Party
- attr :cunkuan,true
- attr :daikuan,true
- attr :dy_item
- attr :items
- alias old_i initialize
- def initialize
- old_i
- @daikuan = 0
- @cunkuan = 0
- @dy_item = []
- end
- def item_empty?
- return @items.empty?
- end
- def gain_dyitem(item)
- # 更新 hash 的个数数据
- if item.id > 0
- if @dy_item.size<=8
- @dy_item.push(item)
- else
- return false
- end
- end
- end
- end
- #场景_银行定义
- class Scene_Bank
- def initialize
- @list_window = Window_HCommand.new(160,["存款","取款","贷款","还款"],416)
- @list_window.y = 64
- @temp_window = Window_Base.new(0,0,160,64)
- @temp_window.contents = Bitmap.new(160 - 32, 64 - 32)
- @temp_window.contents.font.color = Color.new(192, 224, 255, 255)
- @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
- @statu_window = Window_Bank.new
- @statu_window.x = 640 - 160
- @sell_window = Window_BankSell.new
- @sell_window.active = false
- @sell_window.index = -1
- @bin_window = Window_BankInputNumber.new(7)
- @bin_window.active = false
- @bin_window.visible = false
- @statu = nil
- end
- def main
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入情报
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 过渡
- Graphics.freeze
- @list_window.dispose
- @temp_window.dispose
- @statu_window.dispose
- @sell_window.dispose
- end
- def update
- @sell_window.update
- @list_window.update
- @statu_window.update
- @temp_window.update
- @bin_window.update
- if @sell_window.active == true
- update_sell
- return
- end
- if @list_window.active == true
- update_list
- return
- end
- if @bin_window.active == true
- update_bin
- return
- end
- end
- def update_list
- if @sell_window.item_max == 0
- @list_window.disable_item(2)
- else
- @list_window.draw_item(2)
- end
- 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 @list_window.index
- when 0 # 存款
- @temp_window.contents.clear
- @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
- @temp_window.update
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- @bin_window.visible = true
- @bin_window.active = true
- @list_window.active = false
- @statu = :ck
- when 1 # 取款
- @temp_window.contents.clear
- @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
- @temp_window.update
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- @bin_window.visible = true
- @bin_window.active = true
- @list_window.active = false
- @statu = :qk
- when 2 # 贷款
- unless @sell_window.item_max == 0
- @temp_window.contents.clear
- @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
- @temp_window.update
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 激活状态窗口
- @list_window.active = false
- @sell_window.active = true
- @sell_window.index = 0
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- when 3 # 还款
- @temp_window.contents.clear
- @temp_window.contents.draw_text(0,0,32*6,32,"你要干什么?")
- @temp_window.update
- $game_system.se_play($data_system.decision_se)
- if $game_party.gold >= $game_party.daikuan
- $game_party.lose_gold($game_party.daikuan)
- $game_party.daikuan = 0
- $game_party.dy_item.each {|value|
- case value
- when RPG::Item
- $game_party.gain_item(value.id,1)
- when RPG::Weapon
- $game_party.gain_weapon(value.id,1)
- when RPG::Armor
- $game_party.gain_armor(value.id,1)
- end
- }
- $game_party.dy_item.clear
- @statu_window.refresh
- @sell_window.refresh
- else
- @temp_window.contents.clear
- @temp_window.contents.draw_text(0,0,32*6,32,"没有足够现金")
- @temp_window.update
- end #if
- end #case
- end #if
- end#def(被end搞晕了)
- def update_sell
- if @sell_window.item_max == 0
- @sell_window.active = false
- @sell_window.index = -1
- @list_window.active = true
- end
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- @sell_window.active = false
- @sell_window.index = -1
- @list_window.active = true
- return
- end
- if Input.trigger?(Input::C)
- unless @sell_window.item_max == 0
- $game_system.se_play($data_system.decision_se)
- dyitem = @sell_window.item
- unless dyitem.price <=0
- if $game_party.dy_item.size <800000
- case dyitem
- when RPG::Item
- $game_party.gain_item(dyitem.id ,-1)
- when RPG::Weapon
- $game_party.gain_weapon(dyitem.id ,-1)
- when RPG::Armor
- $game_party.gain_armor(dyitem.id,-1)
- end
- $game_party.gain_dyitem(dyitem)
- $game_party.gain_gold((dyitem.price * 0.8).to_i)
- $game_party.daikuan = $game_party.daikuan + (dyitem.price * 0.8).to_i
- @statu_window.refresh
- @sell_window.index = 0
- @sell_window.refresh
- else
- @temp_window.contents.clear
- @temp_window.contents.draw_text(0,0,32*6,32,"抵押达到上限")
- @temp_window.update
- end
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end #unless
- end #if
- end #def
- def update_bin
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- @bin_window.active = false
- @bin_window.visible = false
- @list_window.active = true
- return
- end
- if Input.trigger?(Input::C)
- $game_system.se_play($data_system.decision_se)
- @bin_window.active = false
- @bin_window.visible = false
- @list_window.active = true
- if @statu == :ck
- if $game_party.gold < @bin_window.number
- @temp_window.contents.clear
- @temp_window.contents.draw_text(0,0,32*6,32,"现金不足")
- @temp_window.update
- return
- else
- $game_party.gain_gold([email]-@bin_window.number[/email])
- $game_party.cunkuan += @bin_window.number
- @statu_window.refresh
- return
- end
- end
- if @statu == :qk
- if $game_party.cunkuan < @bin_window.number
- @temp_window.contents.clear
- @temp_window.contents.draw_text(0,0,32*6,32,"存款不足")
- @temp_window.update
- return
- else
- $game_party.gain_gold(@bin_window.number)
- $game_party.cunkuan -= @bin_window.number
- @statu_window.refresh
- return
- end
- end
- end
- end
- end
复制代码 |
|