赞 | 1 |
VIP | 7 |
好人卡 | 9 |
积分 | 1 |
经验 | 7021 |
最后登录 | 2014-11-30 |
在线时间 | 140 小时 |
Lv1.梦旅人 小黑
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 140 小时
- 注册时间
- 2011-8-23
- 帖子
- 536
|
把这个东西放进菜单里面也是个不错的选择- #用法:
- #领取任务:$game_party.get_task(任意数字,任务名称,任务描述)
- #完成任务:$game_party.finish_task(领取任务时设定的数字)
- #如:前面有事件$game_party.get_task(1,"测试","只是测试")
- #后面完成任务的脚本就是$game_party.finish_task(1)
- #召唤任务界面:SceneManager.call(Scene_Task)
- 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
- class Window_MenuCommand < Window_Command
- alias add_original_commands_task_zabing add_original_commands
- def add_original_commands
- add_original_commands_task_zabing
- add_command("任务", :maphint)
- end
- end
- class Scene_Menu < Scene_MenuBase
- alias create_command_window_task_zabing create_command_window
- def create_command_window
- create_command_window_task_zabing
- @command_window.set_handler(:maphint, method(:command_maphint))
- end
- def command_maphint
- SceneManager.call(Scene_Task)
- end
- end
复制代码 |
|