赞 | 0 |
VIP | 0 |
好人卡 | 2 |
积分 | 1 |
经验 | 12207 |
最后登录 | 2016-8-13 |
在线时间 | 438 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 438 小时
- 注册时间
- 2009-1-6
- 帖子
- 230
|
#==============================================================================
#真·仙剑菜单
#脚本作者by七夕小雨
#本脚本来自于66RPG 转贴请保留该信息
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# ● 初始化对像
# menu_index : 命令光标的初期位置
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
#############################
@backsp2 = Sprite.new
@backsp2.bitmap = Bitmap.new("Graphics/menu/menu_all.png")
@backsp2.x = 0
@backsp2.y = 0
@backsp2.z = 1
############################
# 生成命令窗口
@command_window = Window_Command.new(250,["状态", "仙术", "物品", "系统"])
@command_window.windowskin = RPG::Cache.windowskin("nil")
@command_window.width = 180
@command_window.height = 250
@command_window.y = 115
@command_window.x = -1
@command_window.z = 10
@command_window.opacity = 0
@command_window.index = @menu_index
#================================================================
@command_window.contents = Bitmap.new("Graphics/menu/menu.png")
#================================================================
# 同伴人数为 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
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 60
@gold_window.opacity = 0
# 生成状态窗口
@status_window = Window_MenuStatus.new
# 执行过渡
#=============================================================
case @menu_index
when 0
@command_window.contents = Bitmap.new("Graphics/menu/menu.png")
when 1
@command_window.contents = Bitmap.new("Graphics/menu/menu2.png")
when 2
@command_window.contents = Bitmap.new("Graphics/menu/menu3.png")
when 3
@command_window.contents = Bitmap.new("Graphics/menu/menu4.png")
end
#====================================================================
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@gold_window.dispose
@status_window.dispose
@backsp2.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@gold_window.update
@status_window.update
#=============================================================
case @command_window.index
when 0
@command_window.contents = Bitmap.new("Graphics/menu/menu.png")
when 1
@command_window.contents = Bitmap.new("Graphics/menu/menu2.png")
when 2
@command_window.contents = Bitmap.new("Graphics/menu/menu3.png")
when 3
@command_window.contents = Bitmap.new("Graphics/menu/menu4.png")
end
#====================================================================
# 命令窗口被激活的情况下: 调用 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)
# 激活状态窗口
@command_window.active = false
@status_window.active = true
@status_window.index = 0
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)
# 切换到物品画面
$scene = Scene_Menu_Item.new
when 3 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到物品画面
$scene = Scene_Menu_System.new
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 0 # 状态
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到状态画面
$scene = Scene_Status.new(@status_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
#-------------------------物品·二级菜单--------------------------------------
class Scene_Menu_Item
#--------------------------------------------------------------------------
# ● 初始化对像
# menu_index : 命令光标的初期位置
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
#############################
@backsp2 = Sprite.new
@backsp2.bitmap = Bitmap.new("Graphics/menu/menu_all_2.jpg")
@backsp2.x = 0
@backsp2.y = 0
@backsp2.z = 1
############################
# 生成命令窗口
@command_window = Window_Command.new(250,["装备", "物品"])
@command_window.windowskin = RPG::Cache.windowskin("nil")
@command_window.width = 180
@command_window.height = 250
@command_window.y = 150
@command_window.x = 60
@command_window.z = 10
@command_window.opacity = 0
@command_window.index = @menu_index
#================================================================
@command_window.contents = Bitmap.new("Graphics/menu/menu3_1.png")
#================================================================
# 同伴人数为 0 的情况下
# 禁止存档的情况下
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 60
@gold_window.opacity = 0
# 生成状态窗口
@status_window = Window_MenuStatus.new
# 执行过渡
#=============================================================
case @menu_index
when 0
@command_window.contents = Bitmap.new("Graphics/menu/menu3_1.png")
when 1
@command_window.contents = Bitmap.new("Graphics/menu/menu3_2.png")
end
#====================================================================
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@gold_window.dispose
@status_window.dispose
@backsp2.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@gold_window.update
@status_window.update
#=============================================================
case @command_window.index
when 0
@command_window.contents = Bitmap.new("Graphics/menu/menu3_1.png")
when 1
@command_window.contents = Bitmap.new("Graphics/menu/menu3_2.png")
end
#====================================================================
# 命令窗口被激活的情况下: 调用 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_Menu.new(2)
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
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 # 特技
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换的装备画面
$scene = Scene_Equip.new(@status_window.index)
end
return
end
end
end
#-------------------------系统·二级菜单--------------------------------------
class Scene_Menu_System
#--------------------------------------------------------------------------
# ● 初始化对像
# menu_index : 命令光标的初期位置
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
#############################
@backsp2 = Sprite.new
@backsp2.bitmap = Bitmap.new("Graphics/menu/menu_all_3.jpg")
@backsp2.x = 0
@backsp2.y = 0
@backsp2.z = 1
############################
# 生成命令窗口
@command_window = Window_Command.new(250,["存储", "读取","离开"])
@command_window.windowskin = RPG::Cache.windowskin("nil")
@command_window.width = 280
@command_window.height = 250
@command_window.y = 150
@command_window.x = 60
@command_window.z = 10
@command_window.opacity = 0
@command_window.index = @menu_index
#================================================================
@command_window.contents = Bitmap.new("Graphics/menu/menu4_1.png")
#================================================================
# 生成金钱窗口
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = 60
@gold_window.opacity = 0
# 执行过渡
#=============================================================
case @menu_index
when 0
@command_window.contents = Bitmap.new("Graphics/menu/menu4_1.png")
when 1
@command_window.contents = Bitmap.new("Graphics/menu/menu4_2.png")
when 2
@command_window.contents = Bitmap.new("Graphics/menu/menu4_3.png")
end
#====================================================================
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果切换画面就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@command_window.dispose
@gold_window.dispose
@backsp2.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
@gold_window.update
#=============================================================
case @command_window.index
when 0
@command_window.contents = Bitmap.new("Graphics/menu/menu4_1.png")
when 1
@command_window.contents = Bitmap.new("Graphics/menu/menu4_2.png")
when 2
@command_window.contents = Bitmap.new("Graphics/menu/menu4_3.png")
end
#====================================================================
# 命令窗口被激活的情况下: 调用 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_Menu.new(3)
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 # 存储
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 1 # 读取
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
$scene = Scene_Load.new
when 2 # 离开
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
$scene = nil
end
return
end
end
end
2.
#==============================================================================
# ■ 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 = 9999
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(255, -255, -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, 141, 0, 255)
when 7
return Color.new(80, 73, 127, 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 = Color.new(64,70,124,255)
self.contents.draw_text(x, y, 32, 32, "")
self.contents.font.color = Color.new(64,70,124,255)
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 + 24, y, 84, 32, actor.exp_s, 2)
self.contents.draw_text(x + 108, y, 12, 32, "/", 1)
self.contents.draw_text(x + 120, 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 : Color.new(224,96,112,255)
self.contents.font.color = Color.new(224,96,112,255)
self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
# 描绘 MaxHP
if flag
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
self.contents.font.color = Color.new(224,96,112,255)
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 : Color.new(80,112,232,255)
self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
# 描绘 MaxSP
if flag
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
self.contents.font.color = Color.new(80,112,232,255)
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
end
self.contents.font.color = normal_color
self.contents.font.color = Color.new(64,70,124,255)
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 = Color.new(64,70,124,255)
self.contents.draw_text(x + 28, y, 212, 32, item.name)
end
#==============================================================
def draw_actor_hp1(actor, x, y, width = 72)
# 计算描绘 MaxHP 所需的空间
if width - 24 >= 32
hp_x = x + 32# + width - 24
end
# 描绘 HP
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : Color.new(255,-255,-255,255)
self.contents.draw_text(315 + x, 409 , 64, 32, actor.hp.to_s, 2)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(380 + x, 409, 12, 32, "/", 1)
self.contents.font.color = Color.new(255,-255,-255,255)
self.contents.draw_text(350 + x, 409, 64, 32, actor.maxhp.to_s,2)
end
#--------------------------------------------------------------------------
# ● 描绘 SP
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标的宽
#--------------------------------------------------------------------------
def draw_actor_sp1(actor, x, y, width = 72)
# 计算描绘 MaxSP 所需的空间
if width - 24 >= 32
sp_x = x + 32# + width - 24
end
# 描绘 SP
self.contents.font.color = actor.sp == 0 ? knockout_color :
actor.sp <= actor.maxsp / 4 ? crisis_color : Color.new(-255,-255,255,255)
self.contents.draw_text(315 + x, 426, 64, 32, actor.sp.to_s, 2)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(380 + x, 426, 12, 32, "/", 1)
self.contents.font.color = Color.new(-255,-255,255,255)
self.contents.draw_text(350 + x, 426, 64, 32, actor.maxsp.to_s,2)
end
end
3.
#==============================================================================
# ■ Window_Selectable
#------------------------------------------------------------------------------
# 拥有光标的移动以及滚动功能的窗口类。
#==============================================================================
class Window_Selectable_MenuStatus < Window_Base
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :index # 光标位置
attr_reader :help_window # 帮助窗口
#--------------------------------------------------------------------------
# ● 初始画对像
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的高
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 1
@index = -1
end
#--------------------------------------------------------------------------
# ● 设置光标的位置
# index : 新的光标位置
#--------------------------------------------------------------------------
def index=(index)
@index = index
# 刷新帮助文本 (update_help 定义了继承目标)
if self.active and @help_window != nil
update_help
end
# 刷新光标矩形
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 获取行数
#--------------------------------------------------------------------------
def row_max
# 由项目数和列数计算出行数
return (@item_max + @column_max - 1) / @column_max
end
#--------------------------------------------------------------------------
# ● 获取开头行
#--------------------------------------------------------------------------
def top_row
# 将窗口内容的传送源 Y 坐标、1 行的高 32 等分
return self.oy / 32
end
#--------------------------------------------------------------------------
# ● 设置开头行
# row : 显示开头的行
#--------------------------------------------------------------------------
def top_row=(row)
# row 未满 0 的场合更正为 0
if row < 0
row = 0
end
# row 超过 row_max - 1 的情况下更正为 row_max - 1
if row > row_max - 1
row = row_max - 1
end
# row 1 行高的 32 倍、窗口内容的传送源 Y 坐标
self.oy = row * 32
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的行数
#--------------------------------------------------------------------------
def page_row_max
# 窗口的高度,设置画面的高度减去 32 ,除以 1 行的高度 32
return (self.height - 32) / 32
end
#--------------------------------------------------------------------------
# ● 获取 1 页可以显示的项目数
#--------------------------------------------------------------------------
def page_item_max
# 将行数 page_row_max 乘上列数 @column_max
return page_row_max * @column_max
end
#--------------------------------------------------------------------------
# ● 帮助窗口的设置
# help_window : 新的帮助窗口
#--------------------------------------------------------------------------
def help_window=(help_window)
@help_window = help_window
# 刷新帮助文本 (update_help 定义了继承目标)
if self.active and @help_window != nil
update_help
end
end
#--------------------------------------------------------------------------
# ● 更新光标举行
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 32
# 计算光标坐标
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * 32 - self.oy
# 更新国标矩形
self.cursor_rect.set(x, y, cursor_width, 32)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 可以移动光标的情况下
if self.active and @item_max > 0 and @index >= 0
# 方向键右被按下的情况下
if Input.repeat?(Input::LEFT)
if (@column_max == 1 and Input.trigger?(Input::UP)) or
@index >= @column_max
# 光标向上移动
$game_system.se_play($data_system.cursor_se)
@index = (@index - @column_max + @item_max) % @item_max
end
end
# 方向键左被按下的情况下
if Input.repeat?(Input::RIGHT)
if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
@index < @item_max - @column_max
# 光标向下移动
$game_system.se_play($data_system.cursor_se)
@index = (@index + @column_max) % @item_max
end
end
# R 键被按下的情况下
if Input.repeat?(Input::R)
# 显示的最后行在数据中最后行上方的情况下
if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
# 光标向后移动一页
$game_system.se_play($data_system.cursor_se)
@index = [@index + self.page_item_max, @item_max - 1].min
self.top_row += self.page_row_max
end
end
# L 键被按下的情况下
if Input.repeat?(Input::L)
# 显示的开头行在位置 0 之后的情况下
if self.top_row > 0
# 光标向前移动一页
$game_system.se_play($data_system.cursor_se)
@index = [@index - self.page_item_max, 0].max
self.top_row -= self.page_row_max
end
end
end
# 刷新帮助文本 (update_help 定义了继承目标)
if self.active and @help_window != nil
update_help
end
# 刷新光标矩形
update_cursor_rect
end
end
4.
#---------------------------物品·帮助-------------------------------
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 特技及物品的说明、角色的状态显示的窗口。
#==============================================================================
class Window_Help2 < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(-16, -16, 640, 480)
self.windowskin = RPG::Cache.windowskin("nil")
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 220
self.z = 400
end
#--------------------------------------------------------------------------
# ● 设置文本
# text : 窗口显示的字符串
# align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
#--------------------------------------------------------------------------
def set_text(text, y = nil,align = 0)
self.visible = true
self.contents.clear
self.contents.font.color = Color.new(64,70,124,255)
@text = text.clone
x = y = 0
begin
last_text = @text.clone
@text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until @text == last_text
@text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
@text.gsub!(/\\\\/) { "\000" }
@text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
@text.gsub!(/\\[Nn]/) { "\002" }
@text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
while ((c = @text.slice!(/./m)) != nil)
if c == "\000"
c = "\\"
end
if c == "\001"
@text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
next
end
if c == "\002"
y += 1
x = 0
next
end
if c == "\003"
@text.sub!(/\[([0-9]+)\]/, "")
t = RPG::Cache.icon("item_#{$1}")
self.contents.blt(-40, 0, t, t.rect)
t.dispose
next
end
self.contents.draw_text(205 + x, 32 * y+32, 40, 32, c)
x += self.contents.text_size(c).width
end
end
end
#------------------------------技能·帮助----------------------------------
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 特技及物品的说明、角色的状态显示的窗口。
#==============================================================================
class Window_Help < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(-16, -16, 640, 480)
self.windowskin = RPG::Cache.windowskin("nil")
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 220
self.z = 400
end
#--------------------------------------------------------------------------
# ● 设置文本
# text : 窗口显示的字符串
# align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
#--------------------------------------------------------------------------
def set_text(text, y = nil,align = 0)
self.visible = true
self.contents.clear
self.contents.font.color = Color.new(64,70,124,255)
@text = text.clone
x = y = 0
begin
last_text = @text.clone
@text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
end until @text == last_text
@text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
$game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
end
@text.gsub!(/\\\\/) { "\000" }
@text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
@text.gsub!(/\\[Nn]/) { "\002" }
@text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
while ((c = @text.slice!(/./m)) != nil)
if c == "\000"
c = "\\"
end
if c == "\001"
@text.sub!(/\[([0-9]+)\]/, "")
color = $1.to_i
if color >= 0 and color <= 7
self.contents.font.color = text_color(color)
end
next
end
if c == "\002"
y += 1
x = 0
next
end
if c == "\003"
@text.sub!(/\[([0-9]+)\]/, "")
t = RPG::Cache.icon("skill_#{$1}")
self.contents.blt(0, 15, t, t.rect)
t.dispose
next
end
self.contents.draw_text(176 + x, 32 * y+32, 40, 32, c)
x += self.contents.text_size(c).width
end
end
5.
#==============================================================================
# ■ Window_Target
#------------------------------------------------------------------------------
# 物品画面与特技画面的、使用对像角色选择窗口。
#==============================================================================
class Window_Target < Window_Selectable_MenuStatus
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 320, 480, 480)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 14
self.opacity = 0
self.z += 10
@item_max = $game_party.actors.size
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
x = i * 160
y = 25
actor = $game_party.actors
@actor = actor
testname = @actor.name.to_s
#=========================================
bitmap=Bitmap.new("Graphics/menu/status/#{testname}_a")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
#=========================================
draw_actor_hp(actor, x + 23, y + 58)
draw_actor_sp(actor, x + 20, y + 72)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
# 光标位置 -1 为全选、-2 以下为单独选择 (使用者自身)
if @index <= -2
self.cursor_rect.set(@index*160, 50, 150, 76)
elsif @index == -1
self.cursor_rect.set(0, 50, @item_max * 155, 76)
else
self.cursor_rect.set(@index*160, 50, 150, 76)
end
end
def dispose
super
end
end
6.
#==============================================================================
# ■ Window_Status
#------------------------------------------------------------------------------
# 显示状态画面、完全规格的状态窗口。
#==============================================================================
class Window_Status < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(-16, -16, 800, 600)
self.back_opacity = 0
self.opacity = 0
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
self.contents.font.size = 20
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
#======================================================
testname = @actor.name.to_s
self.contents.clear
bitmap=Bitmap.new("Graphics/menu/Status/#{testname}")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(0, 0, bitmap, src_rect)
bitmap=Bitmap.new("Graphics/menu/Status/#{testname}"+"_1")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(40, 380, bitmap, src_rect)
#======================================================
draw_actor_level(@actor, 120, 80)
draw_actor_hp(@actor, 34, 157, 172)
draw_actor_sp(@actor, 34, 182, 172)
draw_actor_parameter(@actor, 20, 266, 1)
draw_actor_parameter(@actor, 20, 210, 3)
draw_actor_parameter(@actor, 20, 322, 4)
draw_actor_parameter(@actor, 20, 294, 5)
draw_actor_parameter(@actor, 20, 238, 6)
self.contents.font.color = Color.new(64,70,124,255)
self.contents.draw_text(90, 108, 84, 32, @actor.exp_s, 2)
self.contents.font.color = Color.new(168,232,160,255)
self.contents.draw_text(90, 128, 84, 32, @actor.next_rest_exp_s, 2)
end
end
7.
#==============================================================================
# ■ Window_Gold
#------------------------------------------------------------------------------
# 显示金钱的窗口。
#==============================================================================
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64)
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 = Color.new(64,70,124,255)
self.contents.font.size = 18
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 1)
end
end
8.
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_Item2 < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(30, 150, 595, 240)
#==============================
self.windowskin = RPG::Cache.windowskin("choose")
#=============================================================
@column_max = 2
refresh
self.index = 0
if $game_temp.in_battle
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 = Color.new(64,70,124,255)
else
self.contents.font.color = Color.new(224,96,112,255)
end
x = 4 + index % 2 * (288 + 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))
opacity = self.contents.font.color == normal_color ? 255 : 128.
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 180, y, 16, 32, "X", 1)
self.contents.draw_text(x + 200, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
9.
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# 物品画面、战斗画面、显示浏览物品的窗口。
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(30, 150, 595, 240)
#==============================
self.windowskin = RPG::Cache.windowskin("choose")
@backsp1 = Sprite.new
@backsp1.bitmap = Bitmap.new("Graphics/menu/底板.png")
@backsp1.z = 99
@backsp2 = Sprite.new
@backsp2.bitmap = Bitmap.new("Graphics/menu/物品.png")
@backsp2.x = 15
@backsp2.y = 115
@backsp2.z = 101
#=============================================================
@help2 = Sprite.new
@help2.bitmap = Bitmap.new("Graphics/menu/帮助窗口使用.png")
@help2.x = 15
@help2.y = -20
@help2.z = 100
#==============================
@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 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 = Color.new(64,70,124,255)
else
self.contents.font.color = Color.new(224,96,112,255)
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(64,70,124,0))
#bitmap = RPG::Cache.icon(item.icon_name)
#self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
opacity = self.contents.font.color == Color.new(224,96,112,255) ? 255 : 128.
#self.contents.font.color = Color.new(64,70,124,255)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 180, y, 16, 32, "X", 1)
self.contents.draw_text(x + 200, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
desc1 = self.item == nil ? '' : self.item.description
item2 = $data_skills[self.item.id + 1]
desc2 = item2 == nil ? '' : item2.description
@help_window.set_text(desc1 + desc2, [@index / @column_max * 28 - self.oy, 260].min)
end
#====================
def dispose
super
@backsp1.dispose
@backsp2.dispose
@help2.dispose
end
#=====================
end
10.
#==============================================================================
# ■ Window_Skill
#------------------------------------------------------------------------------
# 特技画面、战斗画面、显示可以使用的特技浏览的窗口。
#==============================================================================
class Window_Skill2 < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(30, 150, 595, 240)
#==============================
self.windowskin = RPG::Cache.windowskin("choose")
#=============================================================
@actor = actor
@column_max = 2
refresh
self.index = 0
# 战斗中的情况下将窗口移至中央并将其半透明化
if $game_temp.in_battle
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 = Color.new(64,70,124,255)
else
self.contents.font.color = Color.new(224,96,112,255)
end
x = 4 + index % 2 * (288 + 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))
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 160, y, 48, 32, skill.sp_cost.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
desc1 = self.skill == nil ? '' : self.skill.description
skill2 = $data_skills[self.skill.id + 1]
desc2 = skill2 == nil ? '' : skill2.description
@help_window.set_text(desc1 + desc2, [@index / @column_max * 28 - self.oy, 260].min)
end
end
11.
#==============================================================================
# ■ Window_Skill
#------------------------------------------------------------------------------
# 特技画面、战斗画面、显示可以使用的特技浏览的窗口。
#==============================================================================
class Window_Skill < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(30, 150, 595, 240)
self.windowskin = RPG::Cache.windowskin("choose")
@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 = Color.new(64,70,124,255)
else
self.contents.font.color = Color.new(224,96,112,255)
end
x = 4 + index % 2 * (288 + 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))
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
self.contents.draw_text(x + 160, y, 48, 32, skill.sp_cost.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 刷新帮助文本
#--------------------------------------------------------------------------
def update_help
desc1 = self.skill == nil ? '' : self.skill.description
skill2 = $data_skills[self.skill.id + 1]
desc2 = skill2 == nil ? '' : skill2.description
@help_window.set_text(desc1 + desc2, [@index / @column_max * 28 - self.oy, 260].min)
end
end
12.
#==============================================================================
# ■ Window_MenuStatus
#------------------------------------------------------------------------------
# 显示菜单画面和同伴状态的窗口。
#==============================================================================
class Window_MenuStatus < Window_Selectable_MenuStatus
#--------------------------------------------------------------------------
# ● 初始化目标
#--------------------------------------------------------------------------
def initialize
super(140, 330, 480, 200)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 14
self.opacity = 0
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
x = i * 160
y = 25
actor = $game_party.actors
@actor = actor
testname = @actor.name.to_s
#-------------------------------------------------------------------
bitmap = Bitmap.new("Graphics/menu/Status/#{testname}"+"_a")
src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
self.contents.blt(x, y, bitmap, src_rect)
#-------------------------------------------------------------------
draw_actor_hp(actor, x + 23, y + 58)
draw_actor_sp(actor, x + 20, y + 72)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(@index*160, 50, 150, 76)
end
end
end
13.
#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
# 显示存档以及读档画面、保存文件的窗口。
#==============================================================================
class Window_SaveFile < Window_Base
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :filename # 文件名
attr_reader :selected # 选择状态
#--------------------------------------------------------------------------
# ● 初始化对像
# file_index : 存档文件的索引 (0~3)
# filename : 文件名
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(250, 64 + file_index % 4 * 104, 640, 100)
self.windowskin = RPG::Cache.windowskin("choose")
self.contents = Bitmap.new(width, height)
@file_index = file_index
@filename = "Save#{@file_index + 1}.rxdata"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@selected = false
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 描绘文件编号
self.contents.font.color = normal_color
name = "进度 #{@file_index + 1}"
self.contents.draw_text(4, 0, 600, 32, name)
@name_width = contents.text_size(name).width
# 存档文件存在的情况下
if @file_exist
# 描绘角色
for i in [email protected]
bitmap = RPG::Cache.character(@characters[0]+"_a", @characters[1])
cw = bitmap.rect.width / 4
ch = bitmap.rect.height / 4
src_rect = Rect.new(0, 0, cw, ch)
x = 150 - @characters.size * 32 + i * 64 - cw / 2
self.contents.blt(x, 68 - ch, bitmap, src_rect)
end
# 描绘游戏时间
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
time_string = sprintf("%02d小时%02d分", hour, min, sec)
self.contents.font.size = 16
self.contents.font.color = Color.new(64,70,124,255)
self.contents.draw_text(6, 38, 600, 32, time_string, 1)
self.contents.draw_text(0,-7,600,32, @game_variables[11].to_s,1)
self.contents.draw_text(0,16,600,32, @game_variables[16].to_s,1)
end
end
#--------------------------------------------------------------------------
# ● 设置选择状态
# selected : 新的选择状态 (true=选择 false=不选择)
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @selected
self.cursor_rect.set(0, 0, 240, 32)
else
self.cursor_rect.empty
end
end
end
14.
#==============================================================================
# ■ Window_SaveFile
#------------------------------------------------------------------------------
# 显示存档以及读档画面、保存文件的窗口。
#==============================================================================
class Window_SaveFile2 < Window_Base
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :filename # 文件名
attr_reader :selected # 选择状态
#--------------------------------------------------------------------------
# ● 初始化对像
# file_index : 存档文件的索引 (0~3)
# filename : 文件名
#--------------------------------------------------------------------------
def initialize(file_index, filename)
super(250, 64 + file_index % 4 * 104, 640, 100)
self.windowskin = RPG::Cache.windowskin("choose")
#================================================
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
#=============================================================
@back = Sprite.new
@back.bitmap = Bitmap.new("Graphics/menu/标题存档.png")
@back.z = 150
#==============================
#================================================
self.contents = Bitmap.new(width, height)
@file_index = file_index
@filename = "Save#{@file_index + 1}.rxdata"
@time_stamp = Time.at(0)
@file_exist = FileTest.exist?(@filename)
if @file_exist
file = File.open(@filename, "r")
@time_stamp = file.mtime
@characters = Marshal.load(file)
@frame_count = Marshal.load(file)
@game_system = Marshal.load(file)
@game_switches = Marshal.load(file)
@game_variables = Marshal.load(file)
@total_sec = @frame_count / Graphics.frame_rate
file.close
end
refresh
@selected = false
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 描绘文件编号
self.contents.font.color = normal_color
name = "进度 #{@file_index + 1}"
self.contents.draw_text(4, 0, 600, 32, name)
@name_width = contents.text_size(name).width
# 存档文件存在的情况下
if @file_exist
# 描绘角色
for i in [email protected]
bitmap = RPG::Cache.character(@characters[0]+"_a", @characters[1])
cw = bitmap.rect.width / 4
ch = bitmap.rect.height / 4
src_rect = Rect.new(0, 0, cw, ch)
x = 150 - @characters.size * 32 + i * 64 - cw / 2
self.contents.blt(x, 68 - ch, bitmap, src_rect)
end
# 描绘游戏时间
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
time_string = sprintf("%02d小时%02d分", hour, min, sec)
self.contents.font.size = 16
self.contents.font.color = Color.new(64,70,124,255)
self.contents.draw_text(6, 38, 600, 32, time_string, 1)
self.contents.draw_text(0,-7,600,32, @game_variables[11].to_s,1)
self.contents.draw_text(0,16,600,32, @game_variables[16].to_s,1)
end
end
#--------------------------------------------------------------------------
# ● 设置选择状态
# selected : 新的选择状态 (true=选择 false=不选择)
#--------------------------------------------------------------------------
def selected=(selected)
@selected = selected
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
if @selected
self.cursor_rect.set(0, 0, 240, 32)
else
self.cursor_rect.empty
end
end
#====================
def dispose
super
@sprite.dispose
@back.dispose
end
#=====================
end
15.
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
# 显示战斗画面同伴状态的窗口。
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 320, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@level_up_flags = [false, false, false, false]
self.z = 1
refresh
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# ● 设置升级标志
# actor_index : 角色索引
#--------------------------------------------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors
actor_x = i * 160 + 4
draw_actor_name(actor, actor_x, 0)
draw_actor_hp(actor, actor_x, 32, 120)
draw_actor_sp(actor, actor_x, 64, 120)
if @level_up_flags
self.contents.font.color = normal_color
self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
else
draw_actor_state(actor, actor_x, 96)
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 主界面的不透明度下降
if $game_temp.battle_main_phase
self.contents_opacity -= 4 if self.contents_opacity > 191
else
self.contents_opacity += 4 if self.contents_opacity < 255
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
#==========================
@help2 = Sprite.new
@help2.bitmap = Bitmap.new("Graphics/menu/帮助窗口使用.png")
@help2.x = 15
@help2.y = -20
@help2.z = 100
#==============================
@backsp1 = Sprite.new
@backsp1.bitmap = Bitmap.new("Graphics/menu/底板.png")
@backsp1.z = 99
@backsp2 = Sprite.new
@backsp2.bitmap = Bitmap.new("Graphics/menu/物品.png")
@backsp2.x = 15
@backsp2.y = 115
@backsp2.z = 101
#=============================================================
# 获取角色
@actor = $game_party.actors[@actor_index]
# 生成帮助窗口、状态窗口、特技窗口
@help_window = Window_Help.new
@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
# 释放窗口
@backsp1.dispose
@backsp2.dispose
@help2.dispose
@help_window.dispose
@skill_window.dispose
@target_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@help_window.update
@skill_window.update
@target_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_Map.new
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.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
# 再生成各窗口内容
@skill_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
17.
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 处理物品画面的类。
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成帮助窗口、物品窗口
@help_window = Window_Help2.new
@item_window = Window_Item.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
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@item_window.update
@help_window.update
@target_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_Item.new
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.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#wjx
$game_system.map_interpreter.setup($data_common_events[@item.common_event_id].list, 0)
# 演奏物品使用时的 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
# 切换到地图画面
#if $game_temp.common_event_id == 107
#$game_temp.common_event_id = 0
#$game_system.map_interpreter.setup($data_common_events[107].list, 0)
#end
$scene = Scene_Menu_Item.new(1)
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_system.map_interpreter.setup($data_common_events[@item.common_event_id].list, 0)
# 预约调用公共事件
#$game_temp.common_event_id = @item.common_event_id
# 切换到地图画面
#if $game_temp.common_event_id == 107
#$game_temp.common_event_id = 0
#$game_system.map_interpreter.setup($data_common_events[107].list, 0)
#end
$scene = Scene_Map.new
return
end
end
# 无法使用物品的情况下
unless used
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
18.
#==============================================================================
# ■ 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)
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@status_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到菜单画面
$scene = Scene_Menu.new
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
19.
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#
# 防具类追加
#
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
module RPG
class Armor
def name
name = @name.split(/,/)[0]
return name != nil ? name : ''
end
def kind
kind = @name.split(/,/)[1]
return kind != nil ? kind.to_i : @kind
end
end
end
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#
# Game_Actor添加新的防具ID,并对相关方法修正
#
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
class Game_Actor < Game_Battler
attr_reader :armor5_id # 项链 ID
attr_reader :armor6_id # 鞋 ID
#--------------------------------------------------------------------------
# ● 设置
# actor_id : 角色 ID
#--------------------------------------------------------------------------
alias old_setup setup
def setup(actor_id)
old_setup(actor_id)
@armor5_id = 0
@armor6_id = 0
update_auto_state(nil, $data_armors[@armor5_id])
update_auto_state(nil, $data_armors[@armor6_id])
end
#--------------------------------------------------------------------------
# ● 取得属性修正值
# element_id : 属性 ID
#--------------------------------------------------------------------------
def element_rate(element_id)
# 获取对应属性有效度的数值
table = [0,200,150,100,50,0,-100]
result = table[$data_classes[@class_id].element_ranks[element_id]]
# 防具能防御本属性的情况下效果减半
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, @armor5_id, @armor6_id]
armor = $data_armors
if armor != nil and armor.guard_element_set.include?(element_id)
result /= 2
end
end
# 状态能防御本属性的情况下效果减半
for i in @states
if $data_states.guard_element_set.include?(element_id)
result /= 2
end
end
# 过程结束
return result
end
#--------------------------------------------------------------------------
# ● 判定防御属性
# state_id : 属性 ID
#--------------------------------------------------------------------------
def state_guard?(state_id)
for i in [@armor1_id, @armor2_id, @armor3_id, @armor4_id, @armor5_id, @armor6_id]
armor = $data_armors
if armor != nil
if armor.guard_state_set.include?(state_id)
return true
end
end
end
return false
end
#--------------------------------------------------------------------------
# ● 获取基本力量
#--------------------------------------------------------------------------
def base_str
n = $data_actors[@actor_id].parameters[2, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
armor5 = $data_armors[@armor5_id]
armor6 = $data_armors[@armor6_id]
n += weapon != nil ? weapon.str_plus : 0
n += armor1 != nil ? armor1.str_plus : 0
n += armor2 != nil ? armor2.str_plus : 0
n += armor3 != nil ? armor3.str_plus : 0
n += armor4 != nil ? armor4.str_plus : 0
n += armor5 != nil ? armor5.str_plus : 0
n += armor6 != nil ? armor6.str_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本灵巧
#--------------------------------------------------------------------------
def base_dex
n = $data_actors[@actor_id].parameters[3, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
armor5 = $data_armors[@armor5_id]
armor6 = $data_armors[@armor6_id]
n += weapon != nil ? weapon.dex_plus : 0
n += armor1 != nil ? armor1.dex_plus : 0
n += armor2 != nil ? armor2.dex_plus : 0
n += armor3 != nil ? armor3.dex_plus : 0
n += armor4 != nil ? armor4.dex_plus : 0
n += armor5 != nil ? armor5.dex_plus : 0
n += armor6 != nil ? armor6.dex_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本速度
#--------------------------------------------------------------------------
def base_agi
n = $data_actors[@actor_id].parameters[4, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
armor5 = $data_armors[@armor5_id]
armor6 = $data_armors[@armor6_id]
n += weapon != nil ? weapon.agi_plus : 0
n += armor1 != nil ? armor1.agi_plus : 0
n += armor2 != nil ? armor2.agi_plus : 0
n += armor3 != nil ? armor3.agi_plus : 0
n += armor4 != nil ? armor4.agi_plus : 0
n += armor5 != nil ? armor5.agi_plus : 0
n += armor6 != nil ? armor6.agi_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本魔力
#--------------------------------------------------------------------------
def base_int
n = $data_actors[@actor_id].parameters[5, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
armor5 = $data_armors[@armor5_id]
armor6 = $data_armors[@armor6_id]
n += weapon != nil ? weapon.int_plus : 0
n += armor1 != nil ? armor1.int_plus : 0
n += armor2 != nil ? armor2.int_plus : 0
n += armor3 != nil ? armor3.int_plus : 0
n += armor4 != nil ? armor4.int_plus : 0
n += armor5 != nil ? armor5.int_plus : 0
n += armor6 != nil ? armor6.int_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本物理防御
#--------------------------------------------------------------------------
def base_pdef
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
armor5 = $data_armors[@armor5_id]
armor6 = $data_armors[@armor6_id]
pdef1 = weapon != nil ? weapon.pdef : 0
pdef2 = armor1 != nil ? armor1.pdef : 0
pdef3 = armor2 != nil ? armor2.pdef : 0
pdef4 = armor3 != nil ? armor3.pdef : 0
pdef5 = armor4 != nil ? armor4.pdef : 0
pdef6 = armor5 != nil ? armor5.pdef : 0
pdef7 = armor6 != nil ? armor6.pdef : 0
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5 + pdef6 + pdef7
end
#--------------------------------------------------------------------------
# ● 获取基本魔法防御
#--------------------------------------------------------------------------
def base_mdef
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
armor5 = $data_armors[@armor5_id]
armor6 = $data_armors[@armor6_id]
mdef1 = weapon != nil ? weapon.mdef : 0
mdef2 = armor1 != nil ? armor1.mdef : 0
mdef3 = armor2 != nil ? armor2.mdef : 0
mdef4 = armor3 != nil ? armor3.mdef : 0
mdef5 = armor4 != nil ? armor4.mdef : 0
mdef6 = armor5 != nil ? armor5.mdef : 0
mdef7 = armor6 != nil ? armor6.mdef : 0
return mdef1 + mdef2 + mdef3 + mdef4 + mdef5 + mdef6 + mdef7
end
#--------------------------------------------------------------------------
# ● 获取基本回避修正
#--------------------------------------------------------------------------
def base_eva
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
armor5 = $data_armors[@armor5_id]
armor6 = $data_armors[@armor6_id]
eva1 = armor1 != nil ? armor1.eva : 0
eva2 = armor2 != nil ? armor2.eva : 0
eva3 = armor3 != nil ? armor3.eva : 0
eva4 = armor4 != nil ? armor4.eva : 0
eva5 = armor5 != nil ? armor5.eva : 0
eva6 = armor6 != nil ? armor6.eva : 0
return eva1 + eva2 + eva3 + eva4 + eva5 + eva6
end
#--------------------------------------------------------------------------
# ● 装备固定判定
# equip_type : 装备类型
#--------------------------------------------------------------------------
def equip_fix?(equip_type)
case equip_type
when 0 # 武器
return $data_actors[@actor_id].weapon_fix
when 1 # 盾
return $data_actors[@actor_id].armor1_fix
when 2 # 头
return $data_actors[@actor_id].armor2_fix
when 3 # 身体
return $data_actors[@actor_id].armor3_fix
when 4 # 装饰品
return $data_actors[@actor_id].armor4_fix
end
return false
end
#--------------------------------------------------------------------------
# ● 变更装备
# equip_type : 装备类型
# id : 武器 or 防具 ID (0 为解除装备)
#--------------------------------------------------------------------------
def equip(equip_type, id)
case equip_type
when 0 # 武器
if id == 0 or $game_party.weapon_number(id) > 0
$game_party.gain_weapon(@weapon_id, 1)
@weapon_id = id
$game_party.lose_weapon(id, 1)
end
when 1 # 盾
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor1_id], $data_armors[id])
$game_party.gain_armor(@armor1_id, 1)
@armor1_id = id
$game_party.lose_armor(id, 1)
end
when 2 # 头
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor2_id], $data_armors[id])
$game_party.gain_armor(@armor2_id, 1)
@armor2_id = id
$game_party.lose_armor(id, 1)
end
when 3 # 身体
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor3_id], $data_armors[id])
$game_party.gain_armor(@armor3_id, 1)
@armor3_id = id
$game_party.lose_armor(id, 1)
end
when 4 # 装饰品
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor4_id], $data_armors[id])
$game_party.gain_armor(@armor4_id, 1)
@armor4_id = id
$game_party.lose_armor(id, 1)
end
when 5 # 项链
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor5_id], $data_armors[id])
$game_party.gain_armor(@armor5_id, 1)
@armor5_id = id
$game_party.lose_armor(id, 1)
end
when 6 # 鞋
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor6_id], $data_armors[id])
$game_party.gain_armor(@armor6_id, 1)
@armor6_id = id
$game_party.lose_armor(id, 1)
end
end
end
#--------------------------------------------------------------------------
# ● 更改职业 ID
# class_id : 新的职业 ID
#--------------------------------------------------------------------------
def class_id=(class_id)
if $data_classes[class_id] != nil
@class_id = class_id
# 避开无法装备的物品
unless equippable?($data_weapons[@weapon_id])
equip(0, 0)
end
unless equippable?($data_armors[@armor1_id])
equip(1, 0)
end
unless equippable?($data_armors[@armor2_id])
equip(2, 0)
end
unless equippable?($data_armors[@armor3_id])
equip(3, 0)
end
unless equippable?($data_armors[@armor4_id])
equip(4, 0)
end
unless equippable?($data_armors[@armor5_id])
equip(5, 0)
end
unless equippable?($data_armors[@armor6_id])
equip(6, 0)
end
end
end
end
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#
# Window_Base美化,增加属性增减颜色,及全能力值描绘
#
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 游戏中全部窗口的超级类。
#==============================================================================
class Window_Base < Window
################## 属性增减颜色 ##############################
def up_color
return Color.new(80,112,232,255)
end
def down_color
return Color.new(224,96,112,255)
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 = Color.new(80,112,232,255)
self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
end
end
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#
# 装备窗口美化,全能力值描绘并追加新的防具装备栏
#
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#==============================================================================
# ■ Window_EquipRight
#------------------------------------------------------------------------------
# 装备画面、显示角色现在装备的物品的窗口。
#==============================================================================
class Window_EquipRight < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(100, 68, 180, 280)
self.windowskin = RPG::Cache.windowskin("choose")
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@data = []
@data.push($data_weapons[@actor.weapon_id])
@data.push($data_armors[@actor.armor1_id])
@data.push($data_armors[@actor.armor2_id])
@data.push($data_armors[@actor.armor3_id])
@data.push($data_armors[@actor.armor4_id])
@data.push($data_armors[@actor.armor5_id])
@item_max = @data.size
self.contents.font.color = system_color
self.contents.draw_text(4, 32 * 0, 92, 32, "")
self.contents.draw_text(4, 32 * 1, 92, 32, "")
self.contents.draw_text(4, 32 * 2, 92, 32, "")
self.contents.draw_text(4, 32 * 3, 92, 32, "")
self.contents.draw_text(4, 32 * 4, 92, 32, "")
self.contents.draw_text(4, 32 * 5, 92, 32, "")
draw_item_name(@data[0], 20, 32 * 0)
draw_item_name(@data[1], 20, 32 * 1)
draw_item_name(@data[2], 20, 32 * 2)
draw_item_name(@data[3], 20, 32 * 3)
draw_item_name(@data[4], 20, 32 * 4)
draw_item_name(@data[5], 20, 32 * 5)
draw_item_name(@data[6], 20, 32 * 6)
end
end
#==============================================================================
# ■ Window_EquipLeft
#------------------------------------------------------------------------------
# 装备画面的、显示角色能力值变化的窗口。
#==============================================================================
class Window_EquipLeft < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
super(295, 3, 272, 416)
self.contents = Bitmap.new(width - 32, height - 32)
#========================================
self.windowskin = RPG::Cache.windowskin("nil")
#========================================
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = Color.new(80,112,232,255)
draw_actor_parameter(@actor, 4, 64, 0)
draw_actor_parameter(@actor, 4, 96, 4)
draw_actor_parameter(@actor, 4, 128, 1)
draw_actor_parameter(@actor, 4, 160, 5)
draw_actor_parameter(@actor, 4, 192, 6)
if @new_atk != nil
self.contents.font.color = system_color
bitmap = RPG::Cache.icon("加.png")
self.contents.blt(160,66 ,bitmap, Rect.new(0, 0, 48, 36))
self.contents.font.color = @new_atk>@actor.atk ? up_color : down_color
self.contents.font.color = Color.new(80,112,232,255) if @new_atk == @actor.atk
self.contents.draw_text(200, 64, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
self.contents.font.color = system_color
bitmap = RPG::Cache.icon("加.png")
self.contents.blt(160,130 ,bitmap, Rect.new(0, 0, 48, 36))
self.contents.font.color = @new_pdef>@actor.pdef ? up_color : down_color
self.contents.font.color = Color.new(80,112,232,255) if @new_pdef == @actor.pdef
self.contents.draw_text(200, 128, 36, 32, @new_pdef.to_s, 2)
end
if @new_str != nil
self.contents.font.color = system_color
bitmap = RPG::Cache.icon("加.png")
self.contents.blt(160,98 ,bitmap, Rect.new(0, 0, 48, 36))
self.contents.font.color = @new_str>@actor.str ? up_color : down_color
self.contents.font.color = Color.new(80,112,232,255) if @new_str == @actor.str
self.contents.draw_text(200, 96, 36, 32, @new_str.to_s, 2)
end
if @new_dex != nil
self.contents.font.color = system_color
bitmap = RPG::Cache.icon("加.png")
self.contents.blt(160,162 ,bitmap, Rect.new(0, 0, 48, 36))
self.contents.font.color = @new_dex>@actor.dex ? up_color : down_color
self.contents.font.color = Color.new(80,112,232,255)if @new_dex == @actor.dex
self.contents.draw_text(200, 160, 36, 32, @new_dex.to_s, 2)
end
if @new_agi != nil
self.contents.font.color = system_color
bitmap = RPG::Cache.icon("加.png")
self.contents.blt(160,194 ,bitmap, Rect.new(0, 0, 48, 36))
self.contents.font.color = @new_agi>@actor.agi ? up_color : down_color
self.contents.font.color = Color.new(80,112,232,255) if @new_agi == @actor.agi
self.contents.draw_text(200, 192, 36, 32, @new_agi.to_s, 2)
end
end
#--------------------------------------------------------------------------
# ● 变更装备后的能力值设置
# new_atk : 变更装备后的攻击力
# new_pdef : 变更装备后的物理防御
# new_mdef : 变更装备后的魔法防御
#--------------------------------------------------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef, new_eva, new_str, new_dex, new_agi, new_int)
if @new_atk != new_atk or @new_pdef !=new_pdef or @new_mdef != new_mdef or @new_eva != new_eva or @new_str != new_str or @new_dex !=new_dex or @new_agi != new_agi or @new_int != new_int
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
@new_eva = new_eva
@new_str = new_str
@new_dex = new_dex
@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(0, 295, 400, 100)
self.windowskin = RPG::Cache.windowskin("choose")
@actor = actor
@equip_type = equip_type
@column_max = 1
refresh
self.active = false
self.index = -1
end
#--------------------------------------------------------------------------
# ● 项目的描绘
# index : 项目符号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
x = 4
y = index * 32
case item
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 = Color.new(80,112,232,255)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 180, y, 16, 32, "X", 1)
self.contents.draw_text(x + 200, y, 24, 32, number.to_s, 2)
end
end
class Scene_Equip
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 获取角色
@actor = $game_party.actors[@actor_index]
# 生成窗口
#=================================
@backsp1 = Sprite.new
@backsp1.bitmap = Bitmap.new("Graphics/menu/底板.png")
@backsp1.z = 98
@backsp2 = Sprite.new
@backsp2.bitmap = Bitmap.new("Graphics/menu/装备.png")
@backsp2.x = 0
@backsp2.y = 50
@backsp2.z = 100
@backsp3 = Sprite.new
@backsp3.bitmap = Bitmap.new("Graphics/menu/装备_下.png")
@backsp3.x = 7
@backsp3.y = 300
@backsp3.z = 99
#==================================
@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)
@item_window6 = Window_EquipItem.new(@actor, 5)
@item_window7 = Window_EquipItem.new(@actor, 6)
# 关联帮助窗口
@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
@item_window6.help_window = @help_window
@item_window7.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
# 释放窗口
@backsp1.dispose
@backsp2.dispose
@backsp3.dispose
@left_window.dispose
@right_window.dispose
@item_window1.dispose
@item_window2.dispose
@item_window3.dispose
@item_window4.dispose
@item_window5.dispose
@item_window6.dispose
@item_window7.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面 (右侧窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_right
# 按下 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)
# 固定装备的情况下
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 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)
@item_window6.visible = (@right_window.index == 5)
@item_window7.visible = (@right_window.index == 6)
# 获取当前装备中的物品
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
when 5
@item_window = @item_window6
when 6
@item_window = @item_window7
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_eva = @actor.eva
new_str = @actor.str
new_dex = @actor.dex
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_eva, new_str, new_dex, new_agi, new_int)
###############################################################
end
end
end
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#
# 商店购买窗口美化,增加对新装备位置的描述
#
# ★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#==============================================================================
# ■ Window_ShopStatus
#------------------------------------------------------------------------------
# 商店画面、显示物品所持数与角色装备的窗口。
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
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(204, 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]
elsif @item.kind == 3
item1 = $data_armors[actor.armor4_id]
elsif @item.kind == 4
item1 = $data_armors[actor.armor5_id]
else# if @item.kind == 5
item1 = $data_armors[actor.armor6_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(124, 64 + 64 * i, 112, 32,
sprintf("%+d", change), 2)
end
# 描绘物品
if item1 != nil
x = 4
y = 64 + 64 * i + 32
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.draw_text(x + 28, y, 212, 32, item1.name)
end
end
end
end
20.
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# 存档画面及读档画面的超级类。
#==============================================================================
class Scene_File
#--------------------------------------------------------------------------
# ● 初始化对像
# help_text : 帮助窗口显示的字符串
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成存档文件查
@savefile_windows = []
#=========================================================
@backsp = Sprite.new
@backsp.bitmap = Bitmap.new("Graphics/menu/菜单存档_假.jpg")
@backsp.z = 99
#=====================================================
for i in 0..3
@savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
end
# 选择最后操作的文件
@file_index = $game_temp.last_file_index
@savefile_windows[@file_index].selected = true
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
for i in @savefile_windows
i.dispose
@backsp.dispose
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
for i in @savefile_windows
i.update
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 调用过程 on_decision (定义继承目标)
on_decision(make_filename(@file_index))
$game_temp.last_file_index = @file_index
return
end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 调用过程 on_cancel (定义继承目标)
on_cancel
return
end
# 按下方向键下的情况下
if Input.repeat?(Input::DOWN)
# 方向键下的按下状态不是重复的情况下、
# 并且光标的位置在 3 以前的情况下
if Input.trigger?(Input::DOWN) or @file_index < 3
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 光标向下移动
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 1) % 4
@savefile_windows[@file_index].selected = true
return
end
end
# 按下方向键上的情况下
if Input.repeat?(Input::UP)
# 方向键上的按下状态不是重复的情况下、
# 并且光标的位置在 0 以后的情况下
if Input.trigger?(Input::UP) or @file_index > 0
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 光标向上移动
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 3) % 4
@savefile_windows[@file_index].selected = true
return
end
end
end
#--------------------------------------------------------------------------
# ● 生成文件名
# file_index : 文件名的索引 (0~3)
#--------------------------------------------------------------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
end
21.
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# 存档画面及读档画面的超级类。
#==============================================================================
class Scene_File3
#--------------------------------------------------------------------------
# ● 初始化对像
# help_text : 帮助窗口显示的字符串
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成存档文件查
@savefile_windows = []
#=========================================================
@backsp = Sprite.new
@backsp.bitmap = Bitmap.new("Graphics/menu/菜单读档_假.jpg")
@backsp.z = 99
#=====================================================
for i in 0..3
@savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
end
# 选择最后操作的文件
@file_index = $game_temp.last_file_index
@savefile_windows[@file_index].selected = true
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
for i in @savefile_windows
i.dispose
@backsp.dispose
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
for i in @savefile_windows
i.update
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 调用过程 on_decision (定义继承目标)
on_decision(make_filename(@file_index))
$game_temp.last_file_index = @file_index
return
end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 调用过程 on_cancel (定义继承目标)
on_cancel
return
end
# 按下方向键下的情况下
if Input.repeat?(Input::DOWN)
# 方向键下的按下状态不是重复的情况下、
# 并且光标的位置在 3 以前的情况下
if Input.trigger?(Input::DOWN) or @file_index < 3
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 光标向下移动
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 1) % 4
@savefile_windows[@file_index].selected = true
return
end
end
# 按下方向键上的情况下
if Input.repeat?(Input::UP)
# 方向键上的按下状态不是重复的情况下、
# 并且光标的位置在 0 以后的情况下
if Input.trigger?(Input::UP) or @file_index > 0
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 光标向上移动
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 3) % 4
@savefile_windows[@file_index].selected = true
return
end
end
end
#--------------------------------------------------------------------------
# ● 生成文件名
# file_index : 文件名的索引 (0~3)
#--------------------------------------------------------------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
end
22.
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# 存档画面及读档画面的超级类。
#==============================================================================
class Scene_File2
#--------------------------------------------------------------------------
# ● 初始化对像
# help_text : 帮助窗口显示的字符串
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 生成存档文件查
@savefile_windows = []
for i in 0..3
@savefile_windows.push(Window_SaveFile2.new(i, make_filename(i)))
end
# 选择最后操作的文件
@file_index = $game_temp.last_file_index
@savefile_windows[@file_index].selected = true
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
for i in @savefile_windows
i.dispose
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
for i in @savefile_windows
i.update
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 调用过程 on_decision (定义继承目标)
on_decision(make_filename(@file_index))
$game_temp.last_file_index = @file_index
return
end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 调用过程 on_cancel (定义继承目标)
$scene = Scene_Title.new
end
# 按下方向键下的情况下
if Input.repeat?(Input::DOWN)
# 方向键下的按下状态不是重复的情况下、
# 并且光标的位置在 3 以前的情况下
if Input.trigger?(Input::DOWN) or @file_index < 3
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 光标向下移动
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 1) % 4
@savefile_windows[@file_index].selected = true
return
end
end
# 按下方向键上的情况下
if Input.repeat?(Input::UP)
# 方向键上的按下状态不是重复的情况下、
# 并且光标的位置在 0 以后的情况下
if Input.trigger?(Input::UP) or @file_index > 0
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 光标向上移动
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 3) % 4
@savefile_windows[@file_index].selected = true
return
end
end
end
#--------------------------------------------------------------------------
# ● 生成文件名
# file_index : 文件名的索引 (0~3)
#--------------------------------------------------------------------------
def make_filename(file_index)
return "Save#{file_index + 1}.rxdata"
end
end
23.
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
# 处理读档画面的类。
#==============================================================================
class Scene_Load2 < Scene_File2
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 再生成临时对像
$game_temp = Game_Temp.new
# 选择存档时间最新的文件
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("要载入哪个文件?")
end
#--------------------------------------------------------------------------
# ● 确定时的处理
#--------------------------------------------------------------------------
def on_decision(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 写入存档数据
file = File.open(filename, "rb")
read_save_data(file)
file.close
# 还原 BGM、BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# 刷新地图 (执行并行事件)
$game_map.update
# 切换到地图画面
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 取消时的处理
#--------------------------------------------------------------------------
def on_cancel
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到标题画面
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 读取存档数据
# file : 读取用文件对像 (已经打开)
#--------------------------------------------------------------------------
def read_save_data(file)
# 读取描绘存档文件用的角色数据
characters = Marshal.load(file)
# 读取测量游戏时间用画面计数
Graphics.frame_count = Marshal.load(file)
# 读取各种游戏对像
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
if $game_system.magic_number != $data_system.magic_number
# 重新装载地图
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# 刷新同伴成员
$game_party.refresh
end
end
24.
#==============================================================================
# ■ Scene_Save
#------------------------------------------------------------------------------
# 处理存档画面的类。
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super("要保存到这个文件吗?")
end
#--------------------------------------------------------------------------
# ● 确定时的处理
#--------------------------------------------------------------------------
def on_decision(filename)
# 演奏存档 SE
$game_system.se_play($data_system.save_se)
# 写入存档数据
file = File.open(filename, "wb")
write_save_data(file)
file.close
# 如果被事件调用
if $game_temp.save_calling
# 清除存档调用标志
$game_temp.save_calling = false
# 切换到地图画面
$scene = Scene_Map.new
return
end
# 切换到菜单画面
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 取消时的处理
#--------------------------------------------------------------------------
def on_cancel
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 如果被事件调用
if $game_temp.save_calling
# 清除存档调用标志
$game_temp.save_calling = false
# 切换到地图画面
$scene = Scene_Map.new
return
end
# 切换到菜单画面
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 写入存档数据
# file : 写入用文件对像 (已经打开)
#--------------------------------------------------------------------------
def write_save_data(file)
# 生成描绘存档文件用的角色图形
characters = []
for i in 0...$game_party.actors.size
actor = $game_party.actors
characters.push([actor.character_name, actor.character_hue])
end
# 写入描绘存档文件用的角色数据
Marshal.dump(characters, file)
# 写入测量游戏时间用画面计数
Marshal.dump(Graphics.frame_count, file)
# 增加 1 次存档次数
$game_system.save_count += 1
# 保存魔法编号
# (将编辑器保存的值以随机值替换)
$game_system.magic_number = $data_system.magic_number
# 写入各种游戏对像
Marshal.dump($game_system, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_screen, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
end
end
25.
#==============================================================================
# ■ Scene_Load
#------------------------------------------------------------------------------
# 处理读档画面的类。
#==============================================================================
class Scene_Load < Scene_File3
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
# 再生成临时对像
$game_temp = Game_Temp.new
# 选择存档时间最新的文件
$game_temp.last_file_index = 0
latest_time = Time.at(0)
for i in 0..3
filename = make_filename(i)
if FileTest.exist?(filename)
file = File.open(filename, "r")
if file.mtime > latest_time
latest_time = file.mtime
$game_temp.last_file_index = i
end
file.close
end
end
super("要载入哪个文件?")
end
#--------------------------------------------------------------------------
# ● 确定时的处理
#--------------------------------------------------------------------------
def on_decision(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 写入存档数据
file = File.open(filename, "rb")
read_save_data(file)
file.close
# 还原 BGM、BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# 刷新地图 (执行并行事件)
$game_map.update
# 切换到地图画面
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 取消时的处理
#--------------------------------------------------------------------------
def on_cancel
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 切换到标题画面
$scene = Scene_Menu_System.new(1)
end
#--------------------------------------------------------------------------
# ● 读取存档数据
# file : 读取用文件对像 (已经打开)
#--------------------------------------------------------------------------
def read_save_data(file)
# 读取描绘存档文件用的角色数据
characters = Marshal.load(file)
# 读取测量游戏时间用画面计数
Graphics.frame_count = Marshal.load(file)
# 读取各种游戏对像
$game_system = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_screen = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
# 魔法编号与保存时有差异的情况下
# (加入编辑器的编辑过的数据)
if $game_system.magic_number != $data_system.magic_number
# 重新装载地图
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
# 刷新同伴成员
$game_party.refresh
end
end
end |
|