赞 | 5 |
VIP | 71 |
好人卡 | 22 |
积分 | 6 |
经验 | 32145 |
最后登录 | 2013-8-9 |
在线时间 | 184 小时 |
Lv2.观梦者 天仙
- 梦石
- 0
- 星屑
- 620
- 在线时间
- 184 小时
- 注册时间
- 2008-4-15
- 帖子
- 5023
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
先放个测试版出来
然後埋头继续写功课
设定方法看注释
调用转职介面:$scene = Scene_Class.new(角色)
或:$scene = Scene_Class.new(角色,菜单命令index)
第一个方法跳出时返回地图
第二个返回菜单
截图:
设定部分
- class RPG::Class
- #=============================================================================
- # 设定是否在描绘职业时显示等级
- #=============================================================================
- DRAW_LEVEL_WITH_CLASS = true
-
- #=============================================================================
- # 设定每个职业的前置职业和前置职业等级,没有指定的默认为无。
- # 格式:
- # when 职业ID
- # prereq_class = {前置1=>等级1, 前置2=>等级2}
- #
- # 例如:prereq_class = {3=>2, 4=>5}
- # 代表需要 3号职业2级 以及 4号职业5级
- #=============================================================================
- def prereq_class_id
- prereq_class=0
- case id
- when 2
- prereq_class = {1=>2, 3=>1}
- when 5
- else
- prereq_class = 0
- end
- return prereq_class
- end
- #=============================================================================
- # 设定每个职业的等级上限,没有指定的默认为 99
- # 格式:
- # when 职业ID
- # return 等级上限
- #=============================================================================
- def max_level
- case id
- when 1
- return 5
- when 2
- return 10
- else
- return 99
- end
- end
- end
- #===============================================================================
- # ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
- #===============================================================================
- class Game_Actor < Game_Battler
- #=============================================================================
- # 设定角色可以转的职业,没有指定的默认可以转所有职业
- # 格式:
- # when 角色ID
- # possible_class = [能够转职的职业]
- #=============================================================================
- def setup_possible_class
- case @actor_id
- # 格式:
- # when 角色ID
- # possible_class = [能够转职的职业]
- when 1
- @possible_class = [1, 2, 5]
- else
- # 默认返回全部职业
- @possible_class = (1...$data_classes.size).to_a
- end
- # 初始化职业等级
- initialize_class
- end
- end
复制代码
主要部分
介面部分
- class Scene_Class < Scene_Base
- def initialize(actor, return_scene=nil)
- @actor = actor
- @return_scene = return_scene
- end
- def start
- command = []
- @actor.possible_class.each{|i| command << $data_classes[i].name}
- @class_window = Window_Command.new(120, command)
- @class_window.x = 76
- @class_window.y = 76
- @class_window.height = 264
- @class_window.create_contents
- command.size.times{|i|
- @class_window.draw_item(i, @actor.class_can_change?(@actor.possible_class[i]))}
-
- @prereq_window = Window_Prereq.new(@actor)
- @prereq_window.refresh
- create_menu_background
- end
- def return_scene
- $scene = @return_scene ? Scene_Menu.new(@return_scene) : Scene_Map.new
- end
- def terminate
- dispose_menu_background
- @class_window.dispose
- @prereq_window.dispose
- end
- def update
- update_menu_background
- @class_window.update
- @prereq_window.update
- if Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
- @prereq_window.s_class_id = 1+ @class_window.index
- @prereq_window.refresh
- elsif Input.trigger?(Input::B)
- return_scene
- elsif Input.trigger?(Input::C)
- cid = @actor.possible_class[@class_window.index]
- # 判断能否转职
- if @actor.class_can_change?(cid)
- Sound.play_decision
- # 判断是升级还是转职
- if @actor.class_id == cid
- @actor.set_class_level(@actor.class_level + 1)
- else
- @actor.change_class(cid)
- @actor.set_class_level(1) if @actor.class_level == 0
- end
- # 刷新窗口
- @prereq_window.refresh
- @class_window.draw_item(@class_window.index,@actor.class_can_change?(cid))
- else
- Sound.play_buzzer
- return
- end
- end
- end
- end
- class Window_Prereq < Window_Base
- attr_accessor :s_class_id
- def initialize(actor)
- @actor = actor
- @s_class_id = @actor.possible_class[0]
- super(196, 76, 272, 264)
- end
- def refresh
- self.contents.clear
- @s_class = $data_classes[@s_class_id]
- actor_class = $data_classes[@actor.class_id]
- self.contents.font.color = normal_color
- self.contents.draw_text(0, 0, 120, WLH, "当前职业:")
- self.contents.draw_text(48, 24, 120, WLH, "#{actor_class.name} #{@actor.current_class_level}级")
- self.contents.draw_text(0, 48, 120, WLH, "履历:")
- @y = 0
- @actor.possible_class.each{|i|
- text = $data_classes[i].name
- if @actor.class_level(i) > 0
- self.contents.draw_text(48, 72+WLH*@y, 120, WLH, "#{text} #{@actor.class_level(i)}级")
- @y += 1
- end
- }
- self.contents.draw_text(0, 72+WLH*@y, 120, WLH, "前置职业:")
- @y += 1
- prereq = @s_class.prereq_class_id
- if prereq != 0
- prereq.keys.size.times{|i|
- pq = prereq.keys[i]
- pqclass = $data_classes[pq].name
- pqlv = prereq[pq]
- enabled = (@actor.p_class?(pq) and @actor.class_level(pq) > pqlv)
- self.contents.font.color = enabled ? normal_color : knockout_color
- self.contents.draw_text(48, 72+WLH*(@y+i), 120, WLH, "#{pqclass} #{pqlv}级")
- }
- else
- self.contents.draw_text(48, 72+WLH*@y, 120, WLH, "无")
- end
- end
- end
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 绘制角色职业
- #--------------------------------------------------------------------------
- alias change_class_draw_actor_class draw_actor_class
- def draw_actor_class(actor, x, y)
- if RPG::Class::DRAW_LEVEL_WITH_CLASS
- self.contents.font.color = normal_color
- text = actor.class.name + " #{actor.class_level}级"
- self.contents.draw_text(x, y, 108, WLH, text)
- else
- change_class_draw_actor_class(actor, x, y)
- end
- end
- end
复制代码 |
|