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

Project1

 找回密码
 注册会员
搜索
查看: 1413|回复: 0

[已经过期] 关于任务插件的刷新问题,求教

[复制链接]

Lv1.梦旅人

梦石
0
星屑
165
在线时间
16 小时
注册时间
2016-1-6
帖子
14
发表于 2019-1-2 20:44:07 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 coolala222 于 2019-1-2 20:54 编辑

使用了叶子大大的【任务界面】插件,发现有个问题,就是读档后如果不打开一次界面,任务界面是不会刷新的。因此在测试中发现会有个问题,就是读档后直接去触发的任务不会显示在任务栏中,必须在接任务前打开一次任务面板才行。

我看了下插件下面,有关于刷新的机制,但看不太懂。

现在想改成【进入游戏后】就能直接刷新的,行不行?

以下是插件的最后关于刷新方面的代码,求赐教。


# ■ Scene_Task
#------------------------------------------------------------------------------
#  处理任务画面的类。
#==============================================================================

class Scene_Task < Scene_Base
  def initialize(index=nil)
    @menu_index = index
  end
  #--------------------------------------------------------------------------
  # ● 主处理
  #--------------------------------------------------------------------------
  def start
    # 刷新任务资料
    $game_party.get_tasks_info
    # 生成任务名称窗口
    @task_names_window = Window_Task_Name.new($game_party.current_tasks)
    @task_names_window.active = true
    if $game_party.current_tasks != []
      @task_names_window.index = $game_party.current_tasks.index($game_party.latest_task)
    end
    # 生成任务内容窗口
    @task_info_window = Window_Task.new($game_party.latest_task)
    @task_info_window.active = true
  end

  def terminate
    # 释放窗口
    @task_names_window.dispose
    @task_info_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 刷新画面
  #--------------------------------------------------------------------------
  def update
    # 刷新窗口
    @task_names_window.update
    @task_info_window.update
    update_task_names_window
  end
  #--------------------------------------------------------------------------
  # ● 刷新任务名称窗口
  #--------------------------------------------------------------------------
  def update_task_names_window
    # 按下 B 键的情况下
    if Input.trigger?(Input::B)
      # 演奏取消 SE
      Sound.play_cancel
      # 这里设置返回的场景,返回地图是Scene_Map.new,菜单是Scene_Menu.new(任务界面index)
      if @menu_index == nil
        $scene = Scene_Map.new
      else
        $scene = Scene_Menu.new(@menu_index)
      end
      return
    end
    # 按下 C 键的情况下
    if Input.trigger?(Input::C)
      # 无任务可显示的话
      if @task_names_window.task == nil
        # 演奏冻结 SE
        Sound.play_buzzer
        return
      end
      # 如果光标没有移动的话,翻页
      if $game_party.latest_task == @task_names_window.task.id
        if @task_info_window.oy + @task_info_window.height - 32 > @task_info_window.contents.height
          @task_info_window.oy = 0
        else
          @task_info_window.oy += 480-32
        end
        
      else
        @task_info_window.refresh(@task_names_window.task.id)
        $game_party.latest_task = @task_names_window.task.id
        # 演奏确定 SE
        Sound.play_decision
      end
    end
  end
end


我在下面把所有代码一起发上来
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.  改版 by snstar2006
  18.  
  19.  修改部分:
  20.  - 将XP的一些脚本改成VX版的
  21.  - 将窗口大小缩放成VX的大小(依照比例)
  22.  - 将一些会变成很长的脚本精简
  23.    (如:用$game_pary.item_no(物品编号)
  24.         代替原来的$game_party.item_number($data_items[物品编号]) = ="好长)
  25.  - 精简一些代码,将 Window_Task_Name 和Window_Task 重合部分用继承方式精简
  26.  - 依照VX的 RGSS2 规范编写 Scene_Task
  27.  - 增加使用16进位颜色代码变换字体颜色功能
  28.  - 修改Scene_Menu的召唤方式,使脚本新手使用起来更容易
  29.  
  30.  --------------------------------------------------------------------------
  31.  顾名思义,就是显示任务数据的界面
  32.  任务数据要预先在这里设定好
  33.  下载范例工程,能帮助你更快更好地掌握使用方法
  34.  --------------------------------------------------------------------------
  35.  使用方法:
  36.  
  37.  1、召唤任务显示界面:$scene = Scene_Task.new
  38.  
  39.  可以在事件中的「脚本」指令加入这段东西,
  40.  又或者修改 Scene_Menu 来增加一个显示任务的选项。
  41.  如果是修改 Scene_Menu 增加選項的話,请使用
  42.  
  43.     $scene = Scene_Task.new(任务在菜单的index)
  44.  
  45.  例如:$scene = Scene_Task.new(7)
  46.  
  47.  2、设置任务数据
  48.  
  49.   2.1、相关内容解析
  50.  
  51.   所有内容文字必须用双引号括住
  52.  
  53.   名称:任务的名字(显示在左边窗口中),大小为172×32,如果全部为文字的话,
  54.         够放九个全角字符
  55.        
  56.   简介:任务的介绍(显示在右边窗口中),宽308,高不限
  57.  
  58.         文字可以自动换行
  59.  
  60.    2.1.1、控制码解析
  61.    
  62.    名称和内容均可用控制码,注意两条反斜杠都要打!
  63.    
  64.    \\v[n] 显示n号变量
  65.    \\c[n] 改变字体颜色。n 为窗口外观图片中所设定的颜色,可为0-31
  66.  
  67.    \\c[HRRGGBB]设定字体颜色为RRGGBB色, RRGGBB 为16进位颜色代码
  68.    \\n[i] 显示i号角色名字
  69.    \\i[图标编号] 显示图标    # 图标编号为图标在IconSet里的顺序
  70.    \\p[文件名] 显示图片
  71.    
  72.    2.1.2、高级:内嵌表达式
  73.        
  74.    请参考帮助-脚本入门-字符串-内嵌表达式相关内容。
  75.    它可以用来在任务的名称和简介那里显示变量。
  76.    常用的表达式(注意不要漏了井号和大括号):
  77.    #{$game_variables[n]}       ——插入n号变量的值
  78.    #{$game_party.item_no(n)}  —— 插入持有n号物品数量
  79.                                   同理还有 weapon_no,armor_no
  80.  
  81.    还可以预先定义一个变量,再插入(例子见示例任务3-灵魂线)
  82.    
  83.   2.2、注意事项
  84.  
  85.    2.2.1、括号、逗号和双引号 [ ] , " 必须使用半角符号(英文输入),
  86.           引号内的内容则没有关系
  87.           
  88.    2.2.2、单引号 ' 和双引号 " 的区别:
  89.           为了不出错误,全部用双引号吧!当然如果你对Ruby很熟悉,那就没所谓了
  90.  
  91.   2.3、开始设置吧!
  92.   从107行开始设置任务数据,可以参考示例任务来设置,请仔细阅读附加讲解
  93.  
  94.  3、接受任务
  95.  
  96.  事件里的「脚本」指令输入:get_task(任务ID)
  97.  例如 get_task(1) 就是接受1号任务
  98.  
  99.   3.1、获得全部任务
  100.  
  101.   事件里的「脚本」指令输入:get_all_task
  102.   这个功能基本上是用来在编写好所有任务数据后测试排版的
  103.  
  104.  
  105.  4、完成/删除任务
  106.  
  107.  事件里的「脚本」指令输入:finish_task(任务ID)
  108.  例如 finish_task(1) 就是完成1号任务
  109.  
  110.  注意:本脚本不负责完成任务后的奖励之类的东西,请自行在事件中判断,
  111.        这里的完成任务指的是从任务列表中删去此任务
  112.  
  113.   4.1、删除全部任务
  114.  
  115.   事件里的「脚本」指令输入:finish_all_task
  116.   作为获得全部任务的对应功能存在,似乎不会怎么用到
  117. =end
  118.  
  119. class Scene_Task
  120.   # 这里设置任务内容翻页音效
  121.   CHANGE_PAGE_SE = "Audio/SE/Book"
  122. end
  123.  
  124. class Game_Party
  125.   #--------------------------------------------------------------------------
  126.   # ● 设置任务资料
  127.   #--------------------------------------------------------------------------
  128.   def get_tasks_info
  129.     @tasks_info = []
  130.  
  131.  
  132.     名称 = "\\c[6]火红女皇"
  133.  
  134.     简介 = "\\c[2]主线任务
  135.  
  136. \\c[3]任务目标:
  137. 获得火红女皇的主板
  138.  
  139. \\c[6]提示:
  140. \\c[0]火红女皇就在智能中心,杀死火红女皇将得到主板。"
  141.     @tasks_info[1] = Game_Task.new(名称, 简介)
  142.  
  143.  
  144.     名称 = "\\c[6]火红女皇\\i[63]"
  145.  
  146.     简介 = "\\c[2]主线任务【已完成】
  147.  
  148. \\c[3]任务目标:
  149. 获得火红女皇的主板
  150.  
  151. \\c[6]提示:
  152. \\c[0]。
  153.  
  154. 任务奖励:
  155. \\c[Hff0000]C级支线剧情1个
  156. 奖励点:2000"
  157.     @tasks_info[2] = Game_Task.new(名称, 简介)
  158.  
  159.  
  160.   end
  161. end
  162. #==============================================================================
  163. # ■ Interpreter
  164. #------------------------------------------------------------------------------
  165. #  执行事件命令的解释器。本类在 Game_System 类
  166. # 与 Game_Event 类的内部使用。
  167. #==============================================================================
  168.  
  169. class Game_Interpreter
  170.   #--------------------------------------------------------------------------
  171.   # ● 接受任务
  172.   #--------------------------------------------------------------------------
  173.   def get_task(id)
  174.     task = $game_party.tasks_info[id]
  175.     return true if (task.nil? or $game_party.current_tasks.include?(task.id))
  176.     $game_party.current_tasks.unshift(task.id)
  177.     return true
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 获得全部任务
  181.   #--------------------------------------------------------------------------
  182.   def get_all_task
  183.     # 清空当前任务
  184.     $game_party.current_tasks.clear
  185.     for task in $game_party.tasks_info
  186.       next if task.nil?
  187.       $game_party.current_tasks.unshift(task.id)
  188.     end
  189.     return true
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # ● 完成/放弃任务
  193.   #--------------------------------------------------------------------------
  194.   def finish_task(id)
  195.     task = $game_party.tasks_info[id]
  196.     return true if task.nil?
  197.     $game_party.current_tasks.delete(task.id)
  198.     return true
  199.   end
  200.   #--------------------------------------------------------------------------
  201.   # ● 删除全部任务
  202.   #--------------------------------------------------------------------------
  203.   def finish_all_task
  204.     $game_party.current_tasks.clear
  205.     return true
  206.   end
  207. end
  208.  
  209. #==============================================================================
  210. # ■ Game_Party
  211. #------------------------------------------------------------------------------
  212. #  处理同伴的类。包含金钱以及物品的信息。本类的实例
  213. # 请参考 $game_party。
  214. #==============================================================================
  215.  
  216. class Game_Party
  217.   #--------------------------------------------------------------------------
  218.   # ● 定义实例变量
  219.   #--------------------------------------------------------------------------
  220.   attr_writer     :latest_task                  # 上次查看的任务
  221.   #--------------------------------------------------------------------------
  222.   # ● 取得任务资料
  223.   #--------------------------------------------------------------------------
  224.   def tasks_info
  225.     if @tasks_info.nil?
  226.       get_tasks_info
  227.     end
  228.     return @tasks_info
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ● 取得当前任务
  232.   #--------------------------------------------------------------------------
  233.   def current_tasks
  234.     if @current_tasks.nil?
  235.       @current_tasks = []
  236.     end
  237.     return @current_tasks
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ● 上次查看的任务
  241.   #--------------------------------------------------------------------------
  242.   def latest_task
  243.     if !current_tasks.include?(@latest_task)
  244.       @latest_task = current_tasks[0]
  245.     end
  246.     return @latest_task
  247.   end
  248. end
  249.  
  250. #==============================================================================
  251. # ■ Game_Task
  252. #------------------------------------------------------------------------------
  253. #  处理任务的类。包含任务的信息。
  254. #==============================================================================
  255.  
  256. class Game_Task
  257.   attr_accessor   :name                   # 名称
  258.   attr_accessor   :briefing               # 简介
  259.   def initialize(name, briefing)
  260.     @name = name
  261.     @briefing = briefing
  262.   end
  263.   def height
  264.     text = @briefing.clone
  265.     x = 0
  266.     y = 64
  267.     min_y = 0
  268.     # 限制文字处理
  269.     begin
  270.       last_text = text.clone
  271.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  272.     end until text == last_text
  273.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  274.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  275.     end
  276.     # 为了方便、将 "\\\\" 变换为 "\000"
  277.     text.gsub!(/\\\\/) { "\000" }
  278.     # "\C" 变为 "\001"
  279.     text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  280.     # "\I" 变为 "\002"
  281.     text.gsub!(/\\[Ii]/) { "\002" }
  282.     # "\P" 变为 "\003"
  283.     text.gsub!(/\\[Pp]/) { "\003" }
  284.     # c 获取 1 个字 (如果不能取得文字就循环)
  285.     while ((c = text.slice!(/./m)) != nil)
  286.       # \\ 的情况下
  287.       if c == "\000"
  288.         # 还原为本来的文字
  289.         c = "\\"
  290.       end
  291.       # \C[n] 的情况下
  292.       if c == "\001"
  293.         # 更改文字色
  294.         text.sub!(/\[([0-9a-zA-Z]+)\]/, "")
  295.         # 下面的文字
  296.         next
  297.       end
  298.       # 图标的情况下
  299.       if c == "\002"
  300.         icon_name = ''
  301.         while ((cha = text.slice!(/./m)) != ']')
  302.           next if cha == '['
  303.           icon_name += cha
  304.         end
  305.         if x + 24 > 368
  306.           x = 0
  307.           y += [24, min_y].max
  308.           min_y = 0
  309.         end
  310.         x += 28
  311.         next
  312.       end
  313.       # 图片的情况下
  314.       if c == "\003"
  315.         pic_name = ''
  316.         while ((cha = text.slice!(/./m)) != ']')
  317.           next if cha == '['
  318.           pic_name += cha
  319.         end
  320.         pic = Cache.picture(pic_name)
  321.         if x + pic.width > 368
  322.           x = 0
  323.           y += [24, min_y].max
  324.           min_y = 0
  325.         end
  326.         x += pic.width
  327.         min_y = [pic.height, 24].max
  328.         next
  329.       end
  330.       # 另起一行文字的情况下
  331.       if c == "\n"
  332.         y += [24, min_y].max
  333.         min_y = 0
  334.         x = 0
  335.         # 下面的文字
  336.         next
  337.       end
  338.       # 自动换行处理
  339.       if x + 22 > 368
  340.         y += [24, min_y].max
  341.         min_y = 0
  342.         x = 0
  343.       end
  344.       # x 为要描绘文字的加法运算
  345.       x += 22
  346.     end
  347.     return (y + [24, min_y].max)
  348.   end
  349.   def id
  350.     return $game_party.tasks_info.index(self)
  351.   end
  352. end
  353.  
  354. #==============================================================================
  355. # ■ Window_Task_Name
  356. #------------------------------------------------------------------------------
  357. #  任务名称显示窗口。
  358. #==============================================================================
  359.  
  360. class Window_Task_Name < Window_Selectable
  361.   #--------------------------------------------------------------------------
  362.   # ● 初始化对像
  363.   #--------------------------------------------------------------------------
  364.   def initialize(tasks)
  365.     super(0, 0, 204, 416)
  366.     @tasks = []
  367.     for id in tasks
  368.       @tasks.push($game_party.tasks_info[id])
  369.     end
  370.     @item_max = tasks.size
  371.     self.contents = Bitmap.new(
  372.     self.width - 32, @item_max == 0 ? 32 : @item_max * 32)
  373.     refresh
  374.     self.index = 0
  375.   end
  376.   #--------------------------------------------------------------------------
  377.   # ● 刷新
  378.   #--------------------------------------------------------------------------
  379.   def refresh
  380.     self.contents.clear
  381.     if @tasks != []
  382.       for task in @tasks
  383.         draw_item(task)
  384.       end
  385.     else
  386.       draw_blank
  387.     end
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # ● 描绘项目
  391.   #--------------------------------------------------------------------------
  392.   def draw_item(task)
  393.     text = task.name.clone
  394.     y = @tasks.index(task) * WLH
  395.     chenge_special_character(text, 0, y)
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● 描绘空行
  399.   #--------------------------------------------------------------------------
  400.   def draw_blank
  401.     self.contents.font.color = Color.new(255, 255, 255, 128)
  402.     rect = Rect.new(4, 0, self.contents.width - 8, 32)
  403.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  404.     self.contents.draw_text(rect, '无任何任务')
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   # ● 获取任务
  408.   #--------------------------------------------------------------------------
  409.   def task
  410.     return @tasks[self.index]
  411.   end
  412. end
  413.  
  414. #==============================================================================
  415. # ■ Window_Task
  416. #------------------------------------------------------------------------------
  417. #  任务内容显示窗口。
  418. #==============================================================================
  419.  
  420. class Window_Task < Window_Base
  421.   #--------------------------------------------------------------------------
  422.   # ● 初始化对像
  423.   #--------------------------------------------------------------------------
  424.   def initialize(task_id)
  425.     super(204, 0, 340, 416)
  426.     refresh(task_id)
  427.   end
  428.   #--------------------------------------------------------------------------
  429.   # ● 刷新内容
  430.   #--------------------------------------------------------------------------
  431.   def refresh(task_id)
  432.     self.oy = 0
  433.     self.visible = true
  434.     return if task_id.nil?
  435.     task = $game_party.tasks_info[task_id]
  436.     if !task.nil?
  437.       self.contents = Bitmap.new(self.width - 32, task.height)
  438.     else
  439.       self.contents = Bitmap.new(self.width - 32, self.height - 32)
  440.       return
  441.     end
  442.     self.contents.font.color = normal_color
  443.     # 描绘任务内容
  444.     draw_task_info(task)
  445.   end
  446.   #--------------------------------------------------------------------------
  447.   # ● 描绘任务内容
  448.   #--------------------------------------------------------------------------
  449.   def draw_task_info(task)
  450.     self.contents.font.color = normal_color
  451.     # 描绘任务简介
  452.     chenge_special_character(task.briefing.clone)
  453.   end
  454. end
  455.  
  456. class Window_Base < Window
  457.   def chenge_special_character(text, x=0, y=0)
  458.     # 记录换行时y坐标最小加值
  459.     min_y = 0
  460.     # 限制文字处理
  461.     begin
  462.       last_text = text.clone
  463.       text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  464.     end until text == last_text
  465.     text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  466.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  467.     end
  468.     # 为了方便、将 "\\\\" 变换为 "\000"
  469.     text.gsub!(/\\\\/) { "\000" }
  470.     # "\C" 变为 "\001"
  471.     text.gsub!(/\\[Cc]\[([0-9a-zA-Z]+)\]/)  { "\001[#{$1}]" }
  472.     # "\I" 变为 "\002"
  473.     text.gsub!(/\\[Ii]/) { "\002" }
  474.     # "\P" 变为 "\003"
  475.     text.gsub!(/\\[Pp]/) { "\003" }
  476.     # c 获取 1 个字 (如果不能取得文字就循环)
  477.     while ((c = text.slice!(/./m)) != nil)
  478.       # \\ 的情况下
  479.       if c == "\000"
  480.         # 还原为本来的文字
  481.         c = "\\"
  482.       end
  483.       # \C[n] 的情況下
  484.       if c == "\001"
  485.         # 更改文字色
  486.         text.sub!(/\[([0-9a-zA-Z]+)\]/, "")
  487.         # 如果是设定RGB颜色
  488.         if $1[0,1]=="H"
  489.           # 先拷贝一下文字
  490.           c=$1.dup
  491.           # 分3段分别取出R,G,B颜色
  492.           c.sub!(/H([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/, "")
  493.           # 设定文字颜色
  494.           self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16))
  495.         else
  496.           color = $1.to_i
  497.           if color >= 0 and color <= 31
  498.             self.contents.font.color = text_color(color)
  499.           elsif color == 32
  500.             self.contents.font.color = disabled_color
  501.           elsif color == 33
  502.             self.contents.font.color = system_color
  503.           end
  504.         end
  505.         # 下面的文字
  506.         next
  507.       end
  508.       # 图标的情况下
  509.       if c == "\002"
  510.         icon_name = ''
  511.         while ((cha = text.slice!(/./m)) != ']')
  512.           next if cha == '['
  513.           icon_name += cha
  514.         end
  515.         if x + 24 > self.contents.width
  516.           x = 0
  517.           y += [WLH, min_y].max
  518.           min_y = 0
  519.         end
  520.         draw_icon(icon_name.to_i, x+4, y+4, true)
  521.         x += 28
  522.         next
  523.       end
  524.       # 图片的情况下
  525.       if c == "\003"
  526.         pic_name = ''
  527.         while ((cha = text.slice!(/./m)) != ']')
  528.           next if cha == '['
  529.           pic_name += cha
  530.         end
  531.         pic = Cache.picture(pic_name)
  532.         if x + pic.width > self.contents.width
  533.           x = 0
  534.           y += [WLH, min_y].max
  535.           min_y = 0
  536.         end
  537.         self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height))
  538.         x += pic.width
  539.         min_y = [pic.height, WLH].max
  540.         next
  541.       end
  542.       # 另起一行文字的情况下
  543.       if c == "\n"
  544.         y += [WLH, min_y].max
  545.         min_y = 0
  546.         x = 0
  547.         # 下面的文字
  548.         next
  549.       end
  550.       # 自动换行处理
  551.       if x + self.contents.text_size(c).width > self.contents.width
  552.         y += [WLH, min_y].max
  553.         min_y = 0
  554.         x = 0
  555.       end
  556.       # 描绘文字
  557.       self.contents.draw_text(4 + x, y, 40, WLH, c)
  558.       # x 为要描绘文字的加法运算
  559.       x += self.contents.text_size(c).width
  560.     end
  561.   end
  562. end
  563.  
  564. class Game_Party < Game_Unit
  565.   def item_no(n)
  566.     return item_number($data_items[n])
  567.   end
  568.   def weapon_no(n)
  569.     return item_number($data_weapons[n])
  570.   end
  571.   def armor_no(n)
  572.     return item_number($data_armors[n])
  573.   end
  574. end
  575.  
  576. #==============================================================================
  577. # ■ Scene_Task
  578. #------------------------------------------------------------------------------
  579. #  处理任务画面的类。
  580. #==============================================================================
  581.  
  582. class Scene_Task < Scene_Base
  583.   def initialize(index=nil)
  584.     @menu_index = index
  585.   end
  586.   #--------------------------------------------------------------------------
  587.   # ● 主处理
  588.   #--------------------------------------------------------------------------
  589.   def start
  590.     # 刷新任务资料
  591.     $game_party.get_tasks_info
  592.     # 生成任务名称窗口
  593.     @task_names_window = Window_Task_Name.new($game_party.current_tasks)
  594.     @task_names_window.active = true
  595.     if $game_party.current_tasks != []
  596.       @task_names_window.index = $game_party.current_tasks.index($game_party.latest_task)
  597.     end
  598.     # 生成任务内容窗口
  599.     @task_info_window = Window_Task.new($game_party.latest_task)
  600.     @task_info_window.active = true
  601.   end
  602.  
  603.   def terminate
  604.     # 释放窗口
  605.     @task_names_window.dispose
  606.     @task_info_window.dispose
  607.   end
  608.   #--------------------------------------------------------------------------
  609.   # ● 刷新画面
  610.   #--------------------------------------------------------------------------
  611.   def update
  612.     # 刷新窗口
  613.     @task_names_window.update
  614.     @task_info_window.update
  615.     update_task_names_window
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # ● 刷新任务名称窗口
  619.   #--------------------------------------------------------------------------
  620.   def update_task_names_window
  621.     # 按下 B 键的情况下
  622.     if Input.trigger?(Input::B)
  623.       # 演奏取消 SE
  624.       Sound.play_cancel
  625.       # 这里设置返回的场景,返回地图是Scene_Map.new,菜单是Scene_Menu.new(任务界面index)
  626.       if @menu_index == nil
  627.         $scene = Scene_Map.new
  628.       else
  629.         $scene = Scene_Menu.new(@menu_index)
  630.       end
  631.       return
  632.     end
  633.     # 按下 C 键的情况下
  634.     if Input.trigger?(Input::C)
  635.       # 无任务可显示的话
  636.       if @task_names_window.task == nil
  637.         # 演奏冻结 SE
  638.         Sound.play_buzzer
  639.         return
  640.       end
  641.       # 如果光标没有移动的话,翻页
  642.       if $game_party.latest_task == @task_names_window.task.id
  643.         if @task_info_window.oy + @task_info_window.height - 32 > @task_info_window.contents.height
  644.           @task_info_window.oy = 0
  645.         else
  646.           @task_info_window.oy += 480-32
  647.         end
  648.  
  649.       else
  650.         @task_info_window.refresh(@task_names_window.task.id)
  651.         $game_party.latest_task = @task_names_window.task.id
  652.         # 演奏确定 SE
  653.         Sound.play_decision
  654.       end
  655.     end
  656.   end
  657. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-3-29 17:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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