赞 | 0 |
VIP | 4 |
好人卡 | 4 |
积分 | 1 |
经验 | 21393 |
最后登录 | 2017-7-15 |
在线时间 | 586 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 52
- 在线时间
- 586 小时
- 注册时间
- 2012-5-31
- 帖子
- 768
|
本帖最后由 亿万星辰 于 2012-10-31 20:46 编辑
- class Scene_Compose
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize
- # 生成帮助窗口
- @help_window = Window_Help.new
- #显示图片菜单
- @dajao_1 = Sprite.new
- @dajao_1.bitmap = Bitmap.new("Graphics/Windowskins/dajao")
- @dajao_1.x = 150
- @dajao_1.y = 50
- # 生成命令窗口
- @command_window = Window_ComposeCommand.new
- @command_window.active = false
- # 生成左方窗口
- @item_window = Window_ComposeLeft.new
- @item_window.active = true
- @item_window.windowskin = Bitmap.new("Graphics/Windowskins/006-Blue")
- @item_window.help_window = @help_window
- # 生成右方窗口
- @forge_window = Window_ComposeRight.new([])
- @forge_window.active = false
- @forge_window.help_window = @help_window
- # 初始化配方与合成区
- @formulas = $game_system.formulas
- @products = $game_system.products
- @forge = []
- @products_temp = []
- end
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入情报
- Input.update
- # 刷新画面
- update
- # 如果画面被切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @dajao_1.dispose
- @dajao_1.bitmap.dispose
- @command_window.dispose
- @item_window.dispose
- @forge_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- @help_window.update
- @dajao_1.update
- @command_window.update
- @item_window.update
- @forge_window.update
- if @command_window.active
- update_command
- return
- end
- if @item_window.active
- update_item
- return
- end
- if @forge_window.active
- update_forge
- return
- end
- return
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面(指令窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_command
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- abort
- # 切换到地图画面
- $scene = Scene_Map.new
- return
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 命令窗口光标位置分支
- case @command_window.index
- when 0 # 更改材料
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 窗口状态转向物品窗口
- @command_window.active = false
- @item_window.active = true
- @forge_window.active = false
- when 1 # 合成
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 执行合成命令
- if $game_temp.forge != []
- compose
- end
- when 2 # 放弃合成
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 放弃合成
- abort
- when 3 # 离开
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 放弃合成
- abort
- # 切换到地图画面
- $scene = Scene_Map.new
- end
- return
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面(物品窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_item
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到指令窗口
- @item_window.active = false
- @command_window.active = true
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 获取物品
- @item = @item_window.item
- # 获取物品的所持数
- case @item
- when RPG::Item
- number = $game_party.item_number(@item.id)
- typetemp = 0
- when RPG::Weapon
- number = $game_party.weapon_number(@item.id)
- typetemp = 1
- when RPG::Armor
- number = $game_party.armor_number(@item.id)
- typetemp = 2
- end
- if number != nil
- # 更改合成窗口的物品
- case @item
- when RPG::Item
- $game_party.lose_item(@item.id, 1)
- when RPG::Weapon
- $game_party.lose_weapon(@item.id, 1)
- when RPG::Armor
- $game_party.lose_armor(@item.id, 1)
- end
- forge_change(typetemp, @item.id, 1)
- # 刷新各窗口
- @item_window.update
- @help_window.update
- @forge_window.update
- @item_window.refresh
- @forge_window.refresh
- end
- end
- # 按下 右方向键 的情况
- #if Input.trigger?(Input::RIGHT)
- # 切换到合成窗口
- # @item_window.active = false
- #@forge_window.active = true
- #end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面(合成窗口激活的情况下)
- #--------------------------------------------------------------------------
- def update_forge
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 切换到指令窗口
- @forge_window.active = false
- @command_window.active = true
- @help_window.set_text("")
- return
- end
- # 按下 C 键的情况
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 获取物品
- @item = @forge_window.item
- # 获取物品的所持数
- case @item
- when RPG::Item
- number = @forge_window.item_number
- typetemp = 0
- when RPG::Weapon
- number = @forge_window.item_number
- typetemp = 1
- when RPG::Armor
- number = @forge_window.item_number
- typetemp = 2
- end
- if number != nil
- # 更改合成窗口的物品
- case @item
- when RPG::Item
- $game_party.gain_item(@item.id, 1)
- when RPG::Weapon
- $game_party.gain_weapon(@item.id, 1)
- when RPG::Armor
- $game_party.gain_armor(@item.id, 1)
- end
- #p number
- forge_change(typetemp, @item.id, -1)
- # 刷新各窗口
- @item_window.refresh
- @forge_window.refresh
- @help_window.update
- @item_window.update
- @forge_window.update
- end
- end
- # 按下 左方向键 的情况下
- #if Input.trigger?(Input::LEFT)
- # 切换到合成窗口
- #@forge_window.active = false
- #@item_window.active = true
- #end
- end
- #--------------------------------------------------------------------------
- # ● 更改合成窗口物品
- #--------------------------------------------------------------------------
- def forge_change(type,id,number)
- quantity = number
- for item in $game_temp.forge
- if (item[0]==type) and (item[1]==id)
- item[2] = [item[2] += quantity,99].min
- if item[2] == 0
- $game_temp.forge.delete(item)
- end
- return
- end
- end
- $game_temp.forge.push([type,id,number])
- end
- #--------------------------------------------------------------------------
- # ● 放弃合成
- #--------------------------------------------------------------------------
- def abort
- # 将合成窗口中的物品转移至物品窗口中
- for item in $game_temp.forge
- # 判断物品类型并归还
- case item[0]
- when 0
- $game_party.gain_item(item[1], item[2])
- when 1
- $game_party.gain_weapon(item[1], item[2])
- when 2
- $game_party.gain_armor(item[1], item[2])
- end
- end
- $game_temp.forge = []
- # 刷新各窗口
- @item_window.refresh
- @forge_window.refresh
- end
- #--------------------------------------------------------------------------
- # ● 检测是否有符合的配方
- #--------------------------------------------------------------------------
- def match
- match_one = false
- match_this = false
- # 检测每一个配方
- for i in [email][email protected][/email]
- # 将合成窗口中的物品复制到合成缓存区
- # 注意: 直接使用"="将传引用 导致检测配方是否匹配时合成窗口中物品被删除
- @forge = $game_temp.forge.dup
- # 检测这个配方中每一项材料
- for ingredient in @formulas[i]
- match_this = true
- # 合成区中没有此项材料的情况
- unless @forge.include?(ingredient)
- match_this = false
- break
- end
- # 从合成区中暂时删除这项材料
- @forge.delete(ingredient)
- end
- if match_this == false
- next
- end
- # 检测合成区中是否还有配方外的材料剩余
- unless @forge == []
- match_this = false
- end
- # 满足这一个配方的情况
- if match_this == true
- match_one = true
- # 获取配方的成品
- @products_temp = @products[i]
- break
- end
- end
- return match_one
- end
- #--------------------------------------------------------------------------
- # ● 合成
- #--------------------------------------------------------------------------
- def compose
- # 如果有符合的配方
- if match
- # 将合成窗口中的材料改变为成品
- $game_temp.forge = []
- for i in [email]0...@products_temp.size[/email]
- forge_change(@products_temp[i][0], @products_temp[i][1], @products_temp[i][2])
- end
- if $SE_Compose_Successful != ""
- Audio.se_play($SE_Compose_Successful)
- end
- # 合成失败的情况
- else
- if $SE_Compose_Failed != ""
- Audio.se_play($SE_Compose_Failed)
- end
- if $Ingredient_Lost_When_Fail
- $game_temp.forge = []
- end
- end
- # 刷新各窗口
- @item_window.refresh
- @forge_window.refresh
- end
- end
复制代码 如上脚本,如何在菜单窗口后面显示出地图画面为背呀。试了N次就是不行。
能看见NPC。其它地方全黑的{:2_270:} 求教高手 |
|