=begin
领取任务:$game_party.get_task(任意数字,任务名称,任务描述)
完成任务:$game_party.finish_task(领取任务时设定的数字)
对已有任务追加说明:$game_party.add_task(任务编号,任务追加描述)
如:
前面有事件$game_party.get_task(1,"测试","只是测试")
此时任务1的说明为
>只是测试
后面完成任务的脚本就是$game_party.finish_task(1)
追加说明$game_party.add_task(1,"真的只是测试哦")
此时任务1的说明为:
>只是测试
>真的只是测试哦
召唤任务界面:SceneManager.call(Scene_Task)
该脚本来自66rpg,发布者:韩云溪
改进:工藤由纪(论坛ID:zyyczp)
=end
#===========================================================
#●任务系统
#===========================================================
class Task
attr_reader :desc
attr_reader :finished
def initialize(origin_name,desc)
@origin_name = origin_name
@desc = desc
@finished = false
end
def name
if @finished
return @origin_name + "(完成)"
else
return @origin_name
end
end
def desc=(desc)
@desc = desc
end
def finish
@finished = true
end
end
class Game_Party < Game_Unit
alias old_init initialize
def initialize
old_init
@tasks = {}
end
def add_task(i,desc)
@tasks[i].desc = @tasks[i].desc + "\n" + desc
end
def get_task(i,name,desc)
@tasks[i]=Task.new(name,desc)
end
def have_task?(i)
@tasks[i] != nil
end
def finish_task(i)
@tasks[i].finish if have_task?(i)
end
def unfinished_tasks
n = []
for i in @tasks.values
next if i.finished
n.push(i)
end
return n
end
def finished_tasks
n = []
for i in @tasks.values
next unless i.finished
n.push(i)
end
return n
end
end
class Window_Task_Type < Window_HorzCommand
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 0)
activate
end
def window_width
return Graphics.width
end
def col_max
return 3
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
add_command("未完成任务", :unfinished_task)
add_command("已完成任务", :finished_task)
add_command("取消", :cancel)
end
end
class Window_TaskLeft < Window_Selectable
attr_reader :finished
def initialize
super(0,48,160,Graphics.height - 48)
create_contents
@finished = false
@index = 0
refresh
deactivate
end
def set_finish(finish)
@finished = finish
set_item_max
end
def item_max
return @item_max != nil ? @item_max : 0
end
def set_item_max
if @finished
@item_max = $game_party.finished_tasks.size
else
@item_max = $game_party.unfinished_tasks.size
end
end
def refresh
set_item_max
super
end
#--------------------------------------------------------------------------
# ● 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
text = ""
unless @finished
if $game_party.unfinished_tasks[index] != nil
text = $game_party.unfinished_tasks[index].name
end
else
if $game_party.finished_tasks[index] != nil
text = $game_party.finished_tasks[index].name
end
end
draw_text(item_rect_for_text(index), text)
end
end
class Window_TaskRight < Window_Base
attr_reader :left_index
def initialize
super(160,48,Graphics.width - 160,Graphics.height - 48)
create_contents
@left_index = 0
@finished = false
refresh
end
def set_index(i)
@left_index = i
refresh
end
def set_finish(i)
@finished = i
end
def refresh
contents.clear
draw_desc
end
def draw_desc
if @finished
if $game_party.finished_tasks[@left_index] != nil
draw_text_ex(0,0,$game_party.finished_tasks[@left_index].desc)
end
else
if $game_party.unfinished_tasks[@left_index] != nil
draw_text_ex(0,0,$game_party.unfinished_tasks[@left_index].desc)
end
end
end
end
class Scene_Task < Scene_Base
def start
super
create_task_type_window
create_left_window
create_right_window
end
def update
super
if @left_window.active
if Input.trigger?(:B)
@left_window.deactivate
@task_type_window.activate
end
if Input.trigger?(:UP) || Input.trigger?(:DOWN)
@right_window.set_finish(@left_window.finished)
@right_window.set_index(@left_window.index)
end
end
end
def terminate
super
end
def create_task_type_window
@task_type_window = Window_Task_Type.new
@task_type_window.set_handler(:unfinished_task,method(:view_unfinished_task))
@task_type_window.set_handler(:finished_task,method(:view_finished_task))
@task_type_window.set_handler(:cancel,method(:return_scene))
end
def create_left_window
@left_window = Window_TaskLeft.new
@left_window.set_finish(false)
@left_window.refresh
end
def create_right_window
@right_window = Window_TaskRight.new
@right_window.refresh
end
def view_unfinished_task
@left_window.set_finish(false)
@left_window.refresh
@left_window.activate
@task_type_window.deactivate
@right_window.set_finish(false)
@right_window.set_index(@left_window.index)
end
def view_finished_task
@left_window.set_finish(true)
@left_window.refresh
@left_window.activate
@task_type_window.deactivate
@right_window.set_finish(true)
@right_window.set_index(@left_window.index)
end
end