| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2015-6-5 |
| 在线时间 | 78 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 78 小时
- 注册时间
- 2011-6-29
- 回帖
- 11
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 feizhaodan 于 2012-11-23 22:31 编辑
本系統並非一般的觀看當前任務的系統
而是類似魔物獵人的接取任務的系統
是我接觸RGSS之後第一個作品
保證有BUG
應該用了很多很矬很土法煉鋼的方法
需要改進的部份也很多,麻煩各位前輩多多指教
使用方法請參考系統內註解
- #==============================================================================
- # ■ Window_QuestType
- #------------------------------------------------------------------------------
- # 任務列表顯示方式的選擇視窗。
- #==============================================================================
- class Window_QuestType < Window_Command
- #--------------------------------------------------------------------------
- # ● 物件初始化
- #--------------------------------------------------------------------------
- def initialize
- super(36, 150)
- deactivate
- self.openness = 0
- end
- #--------------------------------------------------------------------------
- # ● 項目的作成
- #--------------------------------------------------------------------------
- def make_command_list
- add_command("全部", :all_quests)
- add_command("未完成", :unfinished_quests)
- add_command("循環", :loop_quests)
- add_command("取消", :cancel)
- end
- end
复制代码
- #==============================================================================
- # ■ Window_QuestList
- #------------------------------------------------------------------------------
- # 任務列表選擇視窗。
- #==============================================================================
- class Window_QuestList < Window_Selectable
- attr_accessor :type
- attr_reader :quest_list
- #--------------------------------------------------------------------------
- # ● 物件初始化
- #--------------------------------------------------------------------------
- def initialize
- super(12,48,160, 300)
- create_contents
- @type = 0
- @index = 0
- activate
- end
- #--------------------------------------------------------------------------
- # ● 顯示類型的設定
- #--------------------------------------------------------------------------
- def set_type(n)
- @type = n
- set_item_max
- end
- #--------------------------------------------------------------------------
- # ● 項目數的取得
- #--------------------------------------------------------------------------
- def item_max
- return @item_max != nil ? @item_max : 0
- end
- #--------------------------------------------------------------------------
- # ● 項目數的計算
- #--------------------------------------------------------------------------
- def set_item_max
- @quest_list = []
- case @type
- when 0 #所有任務
- p = []
- q = []
- Quests::Quest_list.each { |h|
- if h['usability']
- #~ @quest_list.unshift h if h['finished'] == false || h['loop']
- #~ @quest_list.push h if h['finished'] && h['loop'] == false
- p.push h if h['finished'] == false || h['loop']
- q.push h if h['finished'] && h['loop'] == false
- end
- }
- @quest_list = p + q
- when 1 #未完成任務
- Quests::Quest_list.each { |h|
- if h['usability'] && h['finished'] == false
- @quest_list.push h
- end
- }
- when 2 #循環任務
- Quests::Quest_list.each { |h|
- if h['usability'] && h['loop']
- @quest_list.push h
- end
- }
- end
- @item_max = @quest_list.size
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- set_item_max
- super
- end
- #--------------------------------------------------------------------------
- # ● 項目的描畫
- #--------------------------------------------------------------------------
- def draw_item(index)
- text = ""
- if @quest_list[index] != nil
- text = @quest_list[index]['name']
- end
- if @quest_list[index]['loop']
- change_color(system_color)
- elsif @quest_list[index]['finished']
- change_color(gauge_back_color)
- else
- change_color(normal_color)
- end
- draw_text(item_rect_for_text(index), text)
- end
- #--------------------------------------------------------------------------
- # ● 獲取項目的繪制矩形(內容用)
- #--------------------------------------------------------------------------
- def item_rect_for_text(index)
- rect = item_rect(index)
- rect.x += 4
- rect.width = 160
- rect
- end
- end
复制代码
- #==============================================================================
- # ■ Window_QuestInfo
- #------------------------------------------------------------------------------
- # 任務列表顯示內容的視窗。
- #==============================================================================
- class Window_QuestInfo < Window_Base
- #~ attr_accessor :list_index
- attr_accessor :list_window
- #--------------------------------------------------------------------------
- # ● 物件初始化
- #--------------------------------------------------------------------------
- def initialize
- super(184,24,Graphics.width - 184,Graphics.height - 48)
- create_contents
- @list_index = 0
- #~ refresh
- deactivate
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_desc
- end
- #--------------------------------------------------------------------------
- # ● 描畫內容
- #--------------------------------------------------------------------------
- def draw_desc
- quest = @list_window.quest_list[@list_window.index]
- if quest != nil
- draw_text_ex( 0, 0, quest['info'])
- draw_text_ex( 0, 202, "經驗值:" + quest['exp'].to_s)
- draw_text_ex( 0, 226, "報酬金:" + quest['gold'].to_s)
- draw_text_ex( 0, 250, "\\c[20]已完成") if quest['finished']
- draw_text_ex( 0, 274, "\\c[16]可重覆進行") if quest['loop']
- draw_text_ex( 0, self.height - 48, "\\c[18]確定要接受這個任務嗎?") if self.active
- else
- draw_text_ex( 60, 160, "目前沒有可接受任務。")
- end
- end
- end
复制代码
- #==============================================================================
- # ■ Game_Party
- #------------------------------------------------------------------------------
- # パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
- # スのインスタンスは $game_party で参照されます。
- #==============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ● 以自訂腳本啟用任務的方法
- #--------------------------------------------------------------------------
- def get_quest(name)
- Quests::Quest_list.each do |h|
- if h['name'] == name
- h['usability'] = true
- break
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 以自訂腳本停用任務的方法
- #--------------------------------------------------------------------------
- def lost_quest(name)
- Quests::Quest_list.each do |h|
- if h['name'] == name
- h['usability'] = false
- break
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 以自訂腳本完成任務的方法
- #--------------------------------------------------------------------------
- def finish_quest(name)
- Quests::Quest_list.each do |h|
- if h['name'] == name
- h['finished'] = true
- break
- end
- end
- end
- end
复制代码
- #==============================================================================
- # ■ Scene_Quest
- #------------------------------------------------------------------------------
- # 處理任務場景的類。
- #==============================================================================
- class Scene_Quest < Scene_Base
- #--------------------------------------------------------------------------
- # ● 開始處理
- #--------------------------------------------------------------------------
- def start
- super
- create_list_window
- create_info_window
- create_type_window
- create_background
- create_check_window if $game_quest != nil
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def update
- super
- if @info_window.active
- action = 1
- elsif @list_window.active
- action = 2
- elsif @type_window.active
- action = 3
- elsif @check_window.active
- action = 4
- end
-
- case action
- when 1 #任務確認狀態
- if Input.trigger?(:C) #按下確定的情形
- Sound.play_ok
- $game_quest = @list_window.quest_list[@list_window.index]
- $game_temp.reserve_common_event($game_quest['ev_id'])
- Audio.me_play("Audio/ME/Item")
- return_scene
- end
- if Input.trigger?(:B) #按下取消的情形
- Sound.play_cancel
- @list_window.activate
- @info_window.deactivate
- @info_window.refresh
- end
- when 2
- if Input.trigger?(:A)
- show_type_window
- end
- if Input.trigger?(:UP) || Input.trigger?(:DOWN)
- @info_window.refresh
- end
- if Input.trigger?(:B)
- return_scene
- end
- if Input.trigger?(:C)
- if @list_window.quest_list.empty?
- Sound.play_cancel
- return_scene
- elsif crack_quest_state
- Sound.play_ok
- @list_window.deactivate
- @info_window.activate
- @info_window.refresh
- else
- Sound.play_buzzer
- end
- end
- when 3
- if Input.trigger?(:B)
- hide_type_window
- end
- when 4
- if Input.trigger?(:C)
- Audio.se_play("Audio/SE/Save")
- $game_quest = nil
- hide_check_window
- end
- if Input.trigger?(:B)
- Sound.play_cancel
- return_scene
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 終了処理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_background
- end
- #--------------------------------------------------------------------------
- # ● 任務類型視窗的生成
- #--------------------------------------------------------------------------
- def create_type_window
- @type_window = Window_QuestType.new
- @type_window.set_handler(:all_quests, method(:view_all_quests))
- @type_window.set_handler(:unfinished_quests,method(:view_unfinished_quests))
- @type_window.set_handler(:loop_quests,method(:view_loop_quests))
- @type_window.set_handler(:cancel,method(:hide_type_window))
- end
- #--------------------------------------------------------------------------
- # ● 任務清單視窗的生成
- #--------------------------------------------------------------------------
- def create_list_window
- @list_window = Window_QuestList.new
- #~ @list_window.set_finish(false)
- @list_window.refresh
- end
- #--------------------------------------------------------------------------
- # ● 任務內容視窗的生成
- #--------------------------------------------------------------------------
- def create_info_window
- @info_window = Window_QuestInfo.new
- @info_window.list_window=(@list_window)
- @info_window.refresh
- end
- #--------------------------------------------------------------------------
- # ● 取消任務視窗的生成
- #--------------------------------------------------------------------------
- def create_check_window
- @check_window = Window_Base.new(128, 184, 288, 48)
- @check_window.draw_text_ex( 0, 0, "已接受任務,要取消嗎?")
- @check_window.openness = 0
- @list_window.deactivate
- @list_window.opacity = 128
- @info_window.opacity = 128
- @check_window.activate
- @check_window.open
- end
- #--------------------------------------------------------------------------
- # ● 切換顯示所有任務
- #--------------------------------------------------------------------------
- def view_all_quests
- @list_window.type=(0)
- @list_window.index = 0
- hide_type_window
- end
- #--------------------------------------------------------------------------
- # ● 切換顯示未完成任務
- #--------------------------------------------------------------------------
- def view_unfinished_quests
- @list_window.type=(1)
- @list_window.index = 0
- hide_type_window
- end
- #--------------------------------------------------------------------------
- # ● 切換顯示循環任務
- #--------------------------------------------------------------------------
- def view_loop_quests
- @list_window.type=(2)
- @list_window.index = 0
- hide_type_window
- end
- #--------------------------------------------------------------------------
- # ● 隱藏任務類型視窗
- #--------------------------------------------------------------------------
- def hide_type_window
- @list_window.refresh
- @list_window.activate
- @list_window.opacity = 255
- @info_window.opacity = 255
- @info_window.refresh
- @type_window.deactivate
- @type_window.close
- #~ @type_window.hide
- end
- #--------------------------------------------------------------------------
- # ● 隱藏任務取消視窗
- #--------------------------------------------------------------------------
- def hide_check_window
- @list_window.activate
- @list_window.opacity = 255
- @info_window.opacity = 255
- @check_window.deactivate
- @check_window.close
- end
- #--------------------------------------------------------------------------
- # ● 顯示任務類型視窗
- #--------------------------------------------------------------------------
- def show_type_window
- @list_window.deactivate
- @list_window.opacity = 128
- @info_window.opacity = 128
- #~ @type_window.show
- @type_window.open
- @type_window.activate
- @type_window.index = @list_window.type
- end
- #--------------------------------------------------------------------------
- # ● 背景の作成
- #--------------------------------------------------------------------------
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(16, 16, 16, 128)
- end
- #--------------------------------------------------------------------------
- # ● 背景の解放
- #--------------------------------------------------------------------------
- def dispose_background
- @background_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ● 確認當前任務狀態
- #--------------------------------------------------------------------------
- def crack_quest_state
- q = @list_window.quest_list[@list_window.index]
- if q['finished'] == true && q['loop'] != true
- return false
- else
- return true
- end
- end
- end
复制代码
Questsystem.part1.rar
(999 KB, 下载次数: 230)
Questsystem.part2.rar
(456.81 KB, 下载次数: 210)
|
评分
-
查看全部评分
|