Project1
标题:
怎样在菜单栏中增加“任务”选项
[打印本页]
作者:
小小小蚩尤
时间:
2012-2-20 20:58
标题:
怎样在菜单栏中增加“任务”选项
现在又了任务系统,可以用事件脚本调出来看,,
我想能不能直接从菜单栏上增加这样的选项可以方便随时观看任务领取情况和交付情况
附上代码
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 finish
@finished = true
end
end
class Game_Party < Game_Unit
alias old_init initialize
def initialize
old_init
@tasks = {}
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
复制代码
任务领取脚本:事件脚本
$game_party.get_task(1,"艾格蓝山酒","艾格蓝山
闻名大陆的酒,大叔的最爱。
赶快到酒馆买吧。
没钱?找到黛芙妮问她要吧")
这是观看任务脚本:事件脚本
SceneManager.call(Scene_Task)
这是交任务脚本:事件脚本
$game_party.finish_task(1)
麻烦你们了!!!!!
dsu_plus_rewardpost_czw
作者:
嗨。猪头
时间:
2012-2-21 08:17
http://rpg.blue/forum.php?mod=vi ... D368%26typeid%3D368
多搜搜就好了
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1