class Game_Actor < Game_Battler def next_level_exp @exp_list[@level+1] - exp end def this_level_exp exp - @exp_list[@level] end def exp_rate (this_level_exp.to_f/next_level_exp.to_f).to_i end end module XD class Info_Window < Window_Base attr_accessor :icon attr_accessor :title attr_accessor :text def initialize(index) h = (Graphics.height - WLH - 32)/(Game_Party::MAX_MEMBERS) w = Graphics.width/3 a = Graphics.width/3*2 b = index*h+WLH+32 super(a,b,w,h) @icon = 1 @title = "" @text = "" yield self draw_stuffs end def draw_stuffs draw_icon(@icon,0,0) end def text=(x) end end class Actor_Window < Window_Base attr_reader :selected def draw_actor_name(actor, x, y) self.contents.font.color = hp_color(actor) self.contents.draw_text(x, y, 70, WLH, actor.name,1) end #-------------------------------------------------------------------------- # ● 绘制角色等级 # actor : 角色 # x : 描画目标 X 坐标 # y : 描画目标 Y 坐标 #-------------------------------------------------------------------------- def draw_actor_level(actor, x, y) self.contents.font.color = system_color self.contents.draw_text(x, y, 20, WLH, Vocab::level_a) self.contents.font.color = normal_color self.contents.draw_text(x + 26, y, 50, WLH, "#{actor.level} #{actor.exp_rate}%", 2) end def initialize(index,actor) h = (Graphics.height - WLH - 32)/(Game_Party::MAX_MEMBERS) w = Graphics.width/3*2 x = 0 y = index * h + WLH + 32 super(x,y,w,h) @selected = true @actor = actor draw_info end def selected=(x) if x #self.x+=10 unless @selected self.opacity = 255 self.contents_opacity = 255 self.back_opacity =255 else #self.x-=10 if @selected self.opacity = 140 self.contents_opacity = 140 self.back_opacity = 140 end @selected = x end def draw_info actor = @actor draw_actor_face(actor, 2, 0 * 96 -18, 92) draw_actor_graphic(actor, 14, self.height-32) x = 104 # actor.index * 96 + y = WLH / 2 draw_actor_name(actor, x, y) #draw_actor_class(actor, x + 120, y) draw_actor_level(actor, x, y + WLH * 1) draw_actor_state(actor, 2, 3,24) draw_actor_hp(actor, x + 90, y + WLH * 0) draw_actor_mp(actor, x + 90, y + WLH * 1) end end class Window < Window_Selectable def initialize super(0,0,Graphics.width,WLH + 32) s1 = Vocab::item s2 = Vocab::skill s3 = Vocab::equip s4 = Vocab::status s5 = Vocab::save s6 = Vocab::game_end @commands = [s1,s2,s3,s4,s5,s6] @icons = [64,104,32,137,149,112] @commands.each_with_index do |c,i| @commands[i] = " "+c end @column_max = @commands.size @item_max = @commands.size refresh end def update super if self.active self.opacity = 255 self.contents_opacity = 255 self.back_opacity = 255 else self.opacity = 140 self.contents_opacity = 140 self.back_opacity = 140 end end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 绘制项目 # index : 项目位置 # enabled : 有效标志,false时项目半透明化 #-------------------------------------------------------------------------- def draw_item(index, enabled = true) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(rect, @commands[index],0) draw_icon(@icons[index],rect.x - 9,rect.y) end #-------------------------------------------------------------------- #----- #-------------------------------------------------------------------------- # ● 更新光标 #-------------------------------------------------------------------------- def update_cursor if @index < 0 # 当光标位置小于0 self.cursor_rect.empty # 隐藏光标 else # 当光标位置为0或大于 row = @index / @column_max # 获取当前行 if row < top_row # 若先于首行 self.top_row = row # 向上滚动 end if row > bottom_row # 若後于末行 self.bottom_row = row # 向下滚动 end rect = item_rect(@index) # 获取所选项目矩形 rect.y -= self.oy rect.width+=10 rect.x-=10# 设矩形为滚动位置 self.cursor_rect = rect # 更新光标矩形 end end end end class Scene_Menu < Scene_Base def initialize(i = 0) @menu_index = i end def start super create_menu_background create_info_windows create_actor_windows create_command_window @select_timer = 0 end def create_info_windows #create_gold #create_steps #create_time end def create_actor_windows i=0 @actor_windows = [] $game_party.members.each do |a| new_one = XD::Actor_Window.new(i,a) @actor_windows.push new_one i+=1 end #@actor_window = XD::Actor_Window.new(0,$game_party.members[0]) end def create_command_window @xd = XD::Window.new @xd.index = @menu_index end def update super @xd.update update_selection if Input.trigger?(Input::C) && @xd.active @xd.active = !@selection_mode if @selection_mode update_select else @actor_windows.each do |x| #!!!!! x.selected = true end if @xd.active && Input.trigger?(Input::B) Sound.play_cancel $scene = Scene_Map.new end end @select_timer = 0 unless @selection_mode end def update_select @actor_windows.each do |x| x.selected = false end if Input.trigger?(Input::DOWN) && @select_index<=$game_party.members.size-2 @select_index+=1 Sound.play_cursor end if Input.trigger?(Input::UP) && @select_index>0 @select_index-=1 Sound.play_cursor end if Input.trigger?(Input::C) && @select_timer>=5 Sound.play_decision case @xd.index when 1 $scene = Scene_Skill.new(@select_index) when 2 $scene = Scene_Equip.new(@select_index) when 3 $scene = Scene_Status.new(@select_index) end end @select_timer +=1 if Input.trigger?(Input::B) @select_timer = 0 #~ @actor_windows.each do |x| #~ x.selected = false #~ end end_actor_selection @selection_mode = false Sound.play_cancel #~ @actor_windows.each do |x| #~ x.selected = false #~ end end_actor_selection end @actor_windows[@select_index].selected = true end def debug(x) if Input.trigger?(Input::B) eval(x) end end def terminate super dispose_menu_background @xd.dispose @actor_windows.each{|x| x.dispose} end def update_selection Sound.play_decision case @xd.index when 0 # 物品 $scene = Scene_Item.new when 1,2,3 # 技能、装备、状态 start_actor_selection when 4 # 存档 $scene = Scene_File.new(true, false, false) when 5 # 结束游戏 $scene = Scene_End.new end end def end_actor_selection @actor_windows.each do |x| x.selected = true end end def start_actor_selection @selection_mode = true @select_index = 0 @actor_windows.each do |x| x.selected = false end @actor_windows[@select_index].selected = true end def up @actor_windows.each do |x| x.selected = false end @select_index -=1 @actor_windows[@select_index].selected = true end def down @actor_windows.each do |x| x.selected = false end @select_index +=1 @actor_windows[@select_index].selected = true end def can_up? return false unless @select_index return false if @select_index ==0 return true end def can_down? return false unless @select_index return false if @select_index == $game_party.members.size return true end end