赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 0 |
经验 | 0 |
最后登录 | 2011-3-28 |
在线时间 | 1 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 145
- 在线时间
- 1 小时
- 注册时间
- 2011-3-27
- 帖子
- 1
|
接5L,还有一个忘发了.- #==============================================================================
- # ■ Window_Base
- #------------------------------------------------------------------------------
- # 游戏中全部窗口的超级类。
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 常量
- #--------------------------------------------------------------------------
- WLH = 24 # 窗口行高(Window Line Height)
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # x : 窗口 X 座标
- # y : 窗口 Y 座标
- # width : 窗口宽度
- # height : 窗口高度
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super()
- self.windowskin = Cache.system("Window")
- self.x = x
- self.y = y
- self.width = width
- self.height = height
- self.z = 100
- self.back_opacity = 200
- self.openness = 255
- create_contents
- @opening = false
- @closing = false
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- self.contents.dispose
- super
- end
- #--------------------------------------------------------------------------
- # ● 生成窗口内容
- #--------------------------------------------------------------------------
- def create_contents
- self.contents.dispose
- self.contents = Bitmap.new(width - 32, height - 32)
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- if @opening
- self.openness += 48
- @opening = false if self.openness == 255
- elsif @closing
- self.openness -= 48
- @closing = false if self.openness == 0
- end
- end
- #--------------------------------------------------------------------------
- # ● 打开窗口
- #--------------------------------------------------------------------------
- def open
- @opening = true if self.openness < 255
- @closing = false
- end
- #--------------------------------------------------------------------------
- # ● 关闭窗口
- #--------------------------------------------------------------------------
- def close
- @closing = true if self.openness > 0
- @opening = false
- end
- #--------------------------------------------------------------------------
- # ● 获取文字颜色
- # n : 文字颜色色号(0-31)
- #--------------------------------------------------------------------------
- def text_color(n)
- x = 64 + (n % 8) * 8
- y = 96 + (n / 8) * 8
- return windowskin.get_pixel(x, y)
- end
- #--------------------------------------------------------------------------
- # ● 获取一般文字颜色
- #--------------------------------------------------------------------------
- def normal_color
- return text_color(0)
- end
- #--------------------------------------------------------------------------
- # ● 获取系统文字颜色
- #--------------------------------------------------------------------------
- def system_color
- return text_color(16)
- end
- #--------------------------------------------------------------------------
- # ● 获取危机文字颜色
- #--------------------------------------------------------------------------
- def crisis_color
- return text_color(17)
- end
- #--------------------------------------------------------------------------
- # ● 获取战斗不能文字颜色
- #--------------------------------------------------------------------------
- def knockout_color
- return text_color(18)
- end
- #--------------------------------------------------------------------------
- # ● 获取变量条背景颜色
- #--------------------------------------------------------------------------
- def gauge_back_color
- return text_color(19)
- end
-
-
- #--------------------------------------------------------------------------
- # ● 获取装备画面能力值上升颜色
- #--------------------------------------------------------------------------
- def power_up_color
- return text_color(24)
- end
- #--------------------------------------------------------------------------
- # ● 获取装备画面能力值下降颜色
- #--------------------------------------------------------------------------
- def power_down_color
- return text_color(25)
- end
- #--------------------------------------------------------------------------
- # ● 会制图标
- # icon_index : 图标号
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # enabled : 有效化标志,为 false 时则图标半透明化。
- #--------------------------------------------------------------------------
- def draw_icon(icon_index, x, y, enabled = true)
- bitmap = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
- end
- #--------------------------------------------------------------------------
- # ● 绘制头像
- # face_name : 头像文件名
- # face_index : 头像号码
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # size : 显示大小
- #--------------------------------------------------------------------------
- def draw_face(face_name, face_index, x, y, size = 96)
- bitmap = Cache.face(face_name)
- rect = Rect.new(0, 0, 0, 0)
- rect.x = face_index % 4 * 96 + (96 - size) / 2
- rect.y = face_index / 4 * 96 + (96 - size) / 2
- rect.width = size
- rect.height = size
- self.contents.blt(x, y, bitmap, rect)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 绘制行走图
- # character_name : 行走图文件名
- # character_index : 行走图号码
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- #--------------------------------------------------------------------------
- def draw_character(character_name, character_index, x, y)
- return if character_name == nil
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign != nil and sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = character_index
- src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
- self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
- end
-
-
- #--------------------------------------------------------------------------
- # ● 绘制角色行走图
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- #--------------------------------------------------------------------------
- def draw_actor_graphic(actor, x, y)
- draw_character(actor.character_name, actor.character_index, x, y)
- end
- #--------------------------------------------------------------------------
- # ● 绘制角色头像
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # size : 绘制大小
- #--------------------------------------------------------------------------
- def draw_actor_face(actor, x, y, size = 96)
- draw_face(actor.face_name, actor.face_index, x, y, size)
- end
- #--------------------------------------------------------------------------
- # ● 绘制角色名称
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- #--------------------------------------------------------------------------
- def draw_actor_name(actor, x, y)
- self.contents.draw_text(x, y, 108, WLH, actor.name)
- end
- #--------------------------------------------------------------------------
- # ● 绘制角色职业
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- #--------------------------------------------------------------------------
- def draw_actor_class(actor, x, y)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, 108, WLH, actor.class.name)
- end
-
- #--------------------------------------------------------------------------
- # ● 绘制角色状态
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # width : 描画目标宽度
- #--------------------------------------------------------------------------
- def draw_actor_state(actor, x, y, width = 96)
- count = 0
- for state in actor.states
- draw_icon(state.icon_index, x + 24 * count, y)
- count += 1
- break if (24 * count > width - 24)
- end
- end
-
-
-
-
- #--------------------------------------------------------------------------
- # ● 绘制角色能力值
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # type : 能力值类型(0-3)
- #--------------------------------------------------------------------------
- def draw_actor_parameter(actor, x, y, type)
- case type
- when 0
- parameter_name = Vocab::atk
- parameter_value = actor.atk
- when 1
- parameter_name = Vocab::def
- parameter_value = actor.def
- when 2
- parameter_name = Vocab::spi
- parameter_value = actor.spi
- when 3
- parameter_name = Vocab::agi
- parameter_value = actor.agi
- end
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 120, WLH, parameter_name)
- self.contents.font.color = normal_color
- self.contents.draw_text(x + 120, y, 36, WLH, parameter_value, 2)
- end
- #--------------------------------------------------------------------------
- # ● 绘制物品
- # item : 物品(技能、武器、防具也合用)
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # enabled : 有效化标志,为 false 时则物品半透明化。
- #--------------------------------------------------------------------------
- def draw_item_name(item, x, y, enabled = true)
- if item != nil
- draw_icon(item.icon_index, x, y, enabled)
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- self.contents.draw_text(x + 24, y, 172, WLH, item.name)
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制金钱单位
- # value : 数目
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- # width : 描画目标宽度
- #--------------------------------------------------------------------------
- def draw_currency_value(value, x, y, width)
- cx = contents.text_size(Vocab::gold).width
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y, width-cx-2, WLH, value, 2)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, width, WLH, Vocab::gold, 2)
- end
- end
复制代码- #==============================================================================
- # ■ Window_Status
- #------------------------------------------------------------------------------
- # 显示状态画面、完全规格的状态窗口。
- #==============================================================================
- class Window_Status < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # actor : 角色
- #--------------------------------------------------------------------------
- def initialize(actor)
- super(0, 0, 544, 416)
- @actor = actor
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- draw_actor_name(@actor, 4, 0)
- draw_actor_class(@actor, 128, 0)
- draw_actor_face(@actor, 8, 32)
- draw_basic_info(128, 32)
- draw_parameters(32, 160)
- draw_exp_info(288, 32)
- draw_equipments(288, 160)
- end
- #--------------------------------------------------------------------------
- # ● 绘制基础资料
- # x : 绘制点 X 座标
- # y : 绘制点 Y 座标
- #--------------------------------------------------------------------------
- def draw_basic_info(x, y)
- draw_actor_state(@actor, x, y + WLH * 1)
- end
- #--------------------------------------------------------------------------
- # ● 绘制能力值
- # x : 绘制点 X 座标
- # y : 绘制点 Y 座标
- #--------------------------------------------------------------------------
- def draw_parameters(x, y)
- draw_actor_parameter(@actor, x, y + WLH * 0, 0)
- draw_actor_parameter(@actor, x, y + WLH * 1, 1)
- draw_actor_parameter(@actor, x, y + WLH * 2, 2)
- draw_actor_parameter(@actor, x, y + WLH * 3, 3)
- end
- #--------------------------------------------------------------------------
- # ● 绘制经验值
- # x : 绘制点 X 座标
- # y : 绘制点 Y 座标
- #--------------------------------------------------------------------------
- def draw_exp_info(x, y)
- s1 = @actor.exp_s
- s2 = @actor.next_rest_exp_s
- s_next = sprintf(Vocab::ExpNext, Vocab::level)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y + WLH * 0, 180, WLH, Vocab::ExpTotal)
- self.contents.draw_text(x, y + WLH * 2, 180, WLH, s_next)
- self.contents.font.color = normal_color
- self.contents.draw_text(x, y + WLH * 1, 180, WLH, s1, 2)
- self.contents.draw_text(x, y + WLH * 3, 180, WLH, s2, 2)
- end
- #--------------------------------------------------------------------------
- # ● 绘制装备
- # x : 绘制点 X 座标
- # y : 绘制点 Y 座标
- #--------------------------------------------------------------------------
- def draw_equipments(x, y)
- self.contents.font.color = system_color
- self.contents.draw_text(x, y, 120, WLH, Vocab::equip)
- for i in 0..4
- draw_item_name(@actor.equips[i], x + 16, y + WLH * (i + 1))
- end
- end
- end
复制代码 |
|