赞 | 1 |
VIP | 0 |
好人卡 | 10 |
积分 | 38 |
经验 | 28385 |
最后登录 | 2022-4-9 |
在线时间 | 723 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 3841
- 在线时间
- 723 小时
- 注册时间
- 2014-3-29
- 帖子
- 509
|
3楼
楼主 |
发表于 2014-8-16 13:29:05
|
只看该作者
- #encoding:utf-8
- #==============================================================================
- # ■ Window_Status
- #------------------------------------------------------------------------------
- # 状态画面中,显示角色基本信息的窗口。
- #==============================================================================
- module Cache
- #--------------------------------------------------------------------------
- # ● 获取菜单图像
- #--------------------------------------------------------------------------
- def self.menu(filename)
- load_bitmap("Graphics/Menus/", filename)
- end
- #--------------------------------------------------------------------------
- # ● 获取状态菜单图像
- #--------------------------------------------------------------------------
- def self.menu_status(filename)
- load_bitmap("Graphics/Menus/Status/", filename)
- end
- end
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 绘制数字(x,y,value,image,cl,n)在x,y坐标用image图片的第n行绘制value数值,cl是图片的总行数
- #--------------------------------------------------------------------------
- def draw_image_number(x,y,value,image,cl,n)
- bitmap = Cache.menu(image)
- cw = bitmap.width / 10
- ch = bitmap.height / cl
- number_text = value.abs.to_s.split(//)
- plus_x = -cw * number_text.size
- for r in 0..number_text.size - 1
- number_abs = number_text[r].to_i
- nsrc_rect = Rect.new(cw * number_abs, ch * (n - 1), cw, ch)
- contents.blt(plus_x + x + (cw * r), y, bitmap, nsrc_rect)
- end
- bitmap.dispose
- end
- end
- class Window_Status < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(0, 0, Graphics.width, Graphics.height)
- @actor = actor
- refresh
- activate
- end
- #--------------------------------------------------------------------------
- # ● 设置角色
- #--------------------------------------------------------------------------
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- clear
- draw_actor_state
- end
- #--------------------------------------------------------------------------
- # ● 清除
- #--------------------------------------------------------------------------
- def clear
- contents.clear
- end
- #--------------------------------------------------------------------------
- # ● 绘制内容
- #--------------------------------------------------------------------------
- def draw_actor_state
- if @actor == nil
- clear
- else
- contents.font.size = 15
- draw_actor_pic(@actor, 0, 25)
- create_states(205,45)
- draw_actor_name(@actor,130,0)
- draw_actor_class(@actor, 135, 15)
- draw_image_number(235,5,@actor.level,"Number",1,1)
- draw_exp_info(@actor, 242, 5)
- if @actor.is_pet_by?
- change_color(text_color(18))
- draw_text(145, 30, 180, line_height, @actor.nickname)
- change_color(normal_color)
- #draw_actor_nickname(@actor, 145, 30)
- else
- draw_actor_nickname(@actor, 145, 30)
- end
- draw_hp_gauge(@actor,416,12)
- draw_mp_gauge(@actor,417,43)
- draw_hpmp_number(450,0,@actor.hp,"Par_Number",3,3)
- draw_hpmp_number(495,15,@actor.mhp,"Par_Number",3,1)
- draw_hpmp_number(450,30,@actor.mp,"Par_Number",3,2)
- draw_hpmp_number(495,45,@actor.mmp,"Par_Number",3,1)
- draw_actor_allpa_number(@actor, 210, 70)
- draw_equipments(@actor, 205, 207)
- draw_description(@actor, 0, 340)
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制立绘
- #--------------------------------------------------------------------------
- def draw_actor_pic(actor, x, y)
- if actor.is_pet?
- bitmap = Cache.menu_status("Pet_" + actor.get_pet_id.to_s)
- else
- bitmap = Cache.menu_status("Actor_" + actor.id.to_s)
- end
- cw = bitmap.width
- ch = bitmap.height
- rect = Rect.new(0,0,cw,ch)
- contents.blt(x, y, bitmap, rect)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 绘制经验值信息
- #--------------------------------------------------------------------------
- def draw_exp_info(actor, x, y)
- s1 = actor.max_level? ? "-------" : actor.exp
- s2 = actor.max_level? ? "-------" : actor.next_level_exp - actor.exp
- #change_color(system_color)
- draw_text(x, y, 70, 15, "当前经验")
- draw_text(x, y + 15, 70, 15, "下一等级")
- #change_color(normal_color)
- draw_text(x + 30, y, 100, 15, s1, 2)
- draw_text(x + 30, y + 15, 100, 15, s2, 2)
- end
- #--------------------------------------------------------------------------
- # ● 绘制HP、MP槽值
- #--------------------------------------------------------------------------
- def draw_hp_gauge(actor,x,y)
- hp_image = Cache.menu_status("Actor_Meter2")
- cw = hp_image.width * actor.hp / actor.mhp
- ch = hp_image.height / 2
- rect = Rect.new(0, ch, cw, ch)
- contents.blt(x, y, hp_image, rect)
- hp_image.dispose
- end
- def draw_mp_gauge(actor,x,y)
- mp_image = Cache.menu_status("Actor_Meter2")
- cw = mp_image.width * actor.mp / actor.mmp
- ch = mp_image.height / 2
- rect = Rect.new(0, 0, cw, ch)
- contents.blt(x, y, mp_image, rect)
- mp_image.dispose
- end
- #--------------------------------------------------------------------------
- # ● 绘制数字(x,y,value,image,cl,n)在x,y坐标用image图片的第n行绘制value数值,cl是图片的总行数
- #--------------------------------------------------------------------------
- def draw_hpmp_number(x,y,value,image,cl,n)
- bitmap = Cache.menu_status(image)
- cw = bitmap.width / 11
- ch = bitmap.height / cl
- number_text = value.abs.to_s.split(//)
- plus_x = -cw * number_text.size
- for r in 0..number_text.size - 1
- number_abs = number_text[r].to_i
- nsrc_rect = Rect.new(cw * number_abs, ch * (n - 1), cw, ch)
- contents.blt(plus_x + x + (cw * r), y, bitmap, nsrc_rect)
- end
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 绘制属性
- #--------------------------------------------------------------------------
- def draw_actor_allpa_number(actor, x, y)
- contents.font.size = 18
- #bitmap = Cache.menu_status("Par_Number")
- #cw = bitmap.width / 11
- #ch = bitmap.height / 3
- 8.times {|i| #p actor.xparam(i)
- if i % 2 == 0
- change_color(normal_color)
- draw_text(x, y + i / 2 * 32, 50, 20, Vocab::param(i))
- change_color(text_color(17))
- draw_text(x + 35, y + i / 2 * 32, 36, 23, actor.param(i), 2)
- change_color(text_color(20))
- draw_text(x + 85, y + i / 2 * 32, 50, 23, actor.get_pet_oneup_param(i), 2)
- draw_text(x + 135, y + i / 2 * 32, 10, 20, "↑")
- change_color(normal_color)
- else
- change_color(normal_color)
- draw_text(x + 160, y + i / 2 * 32, 50, 20, Vocab::param(i))
- change_color(text_color(17))
- draw_text(x + 195, y + i / 2 * 32, 36, 23, actor.param(i), 2)
- change_color(text_color(20))
- draw_text(x + 245, y + i / 2 * 32, 50, 23, actor.get_pet_oneup_param(i), 2)
- draw_text(x + 295, y + i / 2 * 32, 10, 20, "↑")
- change_color(normal_color)
- end
- }
- #bitmap.dispose
- contents.font.size = 15
- end
- #--------------------------------------------------------------------------
- # ● 绘制装备
- #--------------------------------------------------------------------------
- def draw_equipments(actor, x, y)
- actor.equips.each_with_index do |item, i|
- if i % 2 == 0
- draw_item_name(item, x, y + 26 * i)
- else
- draw_item_name(item, x + 150, y + 26 * i)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制说明
- #--------------------------------------------------------------------------
- def draw_description(actor, x, y)
- draw_text_ex(x, y, actor.description)
- end
- ###########################################################################
- #--------------------------------------------------------------------------
- # ● Create_States
- #--------------------------------------------------------------------------
- def create_states(x,y)
- @icon = Cache.system("Iconset")
- @status.bitmap.clear if @status
- refresh_states
- @status = Sprite.new
- @status.bitmap = Bitmap.new(24,24)
- @status.x = x
- @status.y = y
- @status_flow = -24
- @states_speed = 50
- @status.z = 2
- @old_states = @actor.states
- flow_states
- end
- #--------------------------------------------------------------------------
- # ● Flow_Status
- #--------------------------------------------------------------------------
- def flow_states
- return if @actor.states.size == 0 and [email protected]
- @states_speed = 0
- @status.bitmap.clear
- src_rect = Rect.new(@status_flow,0, 24,24)
- @status.bitmap.blt(0,0, @actor_status, src_rect)
- @status.visible = @actor.states.size == 0 ? false : true
- @status_flow += 1
- #@status_flow = -24 if @status_flow >= @states_size - 24
- @status_flow = -24 if @status_flow >= @states_size - 3#24
- end
-
- #--------------------------------------------------------------------------
- # ● Refresh States
- #--------------------------------------------------------------------------
- def refresh_states
- @old_states = @actor.states
- @actor_status.dispose if @actor_status != nil
- #@states_size = @actor.states.size > 0 ? (48 * @actor.states.size) : 24
- @states_size = @actor.states.size > 0 ? (27 * @actor.states.size) : 3
- @actor_status = Bitmap.new(@states_size,24)
- index = 0
- for i in @actor.states
- rect = Rect.new(i.icon_index % 16 * 24, i.icon_index / 16 * 24, 24, 24)
- #@actor_status.blt(48 * index , 0, @icon, rect)
- @actor_status.blt(27 * index , 0, @icon, rect)
- index += 1
- end
- end
-
- #--------------------------------------------------------------------------
- # ● Dispose
- #--------------------------------------------------------------------------
- def dispose
- super
- @status.bitmap.dispose
- @status.dispose
- @actor_status.dispose if @actor_status != nil
- @icon.dispose
- end
-
- #--------------------------------------------------------------------------
- # ● Update
- #--------------------------------------------------------------------------
- def update
- super
- refresh_states if @old_states != @actor.states
- flow_states
- end
- ###########################################################################
- end
复制代码 |
|