class Game_Party |
#-------------------------------------------------------------------------- |
# ● 設置任務資料 |
#-------------------------------------------------------------------------- |
def get_tasks_info |
@tasks_info = [] |
|
|
name = "\\c[9]帮助" |
intro = "狂版RTAB ver 0.24PF |
\\c[9]操作说明: |
A(Shift):决定使用回声 |
(注:回声就是右下角的星星,攒足一定的攻击数可以攻击力翻倍) |
B(X):取消 |
C(C):确定 |
X(A):攻击的快捷键 |
Y(S):技能快捷键 |
Z(D):防御快捷键 |
L(Q):物品快捷键 |
R(W):逃跑快捷键 |
(具体看F1设定) |
请进入菜单,调整角色设置. |
注:回声只对物理技能有效 |
|
" |
@tasks_info[2] = Game_Task.new(name, intro) |
|
|
name = "\\c[9]连携技能演示" |
intro = "冰刃+寒冰斩=落霜剑 |
落雷术+奔雷斩=天雷破 |
爆发术+V型斩=幻胧术 |
" |
@tasks_info[1] = Game_Task.new(name, intro) |
end |
end |
|
#============================================================================== |
# ■ Interpreter |
#------------------------------------------------------------------------------ |
# 执行事件命令的解释器。本类在 Game_System 类 |
# 与 Game_Event 类的内部使用。 |
#============================================================================== |
class Game_Interpreter |
#-------------------------------------------------------------------------- |
# ● 接受任务 |
#-------------------------------------------------------------------------- |
def get_task(id) |
task = $game_party.tasks_info[id] |
return true if (task.nil? or $game_party.current_tasks.include?(task.id)) |
$game_party.current_tasks.unshift(task.id) |
return true |
end |
#-------------------------------------------------------------------------- |
# ● 获得全部任务 |
#-------------------------------------------------------------------------- |
def get_all_task |
# 清空当前任务 |
$game_party.current_tasks.clear |
for task in $game_party.tasks_info |
next if task.nil? |
$game_party.current_tasks.unshift(task.id) |
end |
return true |
end |
#-------------------------------------------------------------------------- |
# ● 完成/放弃任务 |
#-------------------------------------------------------------------------- |
def finish_task(id) |
task = $game_party.tasks_info[id] |
return true if task.nil? |
$game_party.current_tasks.delete(task.id) |
return true |
end |
#-------------------------------------------------------------------------- |
# ● 删除全部任务 |
#-------------------------------------------------------------------------- |
def finish_all_task |
$game_party.current_tasks.clear |
return true |
end |
end |
#============================================================================== |
# ■ Game_Party |
#------------------------------------------------------------------------------ |
# 处理队伍的类。包含金钱以及物品的信息。 |
# 这个类的实例请参考 $game_party 。 |
#============================================================================== |
class Game_Party |
#-------------------------------------------------------------------------- |
# ● 定义实例变量 |
#-------------------------------------------------------------------------- |
attr_writer :latest_task # 上次查看任务 |
#-------------------------------------------------------------------------- |
# ● 取得任务资料 |
#-------------------------------------------------------------------------- |
def tasks_info |
if @tasks_info.nil? |
get_tasks_info |
end |
return @tasks_info |
end |
#-------------------------------------------------------------------------- |
# ● 取得当前任务 |
#-------------------------------------------------------------------------- |
def current_tasks |
if @current_tasks.nil? |
@current_tasks = [] |
end |
return @current_tasks |
end |
#-------------------------------------------------------------------------- |
# ● 上次查看任务 |
#-------------------------------------------------------------------------- |
def latest_task |
if !current_tasks.include?(@latest_task) |
@latest_task = current_tasks[0] |
end |
return @latest_task |
end |
end |
#============================================================================== |
# ■ Game_Task |
#------------------------------------------------------------------------------ |
# 处理任务的类。包含任务信息。 |
#============================================================================== |
class Game_Task |
attr_accessor :name # 名称 |
attr_accessor :briefing # 简介 |
def initialize(name, briefing) |
@name = name |
@briefing = briefing |
end |
def height |
text = @briefing.clone |
x = 0 |
y = 64 |
min_y = 0 |
# 限制文字处理 |
begin |
last_text = text.clone |
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } |
end until text == last_text |
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do |
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : "" |
end |
# 為了方便、將 "\\\\" 變換為 "\000" |
text.gsub!(/\\\\/) { "\000" } |
# "\C" 變為 "\001" |
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" } |
# "\I" 變為 "\002" |
text.gsub!(/\\[Ii]/) { "\002" } |
# "\P" 變為 "\003" |
text.gsub!(/\\[Pp]/) { "\003" } |
# c 獲取 1 個字 (如果不能取得文字就循環) |
while ((c = text.slice!(/./m)) != nil) |
# \\ 的情況下 |
if c == "\000" |
# 還原為本來的文字 |
c = "\\" |
end |
# \C[n] 的情況下 |
if c == "\001" |
# 更改文字色 |
text.sub!(/\[([0-9]+)\]/, "") |
# 下面的文字 |
next |
end |
# 圖標的情況下 |
if c == "\002" |
icon_name = '' |
while ((cha = text.slice!(/./m)) != ']') |
next if cha == '[' |
icon_name += cha |
end |
if x + 24 > 368 |
x = 0 |
y += [24, min_y].max |
min_y = 0 |
end |
x += 28 |
next |
end |
# 圖片的情況下 |
if c == "\003" |
pic_name = '' |
while ((cha = text.slice!(/./m)) != ']') |
next if cha == '[' |
pic_name += cha |
end |
pic = Cache.picture(pic_name) |
if x + pic.width > 368 |
x = 0 |
y += [32, min_y].max |
min_y = 0 |
end |
x += pic.width |
min_y = [pic.height, 32].max |
next |
end |
# 另起一行文字的情況下 |
if c == " " |
y += [24, min_y].max |
min_y = 0 |
x = 0 |
# 下面的文字 |
next |
end |
# 自動換行處理 |
if x + 22 > 368 |
y += [24, min_y].max |
min_y = 0 |
x = 0 |
end |
# x 為要描繪文字的加法運算 |
x += 22 |
end |
return (y + [24, min_y].max) |
end |
def id |
return $game_party.tasks_info.index(self) |
end |
end |
#============================================================================== |
# ■ Window_Task_Name |
#------------------------------------------------------------------------------ |
# 任務名稱顯示窗口。 |
#============================================================================== |
class Window_Task_Name < Window_Selectable |
#-------------------------------------------------------------------------- |
# ● 初始化對像 |
#-------------------------------------------------------------------------- |
def initialize(tasks) |
super(0, 0, 192, 416) |
@tasks = [] |
for id in tasks |
@tasks.push($game_party.tasks_info[id]) |
end |
@item_max = tasks.size |
self.contents = Bitmap.new( |
self.width - 32, @item_max == 0 ? 32 : @item_max * 32) |
refresh |
self.index = 0 |
end |
#-------------------------------------------------------------------------- |
# ● 刷新 |
#-------------------------------------------------------------------------- |
def refresh |
self.contents.clear |
if @tasks != [] |
for task in @tasks |
draw_item(task) |
end |
else |
draw_blank |
end |
end |
|
|
#-------------------------------------------------------------------------- |
# ● 描繪空行 |
#-------------------------------------------------------------------------- |
def draw_blank |
self.contents.font.color = disabled_color |
rect = Rect.new(4, 0, self.contents.width - 8, 32) |
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) |
self.contents.draw_text(rect, '没有任务') |
end |
|
#-------------------------------------------------------------------------- |
# ● 描繪項目 |
#-------------------------------------------------------------------------- |
def draw_item(task) |
text = task.name.clone |
x = 0 |
y = @tasks.index(task) * WLH |
# 限制文字處理 |
begin |
last_text = text.clone |
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } |
end until text == last_text |
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do |
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : "" |
end |
# 為了方便、將 "\\\\" 變換為 "\000" |
text.gsub!(/\\\\/) { "\000" } |
# "\\C" 變為 "\001" |
text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" } |
# "\I" 變為 "\002" |
text.gsub!(/\\[Ii]/) { "\002" } |
# "\P" 變為 "\003" |
text.gsub!(/\\[Pp]/) { "\003" } |
# c 獲取 1 個字 (如果不能取得文字就循環) |
while ((c = text.slice!(/./m)) != nil) |
# \\ 的情況下 |
if c == "\000" |
# 還原為本來的文字 |
c = "\\" |
end |
# \C[n] 的情況下 |
if c == "\001" |
# 更改文字色 |
text.sub!(/\[([0-9a-zA-Z]+)\]/, "") |
# 如果是设定RGB颜色 |
if $1[0,1]=="H" |
# 先拷贝一下文字 |
c=$1.dup |
# 分3段分别取出R,G,B颜色 |
c.sub!(/H([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/, "") |
# 设定文字颜色 |
self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16)) |
next |
else |
color = $1.to_i |
if color >= 0 and color <= 7 |
self.contents.font.color = text_color(color) |
elsif color == 8 |
self.contents.font.color = disabled_color |
elsif color == 9 |
self.contents.font.color = system_color |
end |
end |
# 下面的文字 |
next |
end |
# 圖標的情況下 |
if c == "\002" |
icon_name = '' |
while ((cha = text.slice!(/./m)) != ']') |
next if cha == '[' |
icon_name += cha |
end |
if x + 24 > self.contents.width |
x = 0 |
y += [WLH, min_y].max |
min_y = 0 |
end |
draw_icon(icon_name.to_i, x+24, y+18, true) |
x += 28 |
next |
end |
# 圖片的情況下 |
if c == "\003" |
pic_name = '' |
while ((cha = text.slice!(/./m)) != ']') |
next if cha == '[' |
pic_name += cha |
end |
pic = Cache.picture(pic_name) |
if x + pic.width > self.contents.width |
x = 0 |
y += [WLH, min_y].max |
min_y = 0 |
end |
self.contents.blt(x + 4, y, pic, Rect.new(0, 0, pic.width, pic.height)) |
x += pic.width |
next |
end |
# 描繪文字 |
self.contents.draw_text(4 + x, y, 40, WLH, c) |
# x 為要描繪文字的加法運算 |
x += self.contents.text_size(c).width |
end |
end |
#-------------------------------------------------------------------------- |
# ● 獲取任務 |
#-------------------------------------------------------------------------- |
def task |
return @tasks[self.index] |
end |
end |
|
#============================================================================== |
# ■ Window_Task |
#------------------------------------------------------------------------------ |
# 任務內容顯示窗口。 |
#============================================================================== |
class Window_Task < Window_Base |
#-------------------------------------------------------------------------- |
# ● 初始化對像 |
#-------------------------------------------------------------------------- |
def initialize(task_id) |
super(192, 0, 352, 416) |
refresh(task_id) |
end |
#-------------------------------------------------------------------------- |
# ● 刷新內容 |
#-------------------------------------------------------------------------- |
def refresh(task_id) |
self.oy = 0 |
self.visible = true |
return if task_id.nil? |
task = $game_party.tasks_info[task_id] |
if !task.nil? |
if task.height < 128 |
self.contents = Bitmap.new(self.width - 32, self.height - 32) |
else |
self.contents = Bitmap.new(self.width - 32, task.height - 128) |
end |
else |
self.contents = Bitmap.new(self.width - 32, self.height - 64) |
return |
end |
self.contents.font.color = normal_color |
# 描繪任務內容 |
draw_task_info(task) |
end |
|
#-------------------------------------------------------------------------- |
# ● 描繪任務內容 |
#-------------------------------------------------------------------------- |
def draw_task_info(task) |
# 記錄文字x坐標 |
x = 0 |
# 記錄文字y坐標 |
y = 0 |
# 記錄換行時y坐標最小加值 |
min_y = 0 |
self.contents.font.color = normal_color |
# 描繪任務簡介 |
text = task.briefing.clone |
# 限制文字處理 |
begin |
last_text = text.clone |
text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] } |
end until text == last_text |
text.gsub!(/\\[Nn]\[([0-9]+)\]/) do |
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : "" |
end |
# 為了方便、將 "\\\\" 變換為 "\000" |
text.gsub!(/\\\\/) { "\000" } |
# "\C" 變為 "\001" |
text.gsub!(/\\[Cc]\[([0-9a-zA-Z]+)\]/) { "\001[#{$1}]" } |
#text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" } |
# "\I" 變為 "\002" |
text.gsub!(/\\[Ii]/) { "\002" } |
# "\P" 變為 "\003" |
text.gsub!(/\\[Pp]/) { "\003" } |
# c 獲取 1 個字 (如果不能取得文字就循環) |
while ((c = text.slice!(/./m)) != nil) |
# \\ 的情況下 |
if c == "\000" |
# 還原為本來的文字 |
c = "\\" |
end |
# \C[n] 的情況下 |
if c == "\001" |
# 更改文字色 |
text.sub!(/\[([0-9a-zA-Z]+)\]/, "") |
# 如果是设定RGB颜色 |
if $1[0,1]=="H" |
# 先拷贝一下文字 |
c=$1.dup |
# 分3段分别取出R,G,B颜色 |
c.sub!(/H([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})/, "") |
# 设定文字颜色 |
self.contents.font.color = Color.new($1.to_i(16), $2.to_i(16), $3.to_i(16)) |
else |
color = $1.to_i |
if color >= 0 and color <= 7 |
self.contents.font.color = text_color(color) |
elsif color == 8 |
self.contents.font.color = disabled_color |
elsif color == 9 |
self.contents.font.color = system_color |
end |
end |
# 下面的文字 |
next |
end |
|
# 圖標的情況下 |
if c == "\002" |
icon_name = '' |
while ((cha = text.slice!(/./m)) != ']') |
next if cha == '[' |
icon_name += cha |
end |
if x + 24 > self.contents.width |
x = 0 |
y += [WLH, min_y].max |
min_y = 0 |
end |
draw_icon(icon_name.to_i, x+24, y+18, true) |
x += 28 |
next |
end |
|
# 圖片的情況下 |
if c == "\003" |
pic_name = '' |
while ((cha = text.slice!(/./m)) != ']') |
next if cha == '[' |
pic_name += cha |
end |
pic = Cache.picture(pic_name) |
if x + pic.width > self.contents.width |
x = 0 |
y += [WLH, min_y].max |
min_y = 0 |
end |
self.contents.blt(x + 20, y +18, pic, Rect.new(0, 0, pic.width, pic.height)) |
x += pic.width |
min_y = [pic.height, WLH].max |
next |
end |
# 另起一行文字的情況下 |
if c == " " |
y += [WLH, min_y].max |
min_y = 0 |
x = 0 |
# 下面的文字 |
next |
end |
# 自動換行處理 |
if x + self.contents.text_size(c).width + 20 > self.contents.width |
y += [WLH, min_y].max |
min_y = 0 |
x = 0 |
end |
# 描繪文字 |
#self.contents.draw_text(4 + x, y, 40, 32, c) |
self.contents.draw_text(x + 20, y + 18, 40, WLH, c) |
# x 為要描繪文字的加法運算 |
x += self.contents.text_size(c).width |
end |
end |
end |
class Window_Base < Window |
def disabled_color |
return Color.new(255, 255, 255, 128) |
end |
end |
#============================================================================== |
# ■ Scene_Task |
#------------------------------------------------------------------------------ |
# 處理任務畫面的類。 |
#============================================================================== |
class Scene_Task < Scene_Base |
# 這裡設置任務內容翻頁音效 |
CHANGE_PAGE_SE = "Audio/SE/Book.ogg" |
|
#-------------------------------------------------------------------------- |
# ● 主處理 |
#-------------------------------------------------------------------------- |
def start |
# 刷新任務資料 |
$game_party.get_tasks_info |
# 生成任務名稱窗口 |
@task_names_window = Window_Task_Name.new($game_party.current_tasks) |
@task_names_window.z = 200 |
|
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 |
@task_info_window.update |
end |
|
def terminate |
# 釋放窗口 |
@task_names_window.dispose |
@task_info_window.dispose |
end |
#-------------------------------------------------------------------------- |
# ● 刷新畫面 |
#-------------------------------------------------------------------------- |
def update |
# 刷新窗口 |
@task_names_window.update |
@task_info_window.update |
|
if @task_names_window.active |
update_task_names_window |
else |
update_task_infos_window |
end |
|
end |
#-------------------------------------------------------------------------- |
# ● 刷新任務名稱窗口 |
#-------------------------------------------------------------------------- |
def update_task_names_window |
# 按下 B 鍵的情況下 |
if Input.trigger?(Input::B) |
# 演奏取消 SE |
Sound.play_cancel |
# 這裡設置返回的場景,返回地圖是Scene_Map.new,菜單是Scene_Menu.new(任務界面index) |
$scene = Scene_Map.new |
return |
end |
# 按下 C 鍵的情況下 |
if Input.trigger?(Input::C) |
# 無任務可顯示的話 |
if @task_names_window.task == nil |
# 演奏凍結 SE |
Sound.play_buzzer |
return |
end |
@task_info_window.refresh(@task_names_window.task.id) |
$game_party.latest_task = @task_names_window.task.id |
# 演奏確定 SE |
Sound.play_decision |
|
#@task_names_window.visible = false |
@task_names_window.active = false |
|
#@task_info_window.visible = true |
@task_info_window.update |
end |
end |
|
def update_task_infos_window |
# 按下 B 鍵的情況下 |
if Input.trigger?(Input::B) |
# 演奏取消 SE |
Sound.play_cancel |
|
#@task_names_window.visible = true |
@task_names_window.active = true |
#@task_info_window.visible = false |
@task_info_window.update |
|
return |
end |
# 按下 C 鍵的情況下 |
if Input.trigger?(Input::C) |
# 如果光標沒有移動的話,翻頁 |
#if @task_info_window.oy + @task_info_window.height - 64 > @task_info_window.contents.height |
if @task_info_window.oy + @task_info_window.height > @task_info_window.contents.height |
@task_info_window.oy = 0 |
else |
@task_info_window.oy += 416 - 64 |
end |
if @task_info_window.contents.height > @task_info_window.height - 64 |
# 演奏翻頁 SE |
Audio.se_play(CHANGE_PAGE_SE) |
end |
end |
end |
end |
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |