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

Project1

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

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

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
66 小时
注册时间
2015-4-1
帖子
14
跳转到指定楼层
1
发表于 2015-11-28 22:29:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

我用的是叶子的任务系统,但是每次测试都会显示脚本的197行发生了NameError ,请教各位脚本大神,这是怎么回事呢?
脚本:
RUBY 代码复制
  1. =begin
  2.  --------------------------------------------------------------------------
  3.  详尽任务显示界面 v2.1
  4.  --------------------------------------------------------------------------
  5.  By 叶子
  6.  
  7.  日期与更新
  8.  3-29-2006 -v1.0
  9.  4-3-2006  -v2.0
  10.  -可以改变文字颜色,显示变量,显示图标,显示图片
  11.  -大幅简化了编写任务内容的过程,加入自动换行功能
  12.  -精简了窗口,使其还可以用作图鉴系统、日记系统等等
  13.  4-6-2006  -v2.1
  14.  -增加了获得全部任务与删除全部任务命令
  15.  -改正通假字,修改了示例任务3
  16.  --------------------------------------------------------------------------
  17.  顾名思义,就是显示任务资料的界面
  18.  任务资料要预先在这里设定好
  19.  下载范例工程,能帮助你更快更好地掌握使用方法
  20.  --------------------------------------------------------------------------
  21.  使用方法:
  22.  
  23.  1、召唤任务显示界面:$scene = Scene_Task.new
  24.  
  25.  可以在事件中的“脚本”指令加入这段东西,又或者修改 Scene_Menu 来增加一个显示
  26.  任务的选项。如果是修改 Scene_Menu 增加选项的话,在脚本倒数第30行左右,
  27.  把 $scene = Scene_Map.new 修改成 $scene = Scene_Menu.new(任务界面index)
  28.  
  29.  2、设置任务资料
  30.  
  31.   2.1、相关内容解析
  32.  
  33.   所有内容文字必须用双引号括住
  34.  
  35.   名称:任务的名字(显示在左边窗口中),大小为208×32,如果全部为文字的话,
  36.         够放九个全角字符
  37.        
  38.   简介:任务的介绍(显示在右边窗口中),宽368,高不限
  39.  
  40.         文字可以自动换行
  41.  
  42.    2.1.1、控制码解析
  43.    
  44.    名称和内容均可用控制码,注意两条反斜线都要打!
  45.    
  46.    \\v[n] 显示n号变量
  47.    \\c[n] 改变字体颜色。
  48.           n=1~7 时同“显示文章”的\c[n],n=8 时为半透明色,n=9 时为系统色(青色)
  49.    \\n[i] 显示i号角色名字
  50.    \\i[文件名] 显示图标
  51.    \\p[文件名] 显示图片
  52.    
  53.    2.1.2、高级:内嵌表达式
  54.        
  55.    请参考帮助-脚本入门-字符串-内嵌表达式相关内容。
  56.    它可以用来在任务的名称和简介那里显示变量。
  57.    常用的表达式(注意不要漏了井号和大括号):
  58.    #{$game_variables[n]}       ——插入n号变量的值
  59.    #{$game_party.item_number(n)}  ——插入持有n号物品数量
  60.                                       同理还有weapon_number,armor_number
  61.    还可以预先定义一个变量,再插入(例子见示例任务3-灵魂线)
  62.    
  63.   2.2、注意事项
  64.  
  65.    2.2.1、括号、逗号和双引号 [ ] , " 必须使用半角符号(英文输入),
  66.           引号内的内容则没有关系
  67.           
  68.    2.2.2、单引号 ' 和双引号 " 的区别:
  69.           为了不出错误,全部用双引号吧!当然如果你对Ruby很熟悉,那就没所谓了
  70.  
  71.   2.3、开始设置吧!
  72.   从107行开始设置任务资料,可以参考示例任务来设置,请仔细阅读附加讲解
  73.  
  74.  3、接受任务
  75.  
  76.  事件里的“脚本”指令输入:get_task(任务ID)
  77.  例如 get_task(1) 就是接受1号任务
  78.  
  79.   3.1、获得全部任务
  80.  
  81.   事件里的“脚本”指令输入:get_all_task
  82.   这个功能基本上是用来在编写好所有任务资料后测试排版的
  83.  
  84.  
  85.  4、完成/删除任务
  86.  
  87.  事件里的“脚本”指令输入:finish_task(任务ID)
  88.  例如 finish_task(1) 就是完成1号任务
  89.  
  90.  注意:本脚本不负责完成任务后的奖励之类的东西,请自行在事件中判断,
  91.        这里的完成任务指的是从任务列表中删去此任务
  92.  
  93.   4.1、删除全部任务
  94.  
  95.   事件里的“脚本”指令输入:finish_all_task
  96.   作为获得全部任务的对应功能存在,似乎不会怎么用到
  97. =end
  98.  
  99. class Scene_Task
  100.   # 这里设置任务内容翻页音效
  101.   CHANGE_PAGE_SE = "Audio/SE/046-Book01"
  102. end
  103.  
  104. class Game_Party
  105.   #--------------------------------------------------------------------------
  106.   # ● 设置任务资料
  107.   #--------------------------------------------------------------------------
  108.   def get_tasks_info
  109.     @tasks_info = []
  110.  
  111.     #-讲解-
  112.     # 三个示例任务由浅入深,其实只要看懂第一个就可以使用了。
  113.     # 任务的写法多种多样,不限于这三个任务的方法
  114.     #----
  115.     #-----------------------------
  116.     # 示例任务1:沙漠中的五叶花
  117.     #-----------------------------
  118.     名称 = "\\c[6]沙漠中的五叶花"
  119.     #-讲解-
  120.     # 注意!脚本编辑器的变色功能并不是非常完善,所以换行后字变黑了,但仍然是字符
  121.     # 串的一部分,所以不要忘记在内容最后打一个双引号
  122.     # 按回车是强制换行
  123.     #----
  124.     简介 = "\\c[6]沙漠中的五叶花
  125.  
  126. \\c[9]任务目标:
  127. 获得5朵五叶花,交给西露达
  128.  
  129. \\c[0]五叶花数目:\\v[1]/5
  130.  
  131. 西露达:
  132. 人家等着你的花哦~"
  133.     #-讲解-
  134.     # 每个任务最后一定要加上:
  135.     # @tasks_info[任务ID] = Game_Task.new(名称, 简介)
  136.     # 接受任务和完成任务都是用这个任务ID来索引
  137.     #----
  138.     @tasks_info[0] = Game_Task.new(名称, 简介)
  139.  
  140.     #-----------------------------
  141.     # 示例任务2:克萝莉亚的药瓶
  142.     #-----------------------------
  143.     名称 = "\\c[6]克萝莉亚的药瓶"
  144.     #-讲解-
  145.     # 这里使用了字符串相加,例如 s = "a" + "b" ,s 就是 "ab"
  146.     # 还用了内嵌表达式,$game_party.item_number(38) 就是38号物品的数量
  147.     #----
  148.     简介 = 名称 + "
  149.  
  150. \\c[9]任务目标:
  151. 问克萝莉亚要一个药瓶,交给西露达
  152.  
  153. \\c[0]药瓶:#{$game_party.item_number(38)}/1
  154.  
  155. 西露达:
  156. 克萝莉亚就在西边的屋子里"
  157.     @tasks_info[0] = Game_Task.new(名称, 简介)
  158.  
  159.     #-----------------------------
  160.     # 示例任务3:灵魂线
  161.     #-----------------------------
  162.     #-讲解-
  163.     # 这里用了条件判断,当3号变量大于等于1时,加上“完成”字样,同时变色
  164.     #----
  165.     if $game_variables[3] >= 1
  166.       名称 = "\\c[8]灵魂线(完成)"
  167.       item = "\\c[8]灵魂线:#{$game_variables[3]}/1 (完成)"
  168.     else
  169.       名称 = "\\c[2]灵魂线"
  170.       item = "\\c[0]灵魂线:#{$game_variables[3]}/1"
  171.     end
  172.     #-讲解-
  173.     # 预先定义变量,用内嵌表达式插入
  174.     # 最后用了显示图标
  175.     #----
  176.     简介 = "#{名称}
  177.  
  178. \\c[9]任务目标:
  179. 找到埋起来的灵魂线,交给克萝莉亚
  180.  
  181. #{item}
  182.  
  183. \\c[0]克萝莉亚:
  184. 灵魂线就埋在其中一棵树下,给我好好找\\i[046-Skill03]"
  185.     @tasks_info[0] = Game_Task.new(名称, 简介)
  186.  
  187.   end
  188. end
  189. #==============================================================================
  190.      名称 = "成为英雄王"
  191.      简介 = "最终任务
  192.  
  193. \\c[9]任务目标:
  194. 不断地训练自己,变得很强大,然后打败十二圣者成为英雄王
  195.  
  196. \\c[0]要出发了!成为传说中的英雄王!"
  197.     @tasks_info[1] = Game_Task.new(名称, 简介)
  198. #==============================================================================
  199.      名称 = "阴谋的乞丐"
  200.      简介 = "支线任务
  201.  
  202. \\c[9]任务目标:
  203. 乞丐赖上你了,说不给一千元不行,快去收集吧!
  204.  
  205. \\c[0]【乞丐】一定要收集够!要不你完了!"
  206.     @tasks_info[10] = Game_Task.new(名称, 简介)
  207. #==============================================================================
  208. # ■ Interpreter
  209. #------------------------------------------------------------------------------
  210. #  执行事件命令的解释器。本类在 Game_System 类
  211. # 与 Game_Event 类的内部使用。
  212. #==============================================================================
  213.  
  214. class Interpreter
  215.   #--------------------------------------------------------------------------
  216.   # ● 接受任务
  217.   #--------------------------------------------------------------------------
  218.   def get_task(id)
  219.     task = $game_party.tasks_info[id]
  220.     return true if (task.nil? or $game_party.current_tasks.include?(task.id))
  221.     $game_party.current_tasks.unshift(task.id)
  222.     return true
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 获得全部任务
  226.   #--------------------------------------------------------------------------
  227.   def get_all_task
  228.     # 清空当前任务
  229.     $game_party.current_tasks.clear
  230.     for task in $game_party.tasks_info
  231.       next if task.nil?
  232.       $game_party.current_tasks.unshift(task.id)
  233.     end
  234.     return true
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 完成/放弃任务
  238.   #--------------------------------------------------------------------------
  239.   def finish_task(id)
  240.     task = $game_party.tasks_info[id]
  241.     return true if task.nil?
  242.     $game_party.current_tasks.delete(task.id)
  243.     return true
  244.   end
  245.   #--------------------------------------------------------------------------
  246.   # ● 删除全部任务
  247.   #--------------------------------------------------------------------------
  248.   def finish_all_task
  249.     $game_party.current_tasks.clear
  250.     return true
  251.   end
  252. end
  253.  
  254. #==============================================================================
  255. # ■ Game_Party
  256. #------------------------------------------------------------------------------
  257. #  处理同伴的类。包含金钱以及物品的信息。本类的实例
  258. # 请参考 $game_party。
  259. #==============================================================================
  260.  
  261. class Game_Party
  262.   #--------------------------------------------------------------------------
  263.   # ● 定义实例变量
  264.   #--------------------------------------------------------------------------
  265.   attr_writer     :latest_task                  # 上次查看的任务
  266.   #--------------------------------------------------------------------------
  267.   # ● 取得任务资料
  268.   #--------------------------------------------------------------------------
  269.   def tasks_info
  270.     if @tasks_info.nil?
  271.       get_tasks_info
  272.     end
  273.     return @tasks_info
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # ● 取得当前任务
  277.   #--------------------------------------------------------------------------
  278.   def current_tasks
  279.     if @current_tasks.nil?
  280.       @current_tasks = []
  281.     end
  282.     return @current_tasks
  283.   end
  284.   #--------------------------------------------------------------------------
  285.   # ● 上次查看的任务
  286.   #--------------------------------------------------------------------------
  287.   def latest_task
  288.     if !current_tasks.include?(@latest_task)
  289.       @latest_task = current_tasks[0]
  290.     end
  291.     return @latest_task
  292.   end
  293. end
  294.  
  295. #==============================================================================
  296. # ■ Game_Task
  297. #------------------------------------------------------------------------------
  298. #  处理任务的类。包含任务的信息。
  299. #==============================================================================
  300.  
  301. class Game_Task
  302.   attr_accessor   :name                   # 名称
  303.   attr_accessor   :briefing               # 简介
  304.   def initialize(name, briefing)
  305.     @name = name
  306.     @briefing = briefing
  307.   end
  308.   def height
  309.     text = @briefing.clone
  310.     x = 0
  311.     y = 64
  312.     min_y = 0
  313.     # 限制文字处理
  314.     begin
  315.       last_text = text.clone
  316.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  317.     end until text == last_text
  318.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  319.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  320.     end
  321.     # 为了方便、将 "\\\\" 变换为 "\000"
  322.     text.gsub!(/\\\\/) { "\000" }
  323.     # "\C" 变为 "\001"
  324.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  325.     # "\I" 变为 "\002"
  326.     text.gsub!(/\\[Ii]/) { "\002" }
  327.     # "\P" 变为 "\003"
  328.     text.gsub!(/\\[Pp]/) { "\003" }
  329.     # c 获取 1 个字 (如果不能取得文字就循环)
  330.     while ((c = text.slice!(/./m)) != nil)
  331.       # \\ 的情况下
  332.       if c == "\000"
  333.         # 还原为本来的文字
  334.         c = "\\"
  335.       end
  336.       # \C[n] 的情况下
  337.       if c == "\001"
  338.         # 更改文字色
  339.         text.sub!(/\[([0-9]+)\]/, "")
  340.         # 下面的文字
  341.         next
  342.       end
  343.       # 图标的情况下
  344.       if c == "\002"
  345.         icon_name = ''
  346.         while ((cha = text.slice!(/./m)) != ']')
  347.           next if cha == '['
  348.           icon_name += cha
  349.         end
  350.         icon = RPG::Cache.icon(icon_name)
  351.         if x + icon.width > 368
  352.           x = 0
  353.           y += [32, min_y].max
  354.           min_y = 0
  355.         end
  356.         x += 28
  357.         next
  358.       end
  359.       # 图片的情况下
  360.       if c == "\003"
  361.         pic_name = ''
  362.         while ((cha = text.slice!(/./m)) != ']')
  363.           next if cha == '['
  364.           pic_name += cha
  365.         end
  366.         pic = RPG::Cache.picture(pic_name)
  367.         if x + pic.width > 368
  368.           x = 0
  369.           y += [32, min_y].max
  370.           min_y = 0
  371.         end
  372.         x += pic.width
  373.         min_y = [pic.height, 32].max
  374.         next
  375.       end
  376.       # 另起一行文字的情况下
  377.       if c == "\n"
  378.         y += [32, min_y].max
  379.         min_y = 0
  380.         x = 0
  381.         # 下面的文字
  382.         next
  383.       end
  384.       # 自动换行处理
  385.       if x + 22 > 368
  386.         y += [32, min_y].max
  387.         min_y = 0
  388.         x = 0
  389.       end
  390.       # x 为要描绘文字的加法运算
  391.       x += 22
  392.     end
  393.     return (y + [32, min_y].max)
  394.   end
  395.   def id
  396.     return $game_party.tasks_info.index(self)
  397.   end
  398. end
  399.  
  400. #==============================================================================
  401. # ■ Window_Task_Name
  402. #------------------------------------------------------------------------------
  403. #  任务名称显示窗口。
  404. #==============================================================================
  405.  
  406. class Window_Task_Name < Window_Selectable
  407.   #--------------------------------------------------------------------------
  408.   # ● 初始化对像
  409.   #--------------------------------------------------------------------------
  410.   def initialize(tasks)
  411.     super(0, 0, 240, 480)
  412.     @tasks = []
  413.     for id in tasks
  414.       @tasks.push($game_party.tasks_info[id])
  415.     end
  416.     @item_max = tasks.size
  417.     self.contents = Bitmap.new(
  418.     self.width - 32, @item_max == 0 ? 32 : @item_max * 32)
  419.     refresh
  420.     self.index = 0
  421.   end
  422.   #--------------------------------------------------------------------------
  423.   # ● 刷新
  424.   #--------------------------------------------------------------------------
  425.   def refresh
  426.     self.contents.clear
  427.     if @tasks != []
  428.       for task in @tasks
  429.         draw_item(task)
  430.       end
  431.     else
  432.       draw_blank
  433.     end
  434.   end
  435.   #--------------------------------------------------------------------------
  436.   # ● 描绘项目
  437.   #--------------------------------------------------------------------------
  438.   def draw_item(task)
  439.     text = task.name.clone
  440.     x = 0
  441.     y = @tasks.index(task) * 32
  442.     # 限制文字处理
  443.     begin
  444.       last_text = text.clone
  445.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  446.     end until text == last_text
  447.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  448.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  449.     end
  450.     # 为了方便、将 "\\\\" 变换为 "\000"
  451.     text.gsub!(/\\\\/) { "\000" }
  452.     # "\\C" 变为 "\001"
  453.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  454.     # "\I" 变为 "\002"
  455.     text.gsub!(/\\[Ii]/) { "\002" }
  456.     # "\P" 变为 "\003"
  457.     text.gsub!(/\\[Pp]/) { "\003" }
  458.     # c 获取 1 个字 (如果不能取得文字就循环)
  459.     while ((c = text.slice!(/./m)) != nil)
  460.       # \\ 的情况下
  461.       if c == "\000"
  462.         # 还原为本来的文字
  463.         c = "\\"
  464.       end
  465.       # \C[n] 的情况下
  466.       if c == "\001"
  467.         # 更改文字色
  468.         text.sub!(/\[([0-9]+)\]/, "")
  469.         color = $1.to_i
  470.         if color >= 0 and color <= 7
  471.           self.contents.font.color = text_color(color)
  472.         elsif color == 8
  473.           self.contents.font.color = disabled_color
  474.         elsif color == 9
  475.           self.contents.font.color = system_color
  476.         end
  477.         # 下面的文字
  478.         next
  479.       end
  480.       # 图标的情况下
  481.       if c == "\002"
  482.         icon_name = ''
  483.         while ((cha = text.slice!(/./m)) != ']')
  484.           next if cha == '['
  485.           icon_name += cha
  486.         end
  487.         icon = RPG::Cache.icon(icon_name)
  488.         if x + icon.width > self.contents.width
  489.           x = 0
  490.           y += [32, min_y].max
  491.           min_y = 0
  492.         end
  493.         self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
  494.         x += 28
  495.         next
  496.       end
  497.       # 图片的情况下
  498.       if c == "\003"
  499.         pic_name = ''
  500.         while ((cha = text.slice!(/./m)) != ']')
  501.           next if cha == '['
  502.           pic_name += cha
  503.         end
  504.         pic = RPG::Cache.picture(pic_name)
  505.         if x + pic.width > self.contents.width
  506.           x = 0
  507.           y += [32, min_y].max
  508.           min_y = 0
  509.         end
  510.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  511.         x += pic.width
  512.         next
  513.       end
  514.       # 描绘文字
  515.       self.contents.draw_text(4 + x, y, 40, 32, c)
  516.       # x 为要描绘文字的加法运算
  517.       x += self.contents.text_size(c).width
  518.     end
  519.   end
  520.   #--------------------------------------------------------------------------
  521.   # ● 描绘空行
  522.   #--------------------------------------------------------------------------
  523.   def draw_blank
  524.     self.contents.font.color = disabled_color
  525.     rect = Rect.new(4, 0, self.contents.width - 8, 32)
  526.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  527.     self.contents.draw_text(rect, '当前没有任何任务')
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   # ● 获取任务
  531.   #--------------------------------------------------------------------------
  532.   def task
  533.     return @tasks[self.index]
  534.   end
  535. end
  536.  
  537. #==============================================================================
  538. # ■ Window_Task
  539. #------------------------------------------------------------------------------
  540. #  任务内容显示窗口。
  541. #==============================================================================
  542.  
  543. class Window_Task < Window_Base
  544.   #--------------------------------------------------------------------------
  545.   # ● 初始化对像
  546.   #--------------------------------------------------------------------------
  547.   def initialize(task_id)
  548.     super(240, 0, 400, 480)
  549.     refresh(task_id)
  550.   end
  551.   #--------------------------------------------------------------------------
  552.   # ● 刷新内容
  553.   #--------------------------------------------------------------------------
  554.   def refresh(task_id)
  555.     self.oy = 0
  556.     self.visible = true
  557.     return if task_id.nil?
  558.     task = $game_party.tasks_info[task_id]
  559.     if !task.nil?
  560.       self.contents = Bitmap.new(self.width - 32, task.height)
  561.     else
  562.       self.contents = Bitmap.new(self.width - 32, self.height - 32)
  563.       return
  564.     end
  565.     self.contents.font.color = normal_color
  566.     # 描绘任务内容
  567.     draw_task_info(task)
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # ● 描绘任务内容
  571.   #--------------------------------------------------------------------------
  572.   def draw_task_info(task)
  573.     # 记录文字x坐标
  574.     x = 0
  575.     # 记录文字y坐标
  576.     y = 0
  577.     # 记录换行时y坐标最小加值
  578.     min_y = 0
  579.     self.contents.font.color = normal_color
  580.     # 描绘任务简介
  581.     text = task.briefing.clone
  582.     # 限制文字处理
  583.     begin
  584.       last_text = text.clone
  585.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  586.     end until text == last_text
  587.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  588.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  589.     end
  590.     # 为了方便、将 "\\\\" 变换为 "\000"
  591.     text.gsub!(/\\\\/) { "\000" }
  592.     # "\C" 变为 "\001"
  593.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  594.     # "\I" 变为 "\002"
  595.     text.gsub!(/\\[Ii]/) { "\002" }
  596.     # "\P" 变为 "\003"
  597.     text.gsub!(/\\[Pp]/) { "\003" }
  598.     # c 获取 1 个字 (如果不能取得文字就循环)
  599.     while ((c = text.slice!(/./m)) != nil)
  600.       # \\ 的情况下
  601.       if c == "\000"
  602.         # 还原为本来的文字
  603.         c = "\\"
  604.       end
  605.       # \C[n] 的情况下
  606.       if c == "\001"
  607.         # 更改文字色
  608.         text.sub!(/\[([0-9]+)\]/, "")
  609.         color = $1.to_i
  610.         if color >= 0 and color <= 7
  611.           self.contents.font.color = text_color(color)
  612.         elsif color == 8
  613.           self.contents.font.color = disabled_color
  614.         elsif color == 9
  615.           self.contents.font.color = system_color
  616.         end
  617.         # 下面的文字
  618.         next
  619.       end
  620.       # 图标的情况下
  621.       if c == "\002"
  622.         icon_name = ''
  623.         while ((cha = text.slice!(/./m)) != ']')
  624.           next if cha == '['
  625.           icon_name += cha
  626.         end
  627.         icon = RPG::Cache.icon(icon_name)
  628.         if x + icon.width > self.contents.width
  629.           x = 0
  630.           y += [32, min_y].max
  631.           min_y = 0
  632.         end
  633.         self.contents.blt(x + 4, y + 4, icon, Rect.new(0, 0, 24, 24))
  634.         x += 28
  635.         next
  636.       end
  637.       # 图片的情况下
  638.       if c == "\003"
  639.         pic_name = ''
  640.         while ((cha = text.slice!(/./m)) != ']')
  641.           next if cha == '['
  642.           pic_name += cha
  643.         end
  644.         pic = RPG::Cache.picture(pic_name)
  645.         if x + pic.width > self.contents.width
  646.           x = 0
  647.           y += [32, min_y].max
  648.           min_y = 0
  649.         end
  650.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  651.         x += pic.width
  652.         min_y = [pic.height, 32].max
  653.         next
  654.       end
  655.       # 另起一行文字的情况下
  656.       if c == "\n"
  657.         y += [32, min_y].max
  658.         min_y = 0
  659.         x = 0
  660.         # 下面的文字
  661.         next
  662.       end
  663.       # 自动换行处理
  664.       if x + self.contents.text_size(c).width > self.contents.width
  665.         y += [32, min_y].max
  666.         min_y = 0
  667.         x = 0
  668.       end
  669.       # 描绘文字
  670.       self.contents.draw_text(4 + x, y, 40, 32, c)
  671.       # x 为要描绘文字的加法运算
  672.       x += self.contents.text_size(c).width
  673.     end
  674.   end
  675. end
  676.  
  677. #==============================================================================
  678. # ■ Scene_Task
  679. #------------------------------------------------------------------------------
  680. #  处理任务画面的类。
  681. #==============================================================================
  682.  
  683. class Scene_Task
  684.   #--------------------------------------------------------------------------
  685.   # ● 主处理
  686.   #--------------------------------------------------------------------------
  687.   def main
  688.     # 刷新任务资料
  689.     $game_party.get_tasks_info
  690.     # 生成任务名称窗口
  691.     @task_names_window = Window_Task_Name.new($game_party.current_tasks)
  692.     @task_names_window.active = true
  693.     if $game_party.current_tasks != []
  694.       @task_names_window.index = $game_party.current_tasks.index($game_party.latest_task)
  695.     end
  696.     # 生成任务内容窗口
  697.     @task_info_window = Window_Task.new($game_party.latest_task)
  698.     @task_info_window.active = true
  699.     # 执行过渡
  700.     Graphics.transition
  701.     # 主循环
  702.     loop do
  703.       # 刷新游戏画面
  704.       Graphics.update
  705.       # 刷新输入信息
  706.       Input.update
  707.       # 刷新画面
  708.       update
  709.       # 如果画面被切换的话就中断循环
  710.       if $scene != self
  711.         break
  712.       end
  713.     end
  714.     # 准备过渡
  715.     Graphics.freeze
  716.     # 释放窗口
  717.     @task_names_window.dispose
  718.     @task_info_window.dispose
  719.   end
  720.   #--------------------------------------------------------------------------
  721.   # ● 刷新画面
  722.   #--------------------------------------------------------------------------
  723.   def update
  724.     # 刷新窗口
  725.     @task_names_window.update
  726.     @task_info_window.update
  727.     update_task_names_window
  728.   end
  729.   #--------------------------------------------------------------------------
  730.   # ● 刷新任务名称窗口
  731.   #--------------------------------------------------------------------------
  732.   def update_task_names_window
  733.     # 按下 B 键的情况下
  734.     if Input.trigger?(Input::B)
  735.       # 演奏取消 SE
  736.       $game_system.se_play($data_system.cancel_se)
  737.       # 这里设置返回的场景,返回地图是Scene_Map.new,菜单是Scene_Menu.new(任务界面index)
  738.       $scene = Scene_Map.new
  739.       return
  740.     end
  741.     # 按下 C 键的情况下
  742.     if Input.trigger?(Input::C)
  743.       # 无任务可显示的话
  744.       if @task_names_window.task == nil
  745.         # 演奏冻结 SE
  746.         $game_system.se_play($data_system.buzzer_se)
  747.         return
  748.       end
  749.       # 如果光标没有移动的话,翻页
  750.       if $game_party.latest_task == @task_names_window.task.id
  751.         if @task_info_window.oy + @task_info_window.height - 32 > @task_info_window.contents.height
  752.           @task_info_window.oy = 0
  753.         else
  754.           @task_info_window.oy += 480-32
  755.         end
  756.         if @task_info_window.contents.height > @task_info_window.height - 32
  757.           # 演奏翻页 SE
  758.           Audio.se_play(CHANGE_PAGE_SE)
  759.         end
  760.       else
  761.         @task_info_window.refresh(@task_names_window.task.id)
  762.         $game_party.latest_task = @task_names_window.task.id
  763.         # 演奏确定 SE
  764.         $game_system.se_play($data_system.decision_se)
  765.       end
  766.     end
  767.   end
  768. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-9-22 23:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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