查看: 2154|回复: 0

[已经过期] 叶子的任务界面脚本的问题

[复制链接]
梦石
0
星屑
50
在线时间
66 小时
注册时间
2015-4-1
回帖
8
发表于 2015-11-28 22:29:23 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 RyanBern 于 2015-11-28 23:23 编辑

我用的是叶子的任务系统,但是每次测试都会显示脚本的197行发生了NameError ,请教各位脚本大神,这是怎么回事呢?
脚本:
  1. =begin
  2. --------------------------------------------------------------------------
  3. 详尽任务显示界面 v2.1
  4. --------------------------------------------------------------------------
  5. By 叶子

  6. 日期与更新
  7. 3-29-2006 -v1.0
  8. 4-3-2006  -v2.0
  9. -可以改变文字颜色,显示变量,显示图标,显示图片
  10. -大幅简化了编写任务内容的过程,加入自动换行功能
  11. -精简了窗口,使其还可以用作图鉴系统、日记系统等等
  12. 4-6-2006  -v2.1
  13. -增加了获得全部任务与删除全部任务命令
  14. -改正通假字,修改了示例任务3
  15. --------------------------------------------------------------------------
  16. 顾名思义,就是显示任务资料的界面
  17. 任务资料要预先在这里设定好
  18. 下载范例工程,能帮助你更快更好地掌握使用方法
  19. --------------------------------------------------------------------------
  20. 使用方法:

  21. 1、召唤任务显示界面:$scene = Scene_Task.new

  22. 可以在事件中的“脚本”指令加入这段东西,又或者修改 Scene_Menu 来增加一个显示
  23. 任务的选项。如果是修改 Scene_Menu 增加选项的话,在脚本倒数第30行左右,
  24. 把 $scene = Scene_Map.new 修改成 $scene = Scene_Menu.new(任务界面index)

  25. 2、设置任务资料

  26.   2.1、相关内容解析
  27.   
  28.   所有内容文字必须用双引号括住
  29.   
  30.   名称:任务的名字(显示在左边窗口中),大小为208×32,如果全部为文字的话,
  31.         够放九个全角字符
  32.         
  33.   简介:任务的介绍(显示在右边窗口中),宽368,高不限
  34.   
  35.         文字可以自动换行
  36.   
  37.    2.1.1、控制码解析
  38.    
  39.    名称和内容均可用控制码,注意两条反斜线都要打!
  40.    
  41.    \\v[n] 显示n号变量
  42.    \\c[n] 改变字体颜色。
  43.           n=1~7 时同“显示文章”的\c[n],n=8 时为半透明色,n=9 时为系统色(青色)
  44.    \\n[i] 显示i号角色名字
  45.    \\i[文件名] 显示图标
  46.    \\p[文件名] 显示图片
  47.    
  48.    2.1.2、高级:内嵌表达式
  49.         
  50.    请参考帮助-脚本入门-字符串-内嵌表达式相关内容。
  51.    它可以用来在任务的名称和简介那里显示变量。
  52.    常用的表达式(注意不要漏了井号和大括号):
  53.    #{$game_variables[n]}       ——插入n号变量的值
  54.    #{$game_party.item_number(n)}  ——插入持有n号物品数量
  55.                                       同理还有weapon_number,armor_number
  56.    还可以预先定义一个变量,再插入(例子见示例任务3-灵魂线)
  57.    
  58.   2.2、注意事项
  59.   
  60.    2.2.1、括号、逗号和双引号 [ ] , " 必须使用半角符号(英文输入),
  61.           引号内的内容则没有关系
  62.          
  63.    2.2.2、单引号 ' 和双引号 " 的区别:
  64.           为了不出错误,全部用双引号吧!当然如果你对Ruby很熟悉,那就没所谓了
  65.   
  66.   2.3、开始设置吧!
  67.   从107行开始设置任务资料,可以参考示例任务来设置,请仔细阅读附加讲解
  68.   
  69. 3、接受任务

  70. 事件里的“脚本”指令输入:get_task(任务ID)
  71. 例如 get_task(1) 就是接受1号任务

  72.   3.1、获得全部任务
  73.   
  74.   事件里的“脚本”指令输入:get_all_task
  75.   这个功能基本上是用来在编写好所有任务资料后测试排版的
  76.   

  77. 4、完成/删除任务

  78. 事件里的“脚本”指令输入:finish_task(任务ID)
  79. 例如 finish_task(1) 就是完成1号任务

  80. 注意:本脚本不负责完成任务后的奖励之类的东西,请自行在事件中判断,
  81.        这里的完成任务指的是从任务列表中删去此任务

  82.   4.1、删除全部任务
  83.   
  84.   事件里的“脚本”指令输入:finish_all_task
  85.   作为获得全部任务的对应功能存在,似乎不会怎么用到
  86. =end

  87. class Scene_Task
  88.   # 这里设置任务内容翻页音效
  89.   CHANGE_PAGE_SE = "Audio/SE/046-Book01"
  90. end

  91. class Game_Party
  92.   #--------------------------------------------------------------------------
  93.   # ● 设置任务资料
  94.   #--------------------------------------------------------------------------
  95.   def get_tasks_info
  96.     @tasks_info = []
  97.    
  98.     #-讲解-
  99.     # 三个示例任务由浅入深,其实只要看懂第一个就可以使用了。
  100.     # 任务的写法多种多样,不限于这三个任务的方法
  101.     #----
  102.     #-----------------------------
  103.     # 示例任务1:沙漠中的五叶花
  104.     #-----------------------------
  105.     名称 = "\\c[6]沙漠中的五叶花"
  106.     #-讲解-
  107.     # 注意!脚本编辑器的变色功能并不是非常完善,所以换行后字变黑了,但仍然是字符
  108.     # 串的一部分,所以不要忘记在内容最后打一个双引号
  109.     # 按回车是强制换行
  110.     #----
  111.     简介 = "\\c[6]沙漠中的五叶花

  112. \\c[9]任务目标:
  113. 获得5朵五叶花,交给西露达

  114. \\c[0]五叶花数目:\\v[1]/5

  115. 西露达:
  116. 人家等着你的花哦~"
  117.     #-讲解-
  118.     # 每个任务最后一定要加上:
  119.     # @tasks_info[任务ID] = Game_Task.new(名称, 简介)
  120.     # 接受任务和完成任务都是用这个任务ID来索引
  121.     #----
  122.     @tasks_info[0] = Game_Task.new(名称, 简介)
  123.    
  124.     #-----------------------------
  125.     # 示例任务2:克萝莉亚的药瓶
  126.     #-----------------------------
  127.     名称 = "\\c[6]克萝莉亚的药瓶"
  128.     #-讲解-
  129.     # 这里使用了字符串相加,例如 s = "a" + "b" ,s 就是 "ab"
  130.     # 还用了内嵌表达式,$game_party.item_number(38) 就是38号物品的数量
  131.     #----
  132.     简介 = 名称 + "
  133.    
  134. \\c[9]任务目标:
  135. 问克萝莉亚要一个药瓶,交给西露达

  136. \\c[0]药瓶:#{$game_party.item_number(38)}/1

  137. 西露达:
  138. 克萝莉亚就在西边的屋子里"
  139.     @tasks_info[0] = Game_Task.new(名称, 简介)
  140.    
  141.     #-----------------------------
  142.     # 示例任务3:灵魂线
  143.     #-----------------------------
  144.     #-讲解-
  145.     # 这里用了条件判断,当3号变量大于等于1时,加上“完成”字样,同时变色
  146.     #----
  147.     if $game_variables[3] >= 1
  148.       名称 = "\\c[8]灵魂线(完成)"
  149.       item = "\\c[8]灵魂线:#{$game_variables[3]}/1 (完成)"
  150.     else
  151.       名称 = "\\c[2]灵魂线"
  152.       item = "\\c[0]灵魂线:#{$game_variables[3]}/1"
  153.     end
  154.     #-讲解-
  155.     # 预先定义变量,用内嵌表达式插入
  156.     # 最后用了显示图标
  157.     #----
  158.     简介 = "#{名称}
  159.    
  160. \\c[9]任务目标:
  161. 找到埋起来的灵魂线,交给克萝莉亚

  162. #{item}

  163. \\c[0]克萝莉亚:
  164. 灵魂线就埋在其中一棵树下,给我好好找\\i[046-Skill03]"
  165.     @tasks_info[0] = Game_Task.new(名称, 简介)
  166.    
  167.   end
  168. end
  169. #==============================================================================
  170.      名称 = "成为英雄王"
  171.      简介 = "最终任务
  172.      
  173. \\c[9]任务目标:
  174. 不断地训练自己,变得很强大,然后打败十二圣者成为英雄王

  175. \\c[0]要出发了!成为传说中的英雄王!"
  176.     @tasks_info[1] = Game_Task.new(名称, 简介)
  177. #==============================================================================
  178.      名称 = "阴谋的乞丐"
  179.      简介 = "支线任务
  180.      
  181. \\c[9]任务目标:
  182. 乞丐赖上你了,说不给一千元不行,快去收集吧!

  183. \\c[0]【乞丐】一定要收集够!要不你完了!"
  184.     @tasks_info[10] = Game_Task.new(名称, 简介)
  185. #==============================================================================
  186. # ■ Interpreter
  187. #------------------------------------------------------------------------------
  188. #  执行事件命令的解释器。本类在 Game_System 类
  189. # 与 Game_Event 类的内部使用。
  190. #==============================================================================

  191. class Interpreter
  192.   #--------------------------------------------------------------------------
  193.   # ● 接受任务
  194.   #--------------------------------------------------------------------------
  195.   def get_task(id)
  196.     task = $game_party.tasks_info[id]
  197.     return true if (task.nil? or $game_party.current_tasks.include?(task.id))
  198.     $game_party.current_tasks.unshift(task.id)
  199.     return true
  200.   end
  201.   #--------------------------------------------------------------------------
  202.   # ● 获得全部任务
  203.   #--------------------------------------------------------------------------
  204.   def get_all_task
  205.     # 清空当前任务
  206.     $game_party.current_tasks.clear
  207.     for task in $game_party.tasks_info
  208.       next if task.nil?
  209.       $game_party.current_tasks.unshift(task.id)
  210.     end
  211.     return true
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # ● 完成/放弃任务
  215.   #--------------------------------------------------------------------------
  216.   def finish_task(id)
  217.     task = $game_party.tasks_info[id]
  218.     return true if task.nil?
  219.     $game_party.current_tasks.delete(task.id)
  220.     return true
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ● 删除全部任务
  224.   #--------------------------------------------------------------------------
  225.   def finish_all_task
  226.     $game_party.current_tasks.clear
  227.     return true
  228.   end
  229. end

  230. #==============================================================================
  231. # ■ Game_Party
  232. #------------------------------------------------------------------------------
  233. #  处理同伴的类。包含金钱以及物品的信息。本类的实例
  234. # 请参考 $game_party。
  235. #==============================================================================

  236. class Game_Party
  237.   #--------------------------------------------------------------------------
  238.   # ● 定义实例变量
  239.   #--------------------------------------------------------------------------
  240.   attr_writer     :latest_task                  # 上次查看的任务
  241.   #--------------------------------------------------------------------------
  242.   # ● 取得任务资料
  243.   #--------------------------------------------------------------------------
  244.   def tasks_info
  245.     if @tasks_info.nil?
  246.       get_tasks_info
  247.     end
  248.     return @tasks_info
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 取得当前任务
  252.   #--------------------------------------------------------------------------
  253.   def current_tasks
  254.     if @current_tasks.nil?
  255.       @current_tasks = []
  256.     end
  257.     return @current_tasks
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● 上次查看的任务
  261.   #--------------------------------------------------------------------------
  262.   def latest_task
  263.     if !current_tasks.include?(@latest_task)
  264.       @latest_task = current_tasks[0]
  265.     end
  266.     return @latest_task
  267.   end
  268. end

  269. #==============================================================================
  270. # ■ Game_Task
  271. #------------------------------------------------------------------------------
  272. #  处理任务的类。包含任务的信息。
  273. #==============================================================================

  274. class Game_Task
  275.   attr_accessor   :name                   # 名称
  276.   attr_accessor   :briefing               # 简介
  277.   def initialize(name, briefing)
  278.     @name = name
  279.     @briefing = briefing
  280.   end
  281.   def height
  282.     text = @briefing.clone
  283.     x = 0
  284.     y = 64
  285.     min_y = 0
  286.     # 限制文字处理
  287.     begin
  288.       last_text = text.clone
  289.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  290.     end until text == last_text
  291.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  292.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  293.     end
  294.     # 为了方便、将 "\\\" 变换为 "\000"
  295.     text.gsub!(/\\\\/) { "\000" }
  296.     # "\C" 变为 "\001"
  297.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  298.     # "\I" 变为 "\002"
  299.     text.gsub!(/\\[Ii]/) { "\002" }
  300.     # "\P" 变为 "\003"
  301.     text.gsub!(/\\[Pp]/) { "\003" }
  302.     # c 获取 1 个字 (如果不能取得文字就循环)
  303.     while ((c = text.slice!(/./m)) != nil)
  304.       # \\ 的情况下
  305.       if c == "\000"
  306.         # 还原为本来的文字
  307.         c = "\"
  308.       end
  309.       # \C[n] 的情况下
  310.       if c == "\001"
  311.         # 更改文字色
  312.         text.sub!(/\[([0-9]+)\]/, "")
  313.         # 下面的文字
  314.         next
  315.       end
  316.       # 图标的情况下
  317.       if c == "\002"
  318.         icon_name = ''
  319.         while ((cha = text.slice!(/./m)) != ']')
  320.           next if cha == '['
  321.           icon_name += cha
  322.         end
  323.         icon = RPG::Cache.icon(icon_name)
  324.         if x + icon.width > 368
  325.           x = 0
  326.           y += [32, min_y].max
  327.           min_y = 0
  328.         end
  329.         x += 28
  330.         next
  331.       end
  332.       # 图片的情况下
  333.       if c == "\003"
  334.         pic_name = ''
  335.         while ((cha = text.slice!(/./m)) != ']')
  336.           next if cha == '['
  337.           pic_name += cha
  338.         end
  339.         pic = RPG::Cache.picture(pic_name)
  340.         if x + pic.width > 368
  341.           x = 0
  342.           y += [32, min_y].max
  343.           min_y = 0
  344.         end
  345.         x += pic.width
  346.         min_y = [pic.height, 32].max
  347.         next
  348.       end
  349.       # 另起一行文字的情况下
  350.       if c == "\n"
  351.         y += [32, min_y].max
  352.         min_y = 0
  353.         x = 0
  354.         # 下面的文字
  355.         next
  356.       end
  357.       # 自动换行处理
  358.       if x + 22 > 368
  359.         y += [32, min_y].max
  360.         min_y = 0
  361.         x = 0
  362.       end
  363.       # x 为要描绘文字的加法运算
  364.       x += 22
  365.     end
  366.     return (y + [32, min_y].max)
  367.   end
  368.   def id
  369.     return $game_party.tasks_info.index(self)
  370.   end
  371. end

  372. #==============================================================================
  373. # ■ Window_Task_Name
  374. #------------------------------------------------------------------------------
  375. #  任务名称显示窗口。
  376. #==============================================================================

  377. class Window_Task_Name < Window_Selectable
  378.   #--------------------------------------------------------------------------
  379.   # ● 初始化对像
  380.   #--------------------------------------------------------------------------
  381.   def initialize(tasks)
  382.     super(0, 0, 240, 480)
  383.     @tasks = []
  384.     for id in tasks
  385.       @tasks.push($game_party.tasks_info[id])
  386.     end
  387.     @item_max = tasks.size
  388.     self.contents = Bitmap.new(
  389.     self.width - 32, @item_max == 0 ? 32 : @item_max * 32)
  390.     refresh
  391.     self.index = 0
  392.   end
  393.   #--------------------------------------------------------------------------
  394.   # ● 刷新
  395.   #--------------------------------------------------------------------------
  396.   def refresh
  397.     self.contents.clear
  398.     if @tasks != []
  399.       for task in @tasks
  400.         draw_item(task)
  401.       end
  402.     else
  403.       draw_blank
  404.     end
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   # ● 描绘项目
  408.   #--------------------------------------------------------------------------
  409.   def draw_item(task)
  410.     text = task.name.clone
  411.     x = 0
  412.     y = @tasks.index(task) * 32
  413.     # 限制文字处理
  414.     begin
  415.       last_text = text.clone
  416.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  417.     end until text == last_text
  418.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  419.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  420.     end
  421.     # 为了方便、将 "\\\" 变换为 "\000"
  422.     text.gsub!(/\\\\/) { "\000" }
  423.     # "\\C" 变为 "\001"
  424.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  425.     # "\I" 变为 "\002"
  426.     text.gsub!(/\\[Ii]/) { "\002" }
  427.     # "\P" 变为 "\003"
  428.     text.gsub!(/\\[Pp]/) { "\003" }
  429.     # c 获取 1 个字 (如果不能取得文字就循环)
  430.     while ((c = text.slice!(/./m)) != nil)
  431.       # \\ 的情况下
  432.       if c == "\000"
  433.         # 还原为本来的文字
  434.         c = "\"
  435.       end
  436.       # \C[n] 的情况下
  437.       if c == "\001"
  438.         # 更改文字色
  439.         text.sub!(/\[([0-9]+)\]/, "")
  440.         color = $1.to_i
  441.         if color >= 0 and color <= 7
  442.           self.contents.font.color = text_color(color)
  443.         elsif color == 8
  444.           self.contents.font.color = disabled_color
  445.         elsif color == 9
  446.           self.contents.font.color = system_color
  447.         end
  448.         # 下面的文字
  449.         next
  450.       end
  451.       # 图标的情况下
  452.       if c == "\002"
  453.         icon_name = ''
  454.         while ((cha = text.slice!(/./m)) != ']')
  455.           next if cha == '['
  456.           icon_name += cha
  457.         end
  458.         icon = RPG::Cache.icon(icon_name)
  459.         if x + icon.width > self.contents.width
  460.           x = 0
  461.           y += [32, min_y].max
  462.           min_y = 0
  463.         end
  464.         self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
  465.         x += 28
  466.         next
  467.       end
  468.       # 图片的情况下
  469.       if c == "\003"
  470.         pic_name = ''
  471.         while ((cha = text.slice!(/./m)) != ']')
  472.           next if cha == '['
  473.           pic_name += cha
  474.         end
  475.         pic = RPG::Cache.picture(pic_name)
  476.         if x + pic.width > self.contents.width
  477.           x = 0
  478.           y += [32, min_y].max
  479.           min_y = 0
  480.         end
  481.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  482.         x += pic.width
  483.         next
  484.       end
  485.       # 描绘文字
  486.       self.contents.draw_text(4 + x, y, 40, 32, c)
  487.       # x 为要描绘文字的加法运算
  488.       x += self.contents.text_size(c).width
  489.     end
  490.   end
  491.   #--------------------------------------------------------------------------
  492.   # ● 描绘空行
  493.   #--------------------------------------------------------------------------
  494.   def draw_blank
  495.     self.contents.font.color = disabled_color
  496.     rect = Rect.new(4, 0, self.contents.width - 8, 32)
  497.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  498.     self.contents.draw_text(rect, '当前没有任何任务')
  499.   end
  500.   #--------------------------------------------------------------------------
  501.   # ● 获取任务
  502.   #--------------------------------------------------------------------------
  503.   def task
  504.     return @tasks[self.index]
  505.   end
  506. end
  507.   
  508. #==============================================================================
  509. # ■ Window_Task
  510. #------------------------------------------------------------------------------
  511. #  任务内容显示窗口。
  512. #==============================================================================

  513. class Window_Task < Window_Base
  514.   #--------------------------------------------------------------------------
  515.   # ● 初始化对像
  516.   #--------------------------------------------------------------------------
  517.   def initialize(task_id)
  518.     super(240, 0, 400, 480)
  519.     refresh(task_id)
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # ● 刷新内容
  523.   #--------------------------------------------------------------------------
  524.   def refresh(task_id)
  525.     self.oy = 0
  526.     self.visible = true
  527.     return if task_id.nil?
  528.     task = $game_party.tasks_info[task_id]
  529.     if !task.nil?
  530.       self.contents = Bitmap.new(self.width - 32, task.height)
  531.     else
  532.       self.contents = Bitmap.new(self.width - 32, self.height - 32)
  533.       return
  534.     end
  535.     self.contents.font.color = normal_color
  536.     # 描绘任务内容
  537.     draw_task_info(task)
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ● 描绘任务内容
  541.   #--------------------------------------------------------------------------
  542.   def draw_task_info(task)
  543.     # 记录文字x坐标
  544.     x = 0
  545.     # 记录文字y坐标
  546.     y = 0
  547.     # 记录换行时y坐标最小加值
  548.     min_y = 0
  549.     self.contents.font.color = normal_color
  550.     # 描绘任务简介
  551.     text = task.briefing.clone
  552.     # 限制文字处理
  553.     begin
  554.       last_text = text.clone
  555.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  556.     end until text == last_text
  557.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  558.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  559.     end
  560.     # 为了方便、将 "\\\" 变换为 "\000"
  561.     text.gsub!(/\\\\/) { "\000" }
  562.     # "\C" 变为 "\001"
  563.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  564.     # "\I" 变为 "\002"
  565.     text.gsub!(/\\[Ii]/) { "\002" }
  566.     # "\P" 变为 "\003"
  567.     text.gsub!(/\\[Pp]/) { "\003" }
  568.     # c 获取 1 个字 (如果不能取得文字就循环)
  569.     while ((c = text.slice!(/./m)) != nil)
  570.       # \\ 的情况下
  571.       if c == "\000"
  572.         # 还原为本来的文字
  573.         c = "\"
  574.       end
  575.       # \C[n] 的情况下
  576.       if c == "\001"
  577.         # 更改文字色
  578.         text.sub!(/\[([0-9]+)\]/, "")
  579.         color = $1.to_i
  580.         if color >= 0 and color <= 7
  581.           self.contents.font.color = text_color(color)
  582.         elsif color == 8
  583.           self.contents.font.color = disabled_color
  584.         elsif color == 9
  585.           self.contents.font.color = system_color
  586.         end
  587.         # 下面的文字
  588.         next
  589.       end
  590.       # 图标的情况下
  591.       if c == "\002"
  592.         icon_name = ''
  593.         while ((cha = text.slice!(/./m)) != ']')
  594.           next if cha == '['
  595.           icon_name += cha
  596.         end
  597.         icon = RPG::Cache.icon(icon_name)
  598.         if x + icon.width > self.contents.width
  599.           x = 0
  600.           y += [32, min_y].max
  601.           min_y = 0
  602.         end
  603.         self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
  604.         x += 28
  605.         next
  606.       end
  607.       # 图片的情况下
  608.       if c == "\003"
  609.         pic_name = ''
  610.         while ((cha = text.slice!(/./m)) != ']')
  611.           next if cha == '['
  612.           pic_name += cha
  613.         end
  614.         pic = RPG::Cache.picture(pic_name)
  615.         if x + pic.width > self.contents.width
  616.           x = 0
  617.           y += [32, min_y].max
  618.           min_y = 0
  619.         end
  620.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  621.         x += pic.width
  622.         min_y = [pic.height, 32].max
  623.         next
  624.       end
  625.       # 另起一行文字的情况下
  626.       if c == "\n"
  627.         y += [32, min_y].max
  628.         min_y = 0
  629.         x = 0
  630.         # 下面的文字
  631.         next
  632.       end
  633.       # 自动换行处理
  634.       if x + self.contents.text_size(c).width > self.contents.width
  635.         y += [32, min_y].max
  636.         min_y = 0
  637.         x = 0
  638.       end
  639.       # 描绘文字
  640.       self.contents.draw_text(4 + x, y, 40, 32, c)
  641.       # x 为要描绘文字的加法运算
  642.       x += self.contents.text_size(c).width
  643.     end
  644.   end
  645. end

  646. #==============================================================================
  647. # ■ Scene_Task
  648. #------------------------------------------------------------------------------
  649. #  处理任务画面的类。
  650. #==============================================================================

  651. class Scene_Task
  652.   #--------------------------------------------------------------------------
  653.   # ● 主处理
  654.   #--------------------------------------------------------------------------
  655.   def main
  656.     # 刷新任务资料
  657.     $game_party.get_tasks_info
  658.     # 生成任务名称窗口
  659.     @task_names_window = Window_Task_Name.new($game_party.current_tasks)
  660.     @task_names_window.active = true
  661.     if $game_party.current_tasks != []
  662.       @task_names_window.index = $game_party.current_tasks.index($game_party.latest_task)
  663.     end
  664.     # 生成任务内容窗口
  665.     @task_info_window = Window_Task.new($game_party.latest_task)
  666.     @task_info_window.active = true
  667.     # 执行过渡
  668.     Graphics.transition
  669.     # 主循环
  670.     loop do
  671.       # 刷新游戏画面
  672.       Graphics.update
  673.       # 刷新输入信息
  674.       Input.update
  675.       # 刷新画面
  676.       update
  677.       # 如果画面被切换的话就中断循环
  678.       if $scene != self
  679.         break
  680.       end
  681.     end
  682.     # 准备过渡
  683.     Graphics.freeze
  684.     # 释放窗口
  685.     @task_names_window.dispose
  686.     @task_info_window.dispose
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   # ● 刷新画面
  690.   #--------------------------------------------------------------------------
  691.   def update
  692.     # 刷新窗口
  693.     @task_names_window.update
  694.     @task_info_window.update
  695.     update_task_names_window
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ● 刷新任务名称窗口
  699.   #--------------------------------------------------------------------------
  700.   def update_task_names_window
  701.     # 按下 B 键的情况下
  702.     if Input.trigger?(Input::B)
  703.       # 演奏取消 SE
  704.       $game_system.se_play($data_system.cancel_se)
  705.       # 这里设置返回的场景,返回地图是Scene_Map.new,菜单是Scene_Menu.new(任务界面index)
  706.       $scene = Scene_Map.new
  707.       return
  708.     end
  709.     # 按下 C 键的情况下
  710.     if Input.trigger?(Input::C)
  711.       # 无任务可显示的话
  712.       if @task_names_window.task == nil
  713.         # 演奏冻结 SE
  714.         $game_system.se_play($data_system.buzzer_se)
  715.         return
  716.       end
  717.       # 如果光标没有移动的话,翻页
  718.       if $game_party.latest_task == @task_names_window.task.id
  719.         if @task_info_window.oy + @task_info_window.height - 32 > @task_info_window.contents.height
  720.           @task_info_window.oy = 0
  721.         else
  722.           @task_info_window.oy += 480-32
  723.         end
  724.         if @task_info_window.contents.height > @task_info_window.height - 32
  725.           # 演奏翻页 SE
  726.           Audio.se_play(CHANGE_PAGE_SE)
  727.         end
  728.       else
  729.         @task_info_window.refresh(@task_names_window.task.id)
  730.         $game_party.latest_task = @task_names_window.task.id
  731.         # 演奏确定 SE
  732.         $game_system.se_play($data_system.decision_se)
  733.       end
  734.     end
  735.   end
  736. end
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部