赞 | 5 |
VIP | 71 |
好人卡 | 22 |
积分 | 6 |
经验 | 32145 |
最后登录 | 2013-8-9 |
在线时间 | 184 小时 |
Lv2.观梦者 天仙
- 梦石
- 0
- 星屑
- 620
- 在线时间
- 184 小时
- 注册时间
- 2008-4-15
- 帖子
- 5023
|
主脚本
- class Scene_NameGen
- def main
- # 产生命令窗口
- @command_window = Window_Command.new(250, ["输出为文本", "选择", "离开", "设定", "重新产生"])
- @command_window.x = 320 - @command_window.width
- @command_window.y = 240 - @command_window.height
- @command_window.z = 300
- @command_window.index = 0
- @command_window.visible = false
- @command_window.active = false
-
- # 产生询问窗口
- @ask_window = Window_Base.new(120, 188, 400, 64)
- @ask_window.contents = Bitmap.new(368, 32)
- string = "要生产哪种名称:"
- @ask_window.contents.font.name = "SimHei"
- @ask_window.contents.font.size = 24
- @ask_window.contents.draw_text(4, 0, 368, 32, string)
- @ask_window.visible = true
- @ask_window.z = 1500
-
- # 产生选择窗口
- @select_window = Window_Command.new(200, ["随机", "武器/武功", "物品", "装备", "技能", "自定义尾字"])
- @select_window.visible = true
- @select_window.active = true
- @select_window.index = 0
- @select_window.x = 290
- @select_window.y = 235
- @select_window.z = 1500
-
- # 产生询问窗口
- @check_window = Window_Base.new(120, 188, 400, 64)
- @check_window.contents = Bitmap.new(368, 32)
- string = "已选择名称, 是否要放弃?"
- @check_window.contents.font.name = "SimHei"
- @check_window.contents.font.size = 24
- @check_window.contents.draw_text(4, 0, 368, 32, string)
- @check_window.visible = false
- @check_window.z = 1500
-
- # 产生选择窗口
- @check_sel_window = Window_Command.new(200, ["放弃", "输出为文本"])
- @check_sel_window.visible = false
- @check_sel_window.active = false
- @check_sel_window.index = 0
- @check_sel_window.x = 290
- @check_sel_window.y = 235
- @check_sel_window.z = 1500
- # 产生尾字选择窗口
- @end_select_window = Window_EndSel.new
- @end_select_window.index = 0
- @end_select_window.visible = false
- @end_select_window.active = false
- @end_select_window.z = 300
-
- # 产生名称产生窗口
- @name_window = Window_NameGen.new
- @name_window.x = 0
- @name_window.y = 0
- @name_window.index = -5
- @name_window.active = false
-
- # 执行过渡
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入情报
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 准备过渡
- Graphics.freeze
- # 释放窗口
- @command_window.dispose
- @ask_window.dispose
- @select_window.dispose
- @name_window.dispose
- @end_select_window.dispose
- # 如果在标题画面切换中的情况下
- if $scene.is_a?(Scene_Title)
- # 淡入淡出画面
- Graphics.transition
- Graphics.freeze
- end
- end
-
- #--------------------------------------------------------------------------
- # * 更新画面
- #--------------------------------------------------------------------------
- def update
- # 更新窗口
- @command_window.update
- @ask_window.update
- @select_window.update
- @name_window.update
- @end_select_window.update
- @check_sel_window.update
-
- # 命令窗口被激活的情况下: 调用 update_command
- if @command_window.active
- update_command
- return
- end
- # 选择窗口被激活的情况下: 调用 update_select
- if @select_window.active
- update_select
- return
- end
-
- # 尾字选择窗口被激活的情况下: 调用 update_select
- if @end_select_window.active
- update_end
- return
- end
-
- # 离开确认被激活的情况下: 调用 update_select
- if @check_sel_window.active
- update_check
- return
- end
-
- # 选择窗口被激活的情况下: 调用 update_name
- if @name_window.active
- update_name
- return
- end
- end
-
- # 更新命令窗口
- def update_command
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- case @command_window.index
- when 0 # 输出为文本
- @name_window.output_text
- @command_window.visible = false
- @command_window.active = false
- @name_window.active = true
- when 1 # 选择
- @name_window.active = true
- @name_window.index = 0
- @command_window.visible = false
- @command_window.active = false
- when 2 # 离开
- if @name_window.exit_program?
- exit
- else
- @check_sel_window.active = true
- @check_sel_window.visible = true
- @check_window.visible = true
- @command_window.active = false
- end
- when 3 # 设定
- $scene = Scene_NameGen_Setup.new
- when 4 # 重新产生
- @ask_window.visible = true
- @select_window.active = true
- @select_window.visible = true
- @command_window.visible = false
- @command_window.active = false
- end
- return
- end # end if Input.trigger?(Input::C)
-
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 无效化命令窗口
- @command_window.visible = false
- @command_window.active = false
- @name_window.active = true
- return
- end
- end
-
- # 更新选择窗口
- def update_select
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 產生名稱
- unless @select_window.index == 5
- @name_window.generate(@select_window.index)
- @name_window.active = true
- else
- @end_select_window.active = true
- @end_select_window.visible = true
- end
-
- # 无效化选择窗口
- @ask_window.visible = false
- @select_window.active = false
- @select_window.visible = false
- return
- end # end if Input.trigger?(Input::C)
- end
-
- def update_end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 获取尾字
- end_word = @end_select_window.end_word
- if end_word != "武器/武功" and end_word != "物品" and
- end_word != "裝備" and end_word != "技能"
- $end_word = @end_select_window.end_word
- # 产生名称
- @name_window.generate(@end_select_window.type(@end_select_window.index))
- @name_window.active = true
- # 无效化尾字选择窗口
- @end_select_window.active = false
- @end_select_window.visible = false
- else
- # 演奏冻结 SE
- $game_system.se_play($data_system.buzzer_se)
- end
- return
- end
-
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 无效化尾字选择窗口
- @end_select_window.active = false
- @end_select_window.visible = false
- # 有效化命令窗口
- @ask_window.visible = true
- @select_window.active = true
- @select_window.visible = true
- @select_window.index = 5
- return
- end
- end
-
- def update_name
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- # 纪录文字
- @name_window.input_text(@name_window.index)
- return
- end
-
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 有效化命令窗口
- @command_window.active = true
- @command_window.visible = true
- # 无效化名称产生窗口
- @name_window.active = false
- @name_window.index = -5
- return
- end
- end
-
- def update_check
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- case @check_sel_window.index
- when 0 # 放弃
- exit
- when 1 # 输出为文本
- @name_window.output_text
- @command_window.visible = false
- @command_window.visible = false
- @name_window.active = false
- end
- return
- end
-
- # 按下 B 键的情况下
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- # 有效化命令窗口
- @command_window.active = true
- @command_window.visible = true
- # 无效化产生窗口
- @check_sel_window.active = false
- @check_sel_window.visible = false
- @check_window.visible = false
- return
- end
- end
- end
- class Window_NameGen < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化窗口
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 640, 480)
- @column_max = 4
- @item_max = $generator
- @name_selected = ""
- self.index = 0
- self.contents = Bitmap.new(width - 32, $generator / 4 * 32)
- end
- # 生产
- def generate(etype)
- self.contents.font.color = system_color
- self.contents.clear
-
- # 資料分析
- i = 0
- @name = []
- type = etype
- material_1_rand = $material_1.size
- material_2_rand = $material_2.size
- color_rand = $color_name.size
- chara_rand = $chara_name.size
- pattern_rand = $pattern_name.size
- weapon_rand = $weapon_name.size
- item_rand = $item_name.size
- equip_rand = $equip_name.size
- skill_rand = $skill_name.size
- doubled_rand = $doubled_name.size
- trans_rand = $trans_name.size
- trans2_rand = $trans_name_2.size
- while i < $generator
- # 确认产生类型尾字
- type = rand(4)+1 if etype == 0
- case type
- when 1
- end_word = $weapon_name[rand(weapon_rand)]
- when 2
- end_word = $item_name[rand(item_rand)]
- when 3
- end_word = $equip_name[rand(equip_rand)]
- when 4
- end_word = $skill_name[rand(skill_rand)]
- when 51, 52, 53, 54
- end_word = $end_word
- end
-
- # 设置颜色
- case type
- when 1, 51
- self.contents.font.color = $weapon_color
- when 2, 52
- self.contents.font.color = $item_color
- when 3, 53
- self.contents.font.color = $equip_color
- when 4, 54
- self.contents.font.color = $skill_color
- end
-
- # 随机数选择文字
- mat_word_1a = $material_1[rand(material_1_rand)]
- mat_word_2a = $material_2[rand(material_2_rand)]
- mat_word_1b = $material_1[rand(material_1_rand)]
- mat_word_2b = $material_2[rand(material_2_rand)]
- color_word = $color_name[rand(color_rand)]
- chara_word = $chara_name[rand(chara_rand)]
- pattern_word = $pattern_name[rand(pattern_rand)]
- trans_word = $trans_name[rand(trans_rand)]
-
- # 随机数排列
- case rand(15)
- when 0, 1, 2
- case rand(4)
- when 0
- mat_word = mat_word_1a + mat_word_2a
- when 1
- mat_word = mat_word_1b + mat_word_2b
- when 2
- mat_word = mat_word_1a + mat_word_2b
- else
- mat_word = mat_word_1b + mat_word_2a
- end
- when 3, 4, 5
- mat_word = mat_word_2a + mat_word_1a
- when 6, 7
- mat_word = mat_word_2a
- when 8, 9
- mat_word = mat_word_1a
- when 10
- mat_word = mat_word_1a + mat_word_2a + mat_word_1b
- when 11, 12, 13, 14, 15
- case rand(4)
- when 0
- mat_word = $doubled_name[rand(doubled_rand)]
- when 1
- mat_word = $doubled_name[rand(doubled_rand)] + $doubled_name[rand(doubled_rand)]
- when 2
- mat_word = $doubled_name[rand(doubled_rand)] + mat_word_1a
- when 3
- mat_word = $doubled_name[rand(doubled_rand)] + mat_word_2a
- when 4
- mat_word = $doubled_name[rand(doubled_rand)] + mat_word_1a + mat_word_2a
- end
- end
-
- case rand(9)
- when 0, 1, 2, 3
- trans_word += $trans_name[rand(trans_rand)]
- when 4, 5, 6
- trans_word += $trans_name[rand(trans_rand)] + $trans_name[rand(trans_rand)]
- when 7, 8
- trans_word += $trans_name[rand(trans_rand)] + $trans_name[rand(trans_rand)] + $trans_name[rand(trans_rand)]
- end
-
- case rand(9)
- when 0, 1, 2, 3
- trans_word += $trans_name_2[rand(trans2_rand)]
- when 4, 5, 6
- trans_word += $trans_name_2[rand(trans2_rand)] + $trans_name[rand(trans2_rand)]
- end
-
- case rand(25)
- when 0, 1, 2, 3
- name_gend = mat_word + color_word + chara_word
- when 4, 5, 6, 7
- name_gend = color_word + mat_word + chara_word
- when 8, 9, 10
- name_gend = chara_word + mat_word + color_word
- when 11, 12
- name_gend = mat_word + chara_word + color_word
- when 13
- case rand(2)
- when 0
- name_gend = mat_word + pattern_word
- else
- name_gend = pattern_word + mat_word
- end
- when 14
- name_gend = color_word + pattern_word
- when 15, 16
- case rand(2)
- when 0
- name_gend = color_word + mat_word
- else
- name_gend = mat_word + color_word
- end
- when 17
- case rand(2)
- when 0
- name_gend = pattern_word + chara_word
- else
- name_gend = chara_word + pattern_word
- end
- when 18
- case rand(2)
- when 0
- name_gend = pattern_word + mat_word
- else
- name_gend = mat_word + pattern_word
- end
- when 19
- case rand(2)
- when 0
- name_gend = chara_word + mat_word
- else
- name_gend = mat_word + chara_word
- end
- when 20
- name_gend = mat_word
- when 21, 22, 23, 24
- name_gend = trans_word
- case rand(10)
- when 0, 1
- name_gend += mat_word
- when 2, 3
- name_gend += chara_word
- when 3, 4
- name_gend += pattern_word
- when 4, 5
- name_gend += color_word
- end
- end
-
- case rand(16)
- when 0, 1, 2
- name_gend = end_word + "˙" + name_gend
- when 3, 4, 5
- name_gend += "之" + end_word
- when 6, 7
- if (type == 1 || type == 51) and (end_word != "法" and end_word != "心法"
- name_gend += end_word + "法")
- else
- name_gend += end_word
- end
- else
- name_gend += end_word
- end
- # 設置分隔符號
- if $separator == "(空格)" or $separator == "(回车)"
- separator = "\n"
- else
- separator = $separator
- end
-
- # 显示文字
- self.contents.draw_text(i%4*152, i/4*32, 132, 32, name_gend, 0)
- self.contents.draw_text(i%4*152+132, i/4*32, 132, 32, separator, 0)
- @name.push(name_gend)
- # 产生下一个
- i += 1
- end
- end
-
- # 纪录文字
- def input_text(index)
- # 纪录所选择的文字
- if $separator == "(空格)"
- separator = " "
- elsif $separator == "(回车)"
- separator = "\n"
- else
- separator = $separator
- end
- @name_selected += @name[index] + separator
- end
-
- # 输出为文本
- def output_text
- # 输出
- @namefile = File.open("./NameGen.txt","w")
- @namefile.write(@name_selected)
- #save_data(@name_selected,"NameGen.txt")
- return
- end
-
- # 確認是否已選字
- def exit_program?
- return @name_selected == ""? true : false
- end
-
- alias name_update_cursor_rect update_cursor_rect
- def update_cursor_rect
- name_update_cursor_rect
- i = @index
- # 更新图标矩形
- self.cursor_rect.set(i%4*152, i/4*32 - self.oy, 132, 32)
- end
- end
- class Window_EndSel < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(144, 96, 352, 288)
- @column_max = 10
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取尾字
- #--------------------------------------------------------------------------
- def end_word
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 获取类型
- #--------------------------------------------------------------------------
- def type(index)
- if index < @item
- return 51
- elsif index < @equip
- return 52
- elsif index < @skill
- return 53
- else
- return 54
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- # 添加报务
- @data.push("武器/武功")
- for i in $weapon_name # 添加武器/武功尾字
- @data.push(i)
- end
- @data.push("物品")
- for i in $item_name # 添加物品尾字
- @data.push(i)
- end
- @data.push("裝備")
- for i in $equip_name # 添加装备尾字
- @data.push(i)
- end
- @data.push("技能")
- for i in $skill_name # 添加技能尾字
- @data.push(i)
- end
-
- @item_max = @data.size
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- if @data[i] == "武器/武功"
- self.contents.font.color = $weapon_color
- self.contents.font.size = 11
- self.contents.draw_text(i%10*32, i/10*32 - 3, 32, 32, "武器", 1)
- self.contents.draw_text(i%10*32, i/10*32 + 9, 32, 32, "武功", 1)
- self.contents.font.size = 22
- elsif @data[i] == "物品"
- self.contents.font.color = $item_color
- self.contents.draw_text(i%10*32, i/10*32, 32, 32, @data[i], 1)
- @item = i
- elsif @data[i] == "裝備"
- self.contents.font.color = $equip_color
- self.contents.draw_text(i%10*32, i/10*32, 32, 32, @data[i], 1)
- @equip = i
- elsif @data[i] == "技能"
- self.contents.font.color = $skill_color
- self.contents.draw_text(i%10*32, i/10*32, 32, 32, @data[i], 1)
- @skill = i
- else
- self.contents.draw_text(i%10*32, i/10*32, 32, 32, @data[i], 1)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新光标举行
- #--------------------------------------------------------------------------
- alias name_update_cursor_rect update_cursor_rect
- def update_cursor_rect
- name_update_cursor_rect
- i = @index
- # 更新图标矩形
- self.cursor_rect.set(i%10*32, i/10*32 - self.oy, 32, 32)
- end
- end
复制代码
设定
- #==============================================================================
- # ■ Scene_NameGen_Setup
- #------------------------------------------------------------------------------
- # 处理名称生产器选项画面的类。
- #==============================================================================
- class Scene_NameGen_Setup
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- # 生成帮助窗口、物品窗口
- @help_window = Window_Help.new
- @help_window.contents = Bitmap.new(448, 32)
- @setup_window = Window_NameGen_Setup.new
- # 关联帮助窗口
- @setup_window.help_window = @help_window
-
- @help_window.x = 80
- @help_window.y = 58
- @help_window.width = 480
-
- @separator = $separator_re
- @generator = $generator
-
- # 执行过度
- Graphics.transition
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换就中断循环
- if $scene != self
- break
- end
- end
- # 装备过渡
- Graphics.freeze
- # 释放窗口
- @help_window.dispose
- @setup_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新窗口
- @help_window.update
- @setup_window.update
- # 物品窗口被激活的情况下: 调用 update_item
- if @setup_window.active
- update_setup
- return
- end
- end
-
- # 更新命令窗口
- def update_setup
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 演奏确定 SE
- $game_system.se_play($data_system.decision_se)
- case @setup_window.index
- when 0 # 分隔号
- @separator += 1
- @separator %= 5
- $separator_re = @separator
- case @separator
- when 0
- $separator = "(空格)"
- when 1
- $separator = "(回车)"
- when 2
- $separator = "、"
- when 3
- $separator = ","
- when 4
- $separator = "。"
- when 5
- $separator = ";"
- end
- when 1 # 产生数
- @generator += 1
- @generator %= 5
- case @generator
- when 0
- $generator = 56
- when 1
- $generator = 120
- when 2
- $generator = 180
- when 3
- $generator = 240
- when 4
- $generator = 320
- end
- when 2 # 回复默认
- ini_sepgen
- when 3 # 离开
- $scene = Scene_NameGen.new
- end
- @setup_window.refresh
- return
- end # end if Input.trigger?(Input::C)
-
- if Input.trigger?(Input::B)
- # 演奏取消 SE
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_NameGen.new
- return
- end
- end
- end
- #==============================================================================
- # ■ Window_NameGen_Setup
- #------------------------------------------------------------------------------
- # 显示名称生产器选项的窗口。
- #==============================================================================
- class Window_NameGen_Setup < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(80, 122, 480, 300)
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- @data = []
- # 添加报务
- @item_max = 4
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.font.color = system_color
- self.contents.draw_text(32, 32, 212, 32, "分隔号", 0)
- self.contents.draw_text(32, 96, 212, 32, "产生数", 0)
- self.contents.font.color = normal_color
- self.contents.draw_text(212, 32, 212, 32, $separator, 0)
- self.contents.draw_text(212, 96, 212, 32, $generator.to_s, 0)
- self.contents.draw_text(212, 160, 212, 32, "回复默认", 0)
- self.contents.draw_text(212, 224, 212, 32, "离开", 0)
- end
-
- alias name_update_cursor_rect update_cursor_rect
- def update_cursor_rect
- name_update_cursor_rect
- i = @index
- # 更新图标矩形
- self.cursor_rect.set(206, i*64+32, 224, 32)
- end
-
- #--------------------------------------------------------------------------
- # ● 刷新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- case self.index
- when 0
- string = "设定分隔名字的符号。"
- when 1
- string = "设定产生的名字数量。"
- when 2
- string = "回复到默认设定值。"
- when 3
- string = "离开,继续产生名字。"
- end
- @help_window.set_text(string)
- end
- end
- $separator = "(空格)" if $separator == nil
- $generator = 56 if $generator == nil
- $separator_re = 0 if $separator_re == nil
复制代码
|
|