#==============================================================================02.# ■ 弹性滚动地图 V 1.00 BY SLICK03.#------------------------------------------------------------------------------04.# 处理主角的类。事件启动的判定、以及地图的滚动等功能。05.# 本类的实例请参考 $game_player。06.# 我:。。。这个黄金版已经被改的面目全非了07.#==============================================================================08. 09.class Game_Player < Game_Character10. MOVESPEA = 0.265625#这数值。。。囧11. def update_scroll(last_real_x, last_real_y)12. ax1 = $game_map.adjust_x(last_real_x)13. ay1 = $game_map.adjust_y(last_real_y)14. ax2 = $game_map.adjust_x(@real_x)15. ay2 = $game_map.adjust_y(@real_y)16. movespeb = (2 ** (@move_speed+1))*MOVESPEA17. movesped = movespeb / Graphics.width18. movespec = movespeb / Graphics.height19. tmp=center_x-ax220. $game_map.scroll_left(movesped*tmp) if tmp>021. $game_map.scroll_right(-movesped*tmp) if tmp<022. tmp=center_y-ay223. $game_map.scroll_up(movespec*tmp) if tmp>024. $game_map.scroll_down(-movespec*tmp) if tmp<0 25. end 26.end#==============================================================================
# 领取任务:$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