赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 7 |
经验 | 7443 |
最后登录 | 2024-6-13 |
在线时间 | 206 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 715
- 在线时间
- 206 小时
- 注册时间
- 2013-9-5
- 帖子
- 77
|
4楼
楼主 |
发表于 2015-2-16 15:16:32
|
只看该作者
熟练度,忘了从哪抄来的
本帖最后由 a1670770233 于 2015-2-16 15:18 编辑
- class Window_SkillLevel < Window_Base
- include Snstar2006::Skill_LvUp
- attr_reader :skill # 返回当前显示的技能
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(x, y, actor, skill=nil)
- super(x, y, Graphics.width/2, fitting_height(6))
- @actor = actor
- @skill = skill
- end
- #--------------------------------------------------------------------------
- # ● 设定显示的技能
- #--------------------------------------------------------------------------
- def skill=(skill)
- #return if @skill == skill
- @skill = skill
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 设定当前显示的角色
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 窗口刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- return unless @skill
- draw_skill_name(@skill, 0, 0)
- if @skill.can_lvup?
- draw_skill_max_level(@skill, 24, line_height)
- draw_skill_exp(@skill, 24, line_height*2)
- draw_actor_res_exp(24, line_height*3)
- draw_skill_transform(@skill, 24, line_height*4)
- else
- text = "此技能无法升级"
- draw_text(24, line_height, text_width(text), line_height, text)
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制技能名称
- #--------------------------------------------------------------------------
- def draw_skill_name(skill, x, y, enabled = true)
- return unless skill
- return unless skill.is_a?(RPG::Skill)
- draw_icon(skill.icon_index, x, y, enabled)
- change_color(normal_color, enabled)
- skill_name = skill.name
- skill_name += " (#{@actor.skill_level(skill.id)}级)" if skill.can_lvup?
- text = skill_name
- draw_text(x + 24, y, text_width(text), line_height, text)
- end
- #--------------------------------------------------------------------------
- # ● 绘制技能最高等级
- #--------------------------------------------------------------------------
- def draw_skill_max_level(skill, x, y)
- return unless skill.can_lvup?
- change_color(system_color)
- text = "最高等级"
- draw_text(x, y, text_width(text), line_height, text)
- change_color(normal_color)
- text = "#{skill.max_level} 级"
- draw_text(x+108, y, text_width(text), line_height, text)
- end
- #--------------------------------------------------------------------------
- # ● 绘制技能熟练度
- #--------------------------------------------------------------------------
- def draw_skill_exp(skill, x, y)
- return unless skill.can_lvup?
- return if skill.transformed
- change_color(system_color)
- text = SKILL_EXP_VOCAB
- draw_text(x, y, text_width(text), line_height, text)
- change_color(normal_color)
- color1 = text_color(18)
- color2 = text_color(20)
- current = @actor.skill_exp(skill.id)
- if @actor.skill_can_lvup?(skill.id)
- max = @actor.skill_next_exp(skill.id)
- rate = current.to_f / max
- draw_gauge(x+103, y, 120, rate, color1, color2)
- draw_current_and_max_values(x+76, y, 150, current, max, normal_color, normal_color)
- else
- draw_current_and_max_values(x+76, y, 150, "--", "--", normal_color, normal_color)
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制技能变化技
- #--------------------------------------------------------------------------
- def draw_skill_transform(skill, x, y)
- return unless skill.transform?
- change_color(system_color)
- level = skill.transform_at
- new_skill = $data_skills[skill.transform_to(level)]
- text = sprintf("升至%s级则习得", level)
- draw_text(x, y, text_width(text), line_height, text)
- change_color(normal_color)
- draw_item_name(new_skill, x+12, y+line_height)
- end
- def draw_actor_res_exp(x, y)
- enabled = @skill.manual_lvup?
- text = SKILL_REXP_VOCAB
- change_color(system_color, enabled)
- draw_text(x, y, text_width(text), line_height, text)
- change_color(normal_color, enabled)
- text = @actor.res_exp
- draw_text(x+108, y, text_width(text), line_height, text)
- end
- #--------------------------------------------------------------------------
- # ● 获得文字宽度
- #--------------------------------------------------------------------------
- def text_width(text)
- return text_size(text).width*1.5
- end
- end
- class Window_SkillList < Window_Selectable
- include Snstar2006::Skill_LvUp
- attr_reader :skill_level_window # 返回技能等级窗口
- #--------------------------------------------------------------------------
- # ● 选择技能
- #--------------------------------------------------------------------------
- alias skill_level_select select
- def select(index)
- skill_level_select(index)
- if !$game_party.in_battle
- @skill_level_window.skill = item
- @skill_level_window.refresh
- if index % 2 == 0
- @skill_level_window.x = Graphics.width/2
- else
- @skill_level_window.x = 0
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 设定技能等级窗口
- #--------------------------------------------------------------------------
- def skill_level_window=(skill_level_window)
- @skill_level_window = skill_level_window
- call_skill_level
- end
- #--------------------------------------------------------------------------
- # ● 呼叫技能窗口更新
- #--------------------------------------------------------------------------
- def call_skill_level
- update_skill_level if active && @skill_level_window
- end
- #--------------------------------------------------------------------------
- # ● 技能窗口更新
- #--------------------------------------------------------------------------
- def update_skill_level
- @skill_level_window.clear
- end
- alias skill_level_deactivate deactivate
- def deactivate
- skill_level_deactivate
- return unless @skill_level_window
- @skill_level_window.hide
- end
- alias skill_level_activate activate
- def activate
- skill_level_activate
- return unless @skill_level_window
- @skill_level_window.show
- end
- #--------------------------------------------------------------------------
- # ● 处理句柄
- #--------------------------------------------------------------------------
- alias skill_level_process_handling process_handling
- def process_handling
- skill_level_process_handling
- return manual_skill_lvup if Input.trigger?(SKILL_MAN_LVUP_KEY)
- end
- #--------------------------------------------------------------------------
- # ● 执行手动升级
- #--------------------------------------------------------------------------
- def manual_skill_lvup
- if item.manual_lvup? && @actor.can_lv_skill_manually?(item)
- Sound.play_ok
- @actor.gain_skill_exp_manual(item.id)
- refresh
- @skill_level_window.skill = item
- else
- Sound.play_buzzer
- end
- Input.update
- end
- end
- class Scene_Skill < Scene_ItemBase
- #--------------------------------------------------------------------------
- # ● 场景开始
- #--------------------------------------------------------------------------
- alias skill_level_start start
- def start
- skill_level_start
- create_skill_level_window
- @skill_level_window.z = 200
- end
- #--------------------------------------------------------------------------
- # ● 创建技能等级窗口
- #--------------------------------------------------------------------------
- def create_skill_level_window
- y = @help_window.height + 120
- @skill_level_window = Window_SkillLevel.new(Graphics.width/2, y, @actor)
- @item_window.skill_level_window = @skill_level_window
- @skill_level_window.hide
- end
- end
复制代码 |
|