赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 13776 |
最后登录 | 2015-7-14 |
在线时间 | 64 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 54
- 在线时间
- 64 小时
- 注册时间
- 2010-7-28
- 帖子
- 141
|
3楼
楼主 |
发表于 2014-3-8 06:54:16
|
只看该作者
本帖最后由 Demon丶旋律 于 2014-3-8 07:04 编辑
找是找到actor.name了,但是出现在好几个地方,有些地方我不太看得懂,改了没效果,考虑也许是要把ID号转换成字符串??不太懂,,
我用的是这个脚本,能帮忙看看吗?
#==============================================================================
#本脚本来自www.66rpg.com,转载和使用请保留此信息 。
#默认游戏系统大修改 2.0
# 爆焰 于: 1-30-2012 整合与发布
#QQ:459974518
#此脚本是本人一时兴起修改默认的脚本所制作完成。
#如发现有bug请与作者联系或上66rpg发贴提意见。
#==============================================================================
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 游戏中全部窗口的超级类。
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 初始化对像
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的宽
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super()
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
self.x = x
self.y = y
self.width = width
self.height = height
self.z = 100
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 如果窗口的内容已经被设置就被释放
if self.contents != nil
self.contents.dispose
end
super
end
#--------------------------------------------------------------------------
# ● 获取文字色
# n : 文字色编号 (0~7)
#--------------------------------------------------------------------------
def text_color(n)
case n
when 0
return Color.new(255, 255, 255, 255)
when 1
return Color.new(128, 128, 255, 255)
when 2
return Color.new(255, 128, 128, 255)
when 3
return Color.new(128, 255, 128, 255)
when 4
return Color.new(128, 255, 255, 255)
when 5
return Color.new(255, 128, 255, 255)
when 6
return Color.new(255, 255, 128, 255)
when 7
return Color.new(192, 192, 192, 255)
else
normal_color
end
end
#--------------------------------------------------------------------------
# ● 获取普通文字色
#--------------------------------------------------------------------------
def normal_color
return Color.new(255, 255, 255, 255)
end
#--------------------------------------------------------------------------
# ● 获取无效文字色
#--------------------------------------------------------------------------
def disabled_color
return Color.new(255, 255, 255, 128)
end
#--------------------------------------------------------------------------
# ● 获取系统文字色
#--------------------------------------------------------------------------
def system_color
return Color.new(192, 224, 255, 255)
end
#--------------------------------------------------------------------------
# ● 获取危机文字色
#--------------------------------------------------------------------------
def crisis_color
return Color.new(255, 255, 64, 255)
end
#--------------------------------------------------------------------------
# ● 获取战斗不能文字色
#--------------------------------------------------------------------------
def knockout_color
return Color.new(255, 64, 0)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 如果窗口的外关被变更了、再设置
if $game_system.windowskin_name != @windowskin_name
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
end
#--------------------------------------------------------------------------
# ● 图形的描绘
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
cw = bitmap.width / 4
ch = bitmap.height / 4
src_rect = Rect.new(0, 0, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ● 名称的描绘
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 120, 32, 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, 236, 32, actor.class_name)
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, 32, 32, "Lv")
self.contents.font.color = normal_color
self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 生辰成描绘用状态字符串
# actor : 角色
# width : 描画目标的宽度
# need_normal : [正常] 是否为必须 (true / false)
#--------------------------------------------------------------------------
def make_battler_state_text(battler, width, need_normal)
# 获取括号的宽
brackets_width = self.contents.text_size("[]").width
# 生成状态名字符串
text = ""
for i in battler.states
if $data_states.rating >= 1
if text == ""
text = $data_states.name
else
new_text = text + "/" + $data_states.name
text_width = self.contents.text_size(new_text).width
if text_width > width - brackets_width
break
end
text = new_text
end
end
end
# 状态名空的字符串是 "[正常]" 的情况下
if text == ""
if need_normal
text = "[正常]"
end
else
# 加上括号
text = "[" + text + "]"
end
# 返回完成后的文字类
return text
end
#--------------------------------------------------------------------------
# ● 描绘状态
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标的宽
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 120)
text = make_battler_state_text(actor, width, true)
self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
self.contents.draw_text(x, y, width, 32, text)
end
#--------------------------------------------------------------------------
# ● 描画 EXP
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_exp(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 24, 32, "E")
self.contents.font.color = normal_color
self.contents.draw_text(x + 45, y, 84, 32, actor.exp_s, 2)
#self.contents.draw_text(x + 48, y, 12, 32, "/", 1)
#self.contents.draw_text(x + 60, y, 84, 32, actor.next_exp_s)
end
#--------------------------------------------------------------------------
# ● 描绘 HP
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标的宽
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 144)
# 描绘字符串 "HP"
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
# 计算描绘 MaxHP 所需的空间
if width - 32 >= 108
hp_x = x + width - 108
flag = true
elsif width - 32 >= 48
hp_x = x + width - 48
flag = false
end
# 描绘 HP
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
# 描绘 MaxHP
if flag
self.contents.font.color = normal_color
self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
end
end
#--------------------------------------------------------------------------
# ● 描绘 SP
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标的宽
#--------------------------------------------------------------------------
def draw_actor_sp(actor, x, y, width = 144)
# 描绘字符串 "SP"
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
# 计算描绘 MaxSP 所需的空间
if width - 32 >= 108
sp_x = x + width - 108
flag = true
elsif width - 32 >= 48
sp_x = x + width - 48
flag = false
end
# 描绘 SP
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
# 描绘 MaxSP
if flag
self.contents.font.color = normal_color
self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
end
end
#--------------------------------------------------------------------------
# ● 描绘能力值
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# type : 能力值种类 (0~6)
#--------------------------------------------------------------------------
def draw_actor_parameter(actor, x, y, type)
case type
when 0
parameter_name = $data_system.words.atk
parameter_value = actor.atk
when 1
parameter_name = $data_system.words.pdef
parameter_value = actor.pdef
when 2
parameter_name = $data_system.words.mdef
parameter_value = actor.mdef
when 3
parameter_name = $data_system.words.str
parameter_value = actor.str
when 4
parameter_name = $data_system.words.dex
parameter_value = actor.dex
when 5
parameter_name = $data_system.words.agi
parameter_value = actor.agi
when 6
parameter_name = $data_system.words.int
parameter_value = actor.int
################################################
when 7
parameter_name = "回避"
parameter_value = actor.eva
##################################################
end
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, 32, parameter_name)
self.contents.font.color = normal_color
self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 描绘物品名
# item : 物品
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_item_name(item, x, y)
if item == nil
return
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
end
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 特技及物品的说明、角色的状态显示的窗口。
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.z = 998
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# ● 设置文本
# text : 窗口显示的字符串
# align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
#--------------------------------------------------------------------------
def set_text(text, align = 0)
# 如果文本和对齐方式的至少一方与上次的不同
if text != @text or align != @align
# 再描绘文本
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
@text = text
@align = align
@actor = nil
end
self.visible = true
end
#--------------------------------------------------------------------------
# ● 设置角色
# actor : 要显示状态的角色
#--------------------------------------------------------------------------
def set_actor(actor)
if actor != @actor
self.contents.clear
draw_actor_name(actor, 4, 0)
draw_actor_state(actor, 140, 0)
draw_actor_hp(actor, 284, 0)
draw_actor_sp(actor, 460, 0)
@actor = actor
@text = nil
self.visible = true
end
end
#--------------------------------------------------------------------------
# ● 设置敌人
# enemy : 要显示名字和状态的敌人
#--------------------------------------------------------------------------
def set_enemy(enemy)
text = enemy.name
state_text = make_battler_state_text(enemy, 112, false)
if state_text != ""
text += " " + state_text
end
set_text(text, 1)
end
end
#==============================================================================
# ■ Window_Gold
#------------------------------------------------------------------------------
# 显示金钱的窗口。
#==============================================================================
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "硬币")
end
end
#==============================================================================
# ■ Window_PlayTime
#------------------------------------------------------------------------------
# 菜单画面显示游戏时间的窗口。
#==============================================================================
class Window_PlayTime < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "游戏时间")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, text, 2)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#==============================================================================
# ■ Window_Steps
#------------------------------------------------------------------------------
# 菜单画面显示步数的窗口。
#==============================================================================
class Window_Steps < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "魔能值")
self.contents.font.color = normal_color
self.contents.draw_text(4, 32, 120, 32, "#{$game_variables[27]}/#{$game_variables[28]}", 2)
#self.contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
end
end
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# 显示菜单画面和同伴状态的窗口。
#==============================================================================
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化目标
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 320)
@column_max = 4
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
refresh
self.active = false
self.index = -1
end
def draw_actor_face(actor,x,y)
bitmap = RPG::Cache.battler(actor.name + "" , actor.battler_hue)
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height ))
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
#x = 64
#y = i * 116
x = i*158
y = 64
actor = $game_party.actors
draw_actor_face(actor, x+10, y-70)
# draw_actor_hp_meter_line(actor, x+35,y+240,100,12)
# draw_actor_sp_meter_line(actor, x+35,y+270,100,12)
# EXP(actor, x+30,y+300)
draw_actor_hp(actor, x , y + 110)
draw_actor_sp(actor, x , y +140)
# draw_actor_graphic(actor, x + 60, y + 80)
# draw_actor_graphic(actor, x - 40, y + 80)
draw_actor_name(actor, x, y+30)
draw_actor_class(actor, x , y+60)
# draw_actor_level(actor, x, y + 32)
draw_actor_level(actor, x, y+85)
draw_actor_state(actor, x , y + 195)
draw_actor_exp(actor, x, y + 170)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @Index < 0
self.cursor_rect.empty
else
#self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
self.cursor_rect.set(@index * 158, 0, 130, 290)
end
end
end
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(80, 128, 480, 320)
@column_max = 2
self.z = 998
refresh
self.index = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加报务
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items)
end
end
# 在战斗中以外添加武器、防具
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (210 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 150, y, 16, 32, ":", 1)
self.contents.draw_text(x + 170, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ■ Window_Skill
#------------------------------------------------------------------------------
# 特技画面、战斗画面、显示可以使用的特技浏览的窗口。
#==============================================================================
class Window_Skill < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(80, 128, 480, 320)
self.z = 998
@actor = actor
@column_max = 2
refresh
self.index = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● 获取特技
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in [email protected]
skill = $data_skills[@actor.skills]
if skill != nil
@data.push(skill)
end
end
# 如果项目数不是 0 就生成位图、重新描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
skill = @data[index]
if @actor.skill_can_use?(skill.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (210 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 150, y, 48, 32, skill.sp_cost.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.skill == nil ? "" : self.skill.description)
end
end
#==============================================================================
# ■ Window_SkillStatus
#------------------------------------------------------------------------------
# 显示特技画面、特技使用者的窗口。
#==============================================================================
class Window_SkillStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 640, 64)
self.z = 998
self.opacity = 0
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_state(@actor, 140, 0)
draw_actor_hp(@actor, 284, 0)
draw_actor_sp(@actor, 460, 0)
end
end
#==============================================================================
# ■ Window_Target
#------------------------------------------------------------------------------
# 物品画面与特技画面的、使用对像角色选择窗口。
#==============================================================================
class Window_Target < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 336, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.z = 9999
@item_max = $game_party.actors.size
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = 4
y = i * 116
actor = $game_party.actors
draw_actor_name(actor, x, y)
draw_actor_class(actor, x + 144, y)
draw_actor_level(actor, x + 8, y + 32)
draw_actor_state(actor, x + 8, y + 64)
draw_actor_hp(actor, x + 152, y + 32)
draw_actor_sp(actor, x + 152, y + 64)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置 -1 为全选、-2 以下为单独选择 (使用者自身)
if @index <= -2
self.cursor_rect.set(0, (@index + 10) * 116, self.width - 32, 96)
elsif @index == -1
self.cursor_rect.set(0, 0, self.width - 32, @item_max * 116 - 20)
else
self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
end
end
end
#==============================================================================
# ■ Window_EquipLeft
#------------------------------------------------------------------------------
# 装备画面的、显示角色能力值变化的窗口。
#==============================================================================
class Window_EquipLeft < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(0, 64, 272, 416)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
def draw_actor_face(actor,x,y)
bitmap = RPG::Cache.battler(actor.name + "_A" , actor.battler_hue)
self.contents.blt(x,y,bitmap,Rect.new(0,0,bitmap.width,bitmap.height ))
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_face(@actor,x-20,y-70)
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 4, 32)
draw_actor_parameter(@actor, 4, 128, 0)
draw_actor_parameter(@actor, 4, 160, 1)
draw_actor_parameter(@actor, 4, 192, 2)
draw_actor_parameter(@actor, 4, 224, 3)
draw_actor_parameter(@actor, 4, 256, 4)
draw_actor_parameter(@actor, 4, 288, 7)
draw_actor_parameter(@actor, 4, 320, 5)
draw_actor_parameter(@actor, 4, 352, 6)
if @new_atk != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 128, 40, 32, "→", 1)
self.contents.font.color = Color.new(255, 255, 255, 255)
self.contents.draw_text(200, 128, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 160, 40, 32, "→", 1)
self.contents.font.color = Color.new(255, 255, 255, 255)
self.contents.draw_text(200, 160, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 192, 40, 32, "→", 1)
self.contents.font.color = Color.new(255, 255, 255, 255)
self.contents.draw_text(200, 192, 36, 32, @new_mdef.to_s, 2)
end
if @new_str != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 224, 40, 32, "→", 1)
self.contents.font.color = Color.new(255, 255, 255, 255)
self.contents.draw_text(200, 224, 36, 32, @new_str.to_s, 2)
end
if @new_dex != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 256, 40, 32, "→", 1)
self.contents.font.color = Color.new(255, 255, 255, 255)
self.contents.draw_text(200, 256, 36, 32, @new_dex.to_s, 2)
end
if @new_eva != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 288, 40, 32, "→", 1)
self.contents.font.color = Color.new(255, 255, 255, 255)
self.contents.draw_text(200, 288, 36, 32, @new_eva.to_s, 2)
end
if @new_agi != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 320, 40, 32, "→", 1)
self.contents.font.color = Color.new(255, 255, 255, 255)
self.contents.draw_text(200, 320, 36, 32, @new_agi.to_s, 2)
end
if @new_int != nil
self.contents.font.color = system_color
self.contents.draw_text(160, 352, 40, 32, "→", 1)
self.contents.font.color = Color.new(255, 255, 255, 255)
self.contents.draw_text(200, 352, 36, 32, @new_int.to_s, 2)
end
end
#--------------------------------------------------------------------------
# ● 变更装备后的能力值设置
# new_atk : 变更装备后的攻击力
# new_pdef : 变更装备后的物理防御
# new_mdef : 变更装备后的魔法防御
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_eva, new_agi, new_int)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef or @new_str != new_str or @new_dex != new_dex or @new_eva != new_eva or @new_agi != new_agi or @new_int != new_int
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_str = new_str
@new_dex = new_dex
@new_eva = new_eva
@new_agi = new_agi
@new_int = new_int
refresh
end
end
end
#==============================================================================
# ■ Window_EquipItem
#------------------------------------------------------------------------------
# 装备画面、显示浏览变更装备的候补物品的窗口。
#==============================================================================
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
# equip_type : 装备部位 (0~3)
#--------------------------------------------------------------------------
def initialize(actor, equip_type)
super(272, 256, 368, 224)
@actor = actor
@equip_type = equip_type
@column_max = 1
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加可以装备的武器
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons)
end
end
end
# 添加可以装备的防具
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors.kind == @equip_type-1
@data.push($data_armors)
end
end
end
end
# 添加空白
@data.push(nil)
# 生成位图、描绘全部项目
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max-1
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 项目的描绘
# index : 项目符号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4 + index % 1 * (90 + 32)
y = index / 1 * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 280, y, 16, 32, ":", 1)
self.contents.draw_text(x + 300, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
class Window_Status < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(80, 60, 480, 360)
self.z = 998
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.size = 16
#draw_actor_graphic(@actor, 40, 112)
draw_actor_name(@actor, 4, 0)
draw_actor_class(@actor, 4 + 144, 0)
draw_actor_level(@actor, 70, 0)
draw_actor_state(@actor, 0, 60)
draw_actor_hp(@actor, 4, 20, 172)
draw_actor_sp(@actor, 4, 40, 172)
draw_actor_parameter(@actor, 0, 90, 0)#攻击力
draw_actor_parameter(@actor, 0, 120, 1)#物防
draw_actor_parameter(@actor, 0, 150, 2)#魔防
draw_actor_parameter(@actor, 0, 180, 3)#力量
draw_actor_parameter(@actor, 0, 210, 4)#灵巧
draw_actor_parameter(@actor, 0, 270, 5)#速度
draw_actor_parameter(@actor, 0, 300, 6)#魔力
###########################################################
draw_actor_parameter(@actor, 0, 240, 7)#回避
###########################################################
self.contents.font.color = system_color
self.contents.draw_text(230, 0, 80, 32, "当前经验")
self.contents.draw_text(230, 40, 80, 32, "升级所需")
self.contents.font.color = normal_color
self.contents.draw_text(230 + 80, 0, 84, 32, @actor.exp_s, 2)
self.contents.draw_text(230 + 80, 40, 84, 32, @actor.next_rest_exp_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(230, 90, 96, 32, "当前装备")
draw_item_name($data_weapons[@actor.weapon_id], 230 + 16, 124)
draw_item_name($data_armors[@actor.armor1_id], 230 + 16, 168)
draw_item_name($data_armors[@actor.armor2_id], 230 + 16, 212)
draw_item_name($data_armors[@actor.armor3_id], 230 + 16, 256)
draw_item_name($data_armors[@actor.armor4_id], 230 + 16, 300)
end
end
#==============================================================================
# ■ Window_ShopCommand
#------------------------------------------------------------------------------
# 商店画面、选择要做的事的窗口
#==============================================================================
class Window_ShopCommand < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 64, 480, 64)
self.contents = Bitmap.new(width - 32, height - 32)
#self.z = 998
@item_max = 3
@column_max = 3
@commands = ["买", "卖", "离开"]
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
x = 4 + index * 160
self.contents.draw_text(x, 0, 128, 32, @commands[index])
end
end
#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# shop_goods : 商品
#--------------------------------------------------------------------------
def initialize(shop_goods)
super(70, 128, 250, 352)
@shop_goods = shop_goods
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $data_items[goods_item[1]]
when 1
item = $data_weapons[goods_item[1]]
when 2
item = $data_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
# 如果项目数不是 0 就生成位图、描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘羡慕
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
# 获取物品所持数
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
# 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
# 除此之外的情况设置为无效文字色
if item.price <= $game_party.gold and number < 99
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 120, y, 88, 32, item.price.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ■ Window_ShopSell
#------------------------------------------------------------------------------
# 商店画面、浏览显示可以卖掉的商品的窗口。
#==============================================================================
class Window_ShopSell < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(160, 128, 320, 352)
@column_max = 1
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items)
end
end
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons)
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors)
end
end
# 如果项目数不是 0 就生成位图、描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目标号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
# 可以卖掉的显示为普通文字颜色、除此之外设置成无效文字颜色
if item.price > 0
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (90 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ■ Window_ShopNumber
#------------------------------------------------------------------------------
# 商店画面、输入买卖数量的窗口。
#==============================================================================
class Window_ShopNumber < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(70, 128, 250, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
@Max = 1
@price = 0
@Number = 1
end
#--------------------------------------------------------------------------
# ● 设置物品、最大个数、价格
#--------------------------------------------------------------------------
def set(item, max, price)
@item = item
@max = max
@price = price
@number = 1
refresh
end
#--------------------------------------------------------------------------
# ● 被输入的件数设置
#--------------------------------------------------------------------------
def number
return @number
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_item_name(@item, 4, 96)
self.contents.font.color = normal_color
self.contents.draw_text(140, 130, 32, 32, "×")
self.contents.draw_text(180, 130, 24, 32, @number.to_s, 2)
self.cursor_rect.set(178, 130, 32, 32)
# 描绘合计价格和货币单位
domination = $data_system.words.gold
cx = contents.text_size(domination).width
total_price = @price * @number
self.contents.font.color = normal_color
self.contents.draw_text(4, 160, 200-cx-2, 32, total_price.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(204-cx, 160, cx, 32, domination, 2)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if self.active
# 光标右 (+1)
if Input.repeat?(Input::RIGHT) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number += 1
refresh
end
# 光标左 (-1)
if Input.repeat?(Input::LEFT) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number -= 1
refresh
end
# 光标上 (+10)
if Input.repeat?(Input::UP) and @number < @max
$game_system.se_play($data_system.cursor_se)
@number = [@number + 10, @max].min
refresh
end
# 光标下 (-10)
if Input.repeat?(Input::DOWN) and @number > 1
$game_system.se_play($data_system.cursor_se)
@number = [@number - 10, 1].max
refresh
end
end
end
end
#==============================================================================
# ■ Window_ShopStatus
#------------------------------------------------------------------------------
# 商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(320, 128, 250, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@item = nil
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @item == nil
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 200, 32, "所持数")
self.contents.font.color = normal_color
self.contents.draw_text(180, 0, 32, 32, number.to_s, 2)
if @item.is_a?(RPG::Item)
return
end
# 添加装备品信息
for i in 0...$game_party.actors.size
# 获取角色
actor = $game_party.actors
# 可以装备为普通文字颜色、不能装备设置为无效文字颜色
if actor.equippable?(@item)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
# 描绘角色名字
self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
# 获取当前的装备品
if @item.is_a?(RPG::Weapon)
item1 = $data_weapons[actor.weapon_id]
elsif @item.kind == 0
item1 = $data_armors[actor.armor1_id]
elsif @item.kind == 1
item1 = $data_armors[actor.armor2_id]
elsif @item.kind == 2
item1 = $data_armors[actor.armor3_id]
else
item1 = $data_armors[actor.armor4_id]
end
# 可以装备的情况
if actor.equippable?(@item)
# 武器的情况
if @item.is_a?(RPG::Weapon)
atk1 = item1 != nil ? item1.atk : 0
atk2 = @item != nil ? @item.atk : 0
change = atk2 - atk1
end
# 防具的情况
if @item.is_a?(RPG::Armor)
pdef1 = item1 != nil ? item1.pdef : 0
mdef1 = item1 != nil ? item1.mdef : 0
pdef2 = @item != nil ? @item.pdef : 0
mdef2 = @item != nil ? @item.mdef : 0
change = pdef2 - pdef1 + mdef2 - mdef1
end
# 描绘能力值变化
self.contents.draw_text(100, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
# 描绘物品
if item1 != nil
x = 4
y = 64 + 64 * i + 32
bitmap = RPG::Cache.icon(item1.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item1.name)
end
end
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 新的物品
#--------------------------------------------------------------------------
def item=(item)
if @item != item
@item = item
refresh
end
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# 处理菜单画面的类。
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# ● 初始化对像
# menu_index : 命令光标的初期位置
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成命令窗口
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "状态"
s5 = "存档"
s6 = "结束"
@command_window = Window_Command1.new(640, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
# 物品、特技、装备、状态无效化
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# 禁止存档的情况下
if $game_system.save_disabled
# 存档无效
@command_window.disable_item(4)
end
# 生成游戏时间窗口
@playtime_window = Window_PlayTime.new
@playtime_window.x = 320
@playtime_window.y = 385
# 生成步数窗口
@steps_window = Window_Steps.new
@steps_window.x = 160
@steps_window.y = 385
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 480
@gold_window.y = 385
# 生成状态窗口
@status_window = Window_MenuStatus.new
@status_window.x = 0
@status_window.y = 64
@map_window = Window_Map.new
@map_window.x = 0
@map_window.y = 385
@A_window = Window_A.new
@A_window.x = 0
@A_window.y = 64
@B_window = Window_B.new
@B_window.x = 160
@B_window.y = 64
@C_window = Window_C.new
@C_window.x = 320
@C_window.y = 64
@D_window = Window_D.new
@D_window.x = 480
@D_window.y = 64
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@playtime_window.dispose
@steps_window.dispose
@gold_window.dispose
@status_window.dispose
@map_window.dispose
@A_window.dispose
@B_window.dispose
@C_window.dispose
@D_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@playtime_window.update
@steps_window.update
@gold_window.update
@status_window.update
@map_window.update
@A_window.update
@B_window.update
@C_window.update
@D_window.update
# 命令窗口被激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 状态窗口被激活的情况下: 调用 update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (命令窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换的地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 同伴人数为 0、存档、游戏结束以外的场合
if $game_party.actors.size == 0 and @command_window.index < 4
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 命令窗口的光标位置分支
case @command_window.index
when 0 # 物品
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到物品画面
$scene = Scene_Item.new
when 1 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # 存档
# 禁止存档的情况下
if $game_system.save_disabled
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到存档画面
$scene = Scene_Save.new
when 5 # 游戏结束
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到游戏结束画面
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (状态窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_status
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活命令窗口
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口的光标位置分支
case @command_window.index
when 1 # 特技
# 本角色的行动限制在 2 以上的情况下
if $game_party.actors[@status_window.index].restriction >= 2
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到特技画面
$scene = Scene_Skill.new(@status_window.index)
when 2 # 装备
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换的装备画面
$scene = Scene_Equip.new(@status_window.index)
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到状态画面
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口、物品窗口
@help_window = Window_Help.new
@item_window = Window_Item.new
@Q_window = Window_Q.new
# 关联帮助窗口
@item_window.help_window = @help_window
# 生成目标窗口 (设置为不可见・不活动)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# 执行过度
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换就中断循环
if $scene != self
break
end
end
# 装备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@item_window.dispose
@target_window.dispose
@Q_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@item_window.update
@target_window.update
@Q_window.update
# 物品窗口被激活的情况下: 调用 update_item
if @item_window.active
update_item
return
end
# 目标窗口被激活的情况下: 调用 update_target
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (物品窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_item
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(0)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品窗口当前选中的物品数据
@item = @item_window.item
# 不使用物品的情况下
unless @item.is_a?(RPG::Item)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 不能使用的情况下
unless $game_party.item_can_use?(@item.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 效果范围是我方的情况下
if @item.scope >= 3
# 激活目标窗口
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 设置效果范围 (单体/全体) 的对应光标位置
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 效果在我方以外的情况下
else
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 由于物品用完而不能使用的场合
unless $game_party.item_can_use?(@item.id)
# 再次生成物品窗口的内容
@item_window.refresh
end
# 删除目标窗口
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 如果物品用完的情况下
if $game_party.item_number(@item.id) == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 目标是全体的情况下
if @target_window.index == -1
# 对同伴全体应用物品使用效果
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# 目标是单体的情况下
if @target_window.index >= 0
# 对目标角色应用物品的使用效果
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# 使用物品的情况下
if used
# 演奏物品使用时的 SE
$game_system.se_play(@item.menu_se)
# 消耗品的情况下
if @item.consumable
# 使用的物品数减 1
$game_party.lose_item(@item.id, 1)
# 再描绘物品窗口的项目
@item_window.draw_item(@item_window.index)
end
# 再生成目标窗口的内容
@target_window.refresh
# 全灭的情况下
if $game_party.all_dead?
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 公共事件 ID 有效的情况下
if @item.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @item.common_event_id
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#==============================================================================
# ■ Scene_Skill
#------------------------------------------------------------------------------
# 处理特技画面的类。
#==============================================================================
class Scene_Skill
#--------------------------------------------------------------------------
# ● 初始化对像
# actor_index : 角色索引
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 获取角色
@actor = $game_party.actors[@actor_index]
# 生成帮助窗口、状态窗口、特技窗口
@help_window = Window_Help.new
@Q_window = Window_Q.new
@status_window = Window_SkillStatus.new(@actor)
@skill_window = Window_Skill.new(@actor)
# 关联帮助窗口
@skill_window.help_window = @help_window
# 生成目标窗口 (设置为不可见・不活动)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@status_window.dispose
@skill_window.dispose
@target_window.dispose
@Q_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@status_window.update
@skill_window.update
@target_window.update
@Q_window.update
# 特技窗口被激活的情况下: 调用 update_skill
if @skill_window.active
update_skill
return
end
# 目标窗口被激活的情况下: 调用 update_target
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (特技窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_skill
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(1)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取特技窗口现在选择的特技的数据
@skill = @skill_window.skill
# 不能使用的情况下
if @skill == nil or not @actor.skill_can_use?(@skill.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 效果范围是我方的情况下
if @skill.scope >= 3
# 激活目标窗口
@skill_window.active = false
@target_window.x = (@skill_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 设置效果范围 (单体/全体) 的对应光标位置
if @skill.scope == 4 || @skill.scope == 6
@target_window.index = -1
elsif @skill.scope == 7
@target_window.index = @actor_index - 10
else
@target_window.index = 0
end
# 效果在我方以外的情况下
else
# 公共事件 ID 有效的情况下
if @skill.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @skill.common_event_id
# 演奏特技使用时的 SE
$game_system.se_play(@skill.menu_se)
# 消耗 SP
@actor.sp -= @skill.sp_cost
# 再生成各窗口的内容
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的特技画面
$scene = Scene_Skill.new(@actor_index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的特技画面
$scene = Scene_Skill.new(@actor_index)
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (目标窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_target
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 删除目标窗口
@skill_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 因为 SP 不足而无法使用的情况下
unless @actor.skill_can_use?(@skill.id)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 目标是全体的情况下
if @target_window.index == -1
# 对同伴全体应用特技使用效果
used = false
for i in $game_party.actors
used |= i.skill_effect(@actor, @skill)
end
end
# 目标是使用者的情况下
if @target_window.index <= -2
# 对目标角色应用特技的使用效果
target = $game_party.actors[@target_window.index + 10]
used = target.skill_effect(@actor, @skill)
end
# 目标是单体的情况下
if @target_window.index >= 0
# 对目标角色应用特技的使用效果
target = $game_party.actors[@target_window.index]
used = target.skill_effect(@actor, @skill)
end
# 使用特技的情况下
if used
# 演奏特技使用时的 SE
$game_system.se_play(@skill.menu_se)
# 消耗 SP
@actor.sp -= @skill.sp_cost
# 再生成各窗口内容
@status_window.refresh
@skill_window.refresh
@target_window.refresh
# 全灭的情况下
if $game_party.all_dead?
# 切换到游戏结束画面
$scene = Scene_Gameover.new
return
end
# 公共事件 ID 有效的情况下
if @skill.common_event_id > 0
# 预约调用公共事件
$game_temp.common_event_id = @skill.common_event_id
# 切换到地图画面
$scene = Scene_Map.new
return
end
end
# 无法使用特技的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
#==============================================================================
# ■ Scene_Equip
#------------------------------------------------------------------------------
# 处理装备画面的类。
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# ● 初始化对像
# actor_index : 角色索引
# equip_index : 装备索引
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
@equip_index = equip_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 获取角色
@actor = $game_party.actors[@actor_index]
# 生成窗口
@help_window = Window_Help.new
@left_window = Window_EquipLeft.new(@actor)
@right_window = Window_EquipRight.new(@actor)
@item_window1 = Window_EquipItem.new(@actor, 0)
@item_window2 = Window_EquipItem.new(@actor, 1)
@item_window3 = Window_EquipItem.new(@actor, 2)
@item_window4 = Window_EquipItem.new(@actor, 3)
@item_window5 = Window_EquipItem.new(@actor, 4)
# 关联帮助窗口
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
# 设置光标位置
@right_window.index = @equip_index
refresh
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话的就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@left_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 设置物品窗口的可视状态
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
# 获取当前装备中的物品
item1 = @right_window.item
# 设置当前的物品窗口到 @item_window
case @right_window.index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
# 右窗口被激活的情况下
if @right_window.active
# 删除变更装备后的能力
@left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil)
end
# 物品窗口被激活的情况下
if @item_window.active
# 获取现在选中的物品
item2 = @item_window.item
# 变更装备
last_hp = @actor.hp
last_sp = @actor.sp
@actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
# 获取变更装备后的能力值
new_atk = @actor.atk
new_pdef = @actor.pdef
new_mdef = @actor.mdef
new_str = @actor.str
new_dex = @actor.dex
new_eva = @actor.eva
new_agi = @actor.agi
new_int = @actor.int
# 返回到装备
@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
@actor.hp = last_hp
@actor.sp = last_sp
# 描画左窗口
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex, new_eva, new_agi, new_int)
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@left_window.update
@right_window.update
@item_window.update
refresh
# 右侧窗口被激活的情况下: 调用 update_right
if @right_window.active
update_right
return
end
# 物品窗口被激活的情况下: 调用 update_item
if @item_window.active
update_item
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (右侧窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_right
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(2)
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 固定装备的情况下
if @actor.equip_fix?(@right_window.index)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 激活物品窗口
@right_window.active = false
@item_window.active = true
@item_window.index = 0
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的装备画面
$scene = Scene_Equip.new(@actor_index, @right_window.index)
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (物品窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_item
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活右侧窗口
@right_window.active = true
@item_window.active = false
@item_window.index = -1
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 演奏装备 SE
$game_system.se_play($data_system.equip_se)
# 获取物品窗口现在选择的装备数据
item = @item_window.item
# 变更装备
@actor.equip(@right_window.index, item == nil ? 0 : item.id)
# 激活右侧窗口
@right_window.active = true
@item_window.active = false
@item_window.index = -1
# 再生成右侧窗口、物品窗口的内容
@right_window.refresh
@item_window.refresh
return
end
end
end
#==============================================================================
# ■ Scene_Status
#------------------------------------------------------------------------------
# 处理状态画面的类。
#==============================================================================
class Scene_Status
#--------------------------------------------------------------------------
# ● 初始化对像
# actor_index : 角色索引
#--------------------------------------------------------------------------
def initialize(actor_index = 0, equip_index = 0)
@actor_index = actor_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 获取角色
@actor = $game_party.actors[@actor_index]
# 生成状态窗口
@status_window = Window_Status.new(@actor)
@Q_window = Window_Q.new
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@status_window.dispose
@Q_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(3)
return
end
# 按下 R 键的情况下
if Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至下一位角色
@actor_index += 1
@actor_index %= $game_party.actors.size
# 切换到别的状态画面
$scene = Scene_Status.new(@actor_index)
return
end
# 按下 L 键的情况下
if Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 移至上一位角色
@actor_index += $game_party.actors.size - 1
@actor_index %= $game_party.actors.size
# 切换到别的状态画面
$scene = Scene_Status.new(@actor_index)
return
end
end
end
#==============================================================================
# ■ Scene_End
#------------------------------------------------------------------------------
# 处理游戏结束画面的类。
#==============================================================================
class Scene_End
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成命令窗口
s1 = "返回标题画面"
s2 = "退出"
s3 = "取消"
@Q_window = Window_Q.new
@command_window = Window_Command.new(192, [s1, s2, s3])
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入情报
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@Q_window.dispose
# 如果在标题画面切换中的情况下
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新命令窗口
@command_window.update
@Q_window.update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new(5)
return
end
# 按下 C 键的场合下
if Input.trigger?(Input::C)
# 命令窗口光标位置分支
case @command_window.index
when 0 # 返回标题画面
command_to_title
when 1 # 退出
command_shutdown
when 2 # 取消
command_cancel
end
return
end
end
#--------------------------------------------------------------------------
# ● 选择命令 [返回标题画面] 时的处理
#--------------------------------------------------------------------------
def command_to_title
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 淡入淡出 BGM、BGS、ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 切换到标题画面
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# ● 选择命令 [退出] 时的处理
#--------------------------------------------------------------------------
def command_shutdown
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 淡入淡出 BGM、BGS、ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 退出
$scene = nil
end
#--------------------------------------------------------------------------
# ● 选择命令 [取消] 时的处理
#--------------------------------------------------------------------------
def command_cancel
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到菜单画面
$scene = Scene_Menu.new(5)
end
end
#==============================================================================
# ■ Scene_Shop
#------------------------------------------------------------------------------
# 处理商店画面的类。
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口
@help_window = Window_Help.new
# 生成指令窗口
@command_window = Window_ShopCommand.new
@Q_window = Window_Q.new
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.opacity = 0
@gold_window.x = 480
@gold_window.y = 50
# 生成时间窗口
@dummy_window = Window_Base.new(0, 128, 640, 352)
# 生成购买窗口
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
# 生成卖出窗口
@sell_window = Window_ShopSell.new
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
# 生成数量输入窗口
@number_window = Window_ShopNumber.new
@number_window.active = false
@number_window.visible = false
# 生成状态窗口
@status_window = Window_ShopStatus.new
@status_window.visible = false
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
@command_window.dispose
@gold_window.dispose
@dummy_window.dispose
@buy_window.dispose
@sell_window.dispose
@number_window.dispose
@status_window.dispose
@Q_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@command_window.update
@gold_window.update
@dummy_window.update
@buy_window.update
@sell_window.update
@number_window.update
@status_window.update
@Q_window.update
# 指令窗口激活的情况下: 调用 update_command
if @command_window.active
update_command
return
end
# 购买窗口激活的情况下: 调用 update_buy
if @buy_window.active
update_buy
return
end
# 卖出窗口激活的情况下: 调用 update_sell
if @sell_window.active
update_sell
return
end
# 个数输入窗口激活的情况下: 调用 update_number
if @number_window.active
update_number
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (指令窗口激活的情况下)
#--------------------------------------------------------------------------
def update_command
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到地图画面
$scene = Scene_Map.new
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向购买模式
@command_window.active = false
@dummy_window.visible = false
@buy_window.active = true
@buy_window.visible = true
@buy_window.refresh
@status_window.visible = true
when 1 # 卖出
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 窗口状态转向卖出模式
@command_window.active = false
@dummy_window.visible = false
@sell_window.active = true
@sell_window.visible = true
@sell_window.refresh
when 2 # 取消
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到地图画面
$scene = Scene_Map.new
end
return
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (购买窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
# 设置状态窗口的物品
@status_window.item = @buy_window.item
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @buy_window.item
# 物品无效的情况下、或者价格在所持金以上的情况下
if @item == nil or @item.price > $game_party.gold
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 获取物品所持数
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
# 如果已经拥有了 99 个情况下
if number == 2000
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 计算可以最多购买的数量
max = @item.price == 0 ? 2000 : $game_party.gold / @item.price
max = [max, 2000 - number].min
# 窗口状态转向数值输入模式
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● 画面更新 (卖出窗口激活的情况下)
#--------------------------------------------------------------------------
def update_sell
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @sell_window.item
# 设置状态窗口的物品
@status_window.item = @item
# 物品无效的情况下、或者价格为 0 (不能卖出) 的情况下
if @item == nil or @item.price == 0
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 获取物品的所持数
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
# 最大卖出个数 = 物品的所持数
max = number
# 窗口状态转向个数输入模式
@sell_window.active = false
@sell_window.visible = false
if $game_switches[46] == true
@number_window.set(@item, max, @item.price*100/125)
else
@number_window.set(@item, max, @item.price/2)
end
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (个数输入窗口激活的情况下)
#--------------------------------------------------------------------------
def update_number
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 设置个数输入窗口为不活动·非可视状态
@number_window.active = false
@number_window.visible = false
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 演奏商店 SE
$game_system.se_play($data_system.shop_se)
# 设置个数输入窗口为不活动·非可视状态
@number_window.active = false
@number_window.visible = false
# 命令窗口光标位置分支
case @command_window.index
when 0 # 购买
# 购买处理
$game_party.lose_gold(@number_window.number * @item.price)
case @item
when RPG::Item
$game_party.gain_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.gain_armor(@item.id, @number_window.number)
end
# 刷新各窗口
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
# 卖出处理
if $game_switches[46] == true
$game_party.gain_gold(@number_window.number * (@item.price*100/125))
else
$game_party.gain_gold(@number_window.number * (@item.price / 2))
end
case @item
when RPG::Item
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.lose_armor(@item.id, @number_window.number)
end
# 刷新各窗口
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
end
end
#==============================================================================
# ■ 全部替换 Window_Steps
#------------------------------------------------------------------------------
# 菜单画面显示步数的窗口。
#==============================================================================
class Window_Map < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 96)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@x = $game_player.x #获取角色X坐标
@y = $game_player.y #获取角色Y坐标
@id = $game_map.map_id #获取地图编号
self.contents.clear #清除以前的东西
$mapnames = load_data("Data/MapInfos.rxdata") #读取地图名文件
map_name = $mapnames[@id].name #获得地图名
self.contents.font.color = normal_color#颜色,这里是白色~
self.contents.draw_text(0, 0, 116, 32, map_name,2)
self.contents.font.color = system_color#颜色,暗蓝色
self.contents.draw_text(0, 32, 120, 32, "X:")#显示X这个字的位置,引号里面的内容随便改,比如"X坐标地址"
self.contents.font.color = normal_color#颜色,这里是白色~
self.contents.draw_text(0, 32, 52, 32, @x.to_s,2)
self.contents.font.color = system_color#上面那个是X坐标的变量,可以自己更改变量名~
self.contents.draw_text(64, 32, 128, 32, "Y:")#显示Y这个字~
self.contents.font.color = normal_color
self.contents.draw_text(0, 32, 116, 32, @y.to_s,2)
end
end
class Window_A< Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
#self.back_opacity = 0
self.contents = Bitmap.new(width - 32, height - 64)
# refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
# def refresh
#self.contents.clear
#self.contents.font.color = system_color
#self.contents.draw_text(4, , 64, 16, "虾米")
# end
end
class Window_B< Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
#self.back_opacity = 0
self.contents = Bitmap.new(width - 32, height - 64)
# refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
# def refresh
#self.contents.clear
#self.contents.font.color = system_color
#self.contents.draw_text(4, , 64, 16, "虾米")
# end
end
class Window_C< Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
#self.back_opacity = 0
self.contents = Bitmap.new(width - 32, height - 64)
# refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
# def refresh
#self.contents.clear
#self.contents.font.color = system_color
#self.contents.draw_text(4, , 64, 16, "虾米")
# end
end
class Window_D< Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 320)
#self.back_opacity = 0
self.contents = Bitmap.new(width - 32, height - 64)
# refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
# def refresh
#self.contents.clear
#self.contents.font.color = system_color
#self.contents.draw_text(4, , 64, 16, "虾米")
# end
end
class Window_Q< Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
#self.back_opacity = 0
self.contents = Bitmap.new(width - 32, height - 64)
# refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
# def refresh
#self.contents.clear
#self.contents.font.color = system_color
#self.contents.draw_text(4, , 64, 16, "虾米")
# end
end
class Window_Command1 < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# width : 窗口的宽
# commands : 命令字符串序列
#--------------------------------------------------------------------------
def initialize(width, commands)
# 由命令的个数计算出窗口的高
super(0, 0, width, 64)
@item_max = commands.size
@commands = commands
@column_max = commands.size
self.contents = Bitmap.new(width - 32, 64- 32)
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
# color : 文字色
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
# 计算光标的宽
cursor_width = width / @column_max - 32
# 计算光标坐标
x = index % @column_max * (cursor_width + 32)
#y = @index / @column_max * 32 - self.oy
rect = Rect.new(x, 0, cursor_width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end
#--------------------------------------------------------------------------
# ● 项目无效化
# index : 项目编号
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
class Game_Actor < Game_Battler
def now_exp
return @exp - @exp_list[@level]
end
def next_exp
return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
end
end
#==========================================================
# ■ Window_Base
#------------------------------------------------------------
# ゲーム中のすべてのウィンドウのスーパークラスです。
#============================================================
class Window_Base < Window
#--------------------------------------------------------
# ● HP ゲージの描画
#--------------------------------------------------
# オリジナルのHP描画を draw_actor_hp_original と名前変更
alias :draw_actor_hp_original :draw_actor_hp
def draw_actor_hp(actor, x, y, width = 144)
# 変数rateに 現在のHP/MHPを代入
if actor.maxhp != 0
rate = actor.hp.to_f / actor.maxhp
else
rate = 0
end
# plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
# plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
# align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
# align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
# align3:ゲージタイプ 0:左詰め 1:右詰め
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 85
height = 10
align1 = 1
align2 = 2
align3 = 0
# グラデーション設定 grade1:空ゲージ grade2:実ゲージ
# (0:横にグラデーション 1:縦にグラデーション 2:斜めにグラデーション(激重))
grade1 = 1
grade2 = 0
# 色設定。color1:外枠,color2:中枠
# color3:空ゲージダークカラー,color4:空ゲージライトカラー
# color5:実ゲージダークカラー,color6:実ゲージライトカラー
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 192)
color4 = Color.new(64, 0, 0, 192)
color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
# 変数spに描画するゲージの幅を代入
if actor.maxhp != 0
hp = (width + plus_width) * actor.hp * rate_width / 100 / actor.maxhp
else
hp = 0
end
# ゲージの描画
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, hp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
# オリジナルのHP描画処理を呼び出し
draw_actor_hp_original(actor, x, y, width)
end
#--------------------------------------------------------------
# ● SP ゲージの描画
#------------------------------------------------------------
# オリジナルのSP描画を draw_actor_sp_original と名前変更
alias :draw_actor_sp_original :draw_actor_sp
def draw_actor_sp(actor, x, y, width = 144)
# 変数rateに 現在のSP/MSPを代入
if actor.maxsp != 0
rate = actor.sp.to_f / actor.maxsp
else
rate = 1
end
# plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
# plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
# align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
# align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
# align3:ゲージタイプ 0:左詰め 1:右詰め
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 85
height = 10
align1 = 1
align2 = 2
align3 = 0
# グラデーション設定 grade1:空ゲージ grade2:実ゲージ
# (0:横にグラデーション 1:縦にグラデーション 2:斜めにグラデーション(激重))
grade1 = 1
grade2 = 0
# 色設定。color1:外枠,color2:中枠
# color3:空ゲージダークカラー,color4:空ゲージライトカラー
# color5:実ゲージダークカラー,color6:実ゲージライトカラー
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 192)
color4 = Color.new(0, 64, 0, 192)
color5 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
color6 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
# 変数spに描画するゲージの幅を代入
if actor.maxsp != 0
sp = (width + plus_width) * actor.sp * rate_width / 100 / actor.maxsp
else
sp = (width + plus_width) * rate_width / 100
end
# ゲージの描画
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, sp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
# オリジナルのSP描画処理を呼び出し
draw_actor_sp_original(actor, x, y, width)
end
#--------------------------------------------------------
# ● EXP ゲージの描画
#----------------------------------------------------------
# オリジナルのEXP描画を draw_actor_sp_original と名前変更
alias :draw_actor_exp_original :draw_actor_exp
def draw_actor_exp(actor, x, y, width = 144)
# 変数rateに 現在のexp/nextexpを代入
if actor.next_exp != 0
rate = actor.now_exp.to_f / actor.next_exp
else
rate = 1
end
# plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
# plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
# align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
# align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
# align3:ゲージタイプ 0:左詰め 1:右詰め
plus_x = 0
rate_x = 0
plus_y = 25
plus_width = 0
rate_width = 85
height = 10
align1 = 1
align2 = 2
align3 = 0
# グラデーション設定 grade1:空ゲージ grade2:実ゲージ
# (0:横にグラデーション 1:縦にグラデーション 2:斜めにグラデーション(激重))
grade1 = 1
grade2 = 0
# 色設定。color1:外枠,color2:中枠
# color3:空ゲージダークカラー,color4:空ゲージライトカラー
# color5:実ゲージダークカラー,color6:実ゲージライトカラー
color1 = Color.new(0, 0, 0, 192)
color2 = Color.new(255, 255, 192, 192)
color3 = Color.new(0, 0, 0, 192)
color4 = Color.new(64, 0, 0, 192)
color5 = Color.new(80 * rate, 80 - 80 * rate ** 2, 80 - 80 * rate, 192)
color6 = Color.new(240 * rate, 240 - 240 * rate ** 2, 240 - 240 * rate, 192)
# 変数expに描画するゲージの幅を代入
if actor.next_exp != 0
exp = (width + plus_width) * actor.now_exp * rate_width /
100 / actor.next_exp
else
exp = (width + plus_width) * rate_width / 100
end
# ゲージの描画
gauge_rect(x + plus_x + width * rate_x / 100, y + plus_y,
width, plus_width + width * rate_width / 100,
height, exp, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
# オリジナルのEXP描画処理を呼び出し
draw_actor_exp_original(actor, x, y)
end
#---------------------------------------------------------
# ● ゲージの描画
#-----------------------------------------------------
def gauge_rect(x, y, rect_width, width, height, gauge, align1, align2, align3,
color1, color2, color3, color4, color5, color6, grade1, grade2)
case align1
when 1
x += (rect_width - width) / 2
when 2
x += rect_width - width
end
case align2
when 1
y -= height / 2
when 2
y -= height
end
# 枠描画
self.contents.fill_rect(x, y, width, height, color1)
self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, color2)
if align3 == 0
if grade1 == 2
grade1 = 3
end
if grade2 == 2
grade2 = 3
end
end
if (align3 == 1 and grade1 == 0) or grade1 > 0
color = color3
color3 = color4
color4 = color
end
if (align3 == 1 and grade2 == 0) or grade2 > 0
color = color5
color5 = color6
color6 = color
end
# 空ゲージの描画
self.contents.gradation_rect(x + 2, y + 2, width - 4, height - 4,
color3, color4, grade1)
if align3 == 1
x += width - gauge
end
# 実ゲージの描画
self.contents.gradation_rect(x + 2, y + 2, gauge - 4, height - 4,
color5, color6, grade2)
end
end
#--------------------------------------------------------------
# Bitmapクラスに新たな機能を追加します。
#===================================================================
class Bitmap
#------------------------------------------------------------
# ● 矩形をグラデーション表示
# color1 : スタートカラー
# color2 : エンドカラー
# align : 0:横にグラデーション
# 1:縦にグラデーション
# 2:斜めにグラデーション(激重につき注意)
#--------------------------------------------------------
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
for i in x...x + width
red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green = color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align == 1
for i in y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green = color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) / (height - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align == 2
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align == 3
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
end
#==================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==================================================================
@紫英晓狼1130 |
|