赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1731 |
最后登录 | 2016-8-8 |
在线时间 | 23 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 23 小时
- 注册时间
- 2015-9-13
- 帖子
- 14
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
#重定义+ 不影响纯数值的加法运算
class String
alias old_plus +
def +(other)
self.old_plus(other.to_s)
end
end
#定义抓取menus资料夹中的图档
module Cache
def self.menu(filename)
load_bitmap("Graphics/Menus/", filename)
end
end
class Window_Gold_new < Window_Base
#--------------------------------------------------------------------------
# * 物件初始化
# x : 视窗X座标
# y : 视窗Y座标
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 120, WLH + 32)
refresh
end
#--------------------------------------------------------------------------
# * 更新内容显示
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.opacity = 0
draw_currency_value($game_party.gold, 4, 0, 80)
end
end
#显示游戏时间
class Window_Time < Window_Base
def initialize(x, y)
super(x, y, 200, WLH + 64)
self.opacity = 0
refresh
end
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, 120, 32, "游戏时间")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(16, 32, 120, 32, text, 2)
end
def update
super
if Graphics.frame_count / Graphics.frame_rate != @total_sec
refresh
end
end
end
#新定义command的创建
class Window_Command_new < Window_Selectable
#--------------------------------------------------------------------------
# * 宣告执行个体变数
#--------------------------------------------------------------------------
attr_reader :commands # 命令
#--------------------------------------------------------------------------
# * 物件初始化
# width : 视窗宽度
# commands : 命令字串(阵列)
# column_max : 纵栏数(如果大于等于2则横向分布命令条目)
# row_max : 总横行数(0:与命令条目数匹配)
# spacing : 条目水准分布时的间距大小
#--------------------------------------------------------------------------
def initialize(width, commands, column_max = 6, row_max = 1, spacing = 12)
if row_max == 0
row_max = (commands.size + column_max - 1) / column_max
end
super(100, 0, width, row_max * WLH + 32, spacing)
@commands = commands
@item_max = commands.size
@column_max = column_max
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * 更新内容显示
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * 绘制条目
# index : 条目编号
# enabled : 可用性标帜,如果为false则半透明化条目绘制。
#--------------------------------------------------------------------------
def draw_item(index, enabled = true)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, @commands[index])
end
end
#绘制整个菜单 包含动态背景图
class Scene_Menu < Scene_Base
def start
super
create_command_window
@gold_window = Window_Gold_new.new(424, 48)
@time_window = Window_Time.new(0,36)
@status_window = Window_MenuStatus.new(0, 140)
@menu_back = Plane.new
@menu_back.bitmap = Cache.menu("Background")
end
def pre_terminate
@status_window.close
@time_window.close
@gold_window.close
@command_window.close
begin
@status_window.update
@time_window.update
@gold_window.update
@command_window.update
@menu_back.ox += 1
Graphics.update
end until @status_window.openness == 0
end
def terminate
@command_window.dispose
@gold_window.dispose
@menu_back.dispose
@status_window.dispose
@time_window.dispose
end
def update
@menu_back.ox += 1
@command_window.update
@gold_window.update
@status_window.update
@time_window.update
if @command_window.active
update_command_selection
elsif @status_window.active
update_actor_selection
end
end
#--------------------------------------------------------------------------
# * 创建命令视窗
#--------------------------------------------------------------------------
def create_command_window
s1 = Vocab::status
s2 = Vocab::skill
s3 = Vocab::item
s4 = Vocab::equip
s5 = Vocab::save
s6 = "系统"
@command_window = Window_Command_new.new(444, [s1, s2, s3, s4, s5, s6])
@command_window.index = @menu_index
if $game_party.members.size == 0 # 如果无人在队
@command_window.draw_item(0, false) # 禁用[状态]
@command_window.draw_item(1, false) # 禁用[技能]
@command_window.draw_item(2, false) # 禁用[用品]
@command_window.draw_item(3, false) # 禁用[整备]
end
if $game_system.save_disabled # 如果禁止存档
@command_window.draw_item(4, false) # 禁用[存档]
end
@command_window.opacity = 0
end
#--------------------------------------------------------------------------
# * 更新指令选择输入资讯
#--------------------------------------------------------------------------
def update_command_selection
if Input.trigger?(Input::B)
Sound.play_cancel
$scene = Scene_Map.new
elsif Input.trigger?(Input::C)
if $game_party.members.size == 0 and @command_window.index < 4
Sound.play_buzzer
return
elsif $game_system.save_disabled and @command_window.index == 4
Sound.play_buzzer
return
end
Sound.play_decision
case @command_window.index
when 2 # 用品
$scene = Scene_Item.new
when 0,1,3 # 技能,整备,状态
start_actor_selection
when 4 # 存档
$scene = Scene_File.new(true, false, false)
when 5 # 结束游戏
$scene = Scene_End.new
end
end
end
#--------------------------------------------------------------------------
# * 开始接收主角选择指令输入资讯
#--------------------------------------------------------------------------
def start_actor_selection
@command_window.active = false
@status_window.active = true
if $game_party.last_actor_index < @status_window.item_max
@status_window.index = $game_party.last_actor_index
else
@status_window.index = 0
end
end
#--------------------------------------------------------------------------
# * 停止接收主角选择指令输入资讯
#--------------------------------------------------------------------------
def end_actor_selection
@command_window.active = true
@status_window.active = false
@status_window.index = -1
end
#--------------------------------------------------------------------------
# * 更新主角选择指令输入资讯
#--------------------------------------------------------------------------
def update_actor_selection
if Input.trigger?(Input::B)
Sound.play_cancel
end_actor_selection
elsif Input.trigger?(Input::C)
$game_party.last_actor_index = @status_window.index
Sound.play_decision
case @command_window.index
when 1 # 技能
$scene = Scene_Skill.new(@status_window.index)
when 3 # 整备
$scene = Scene_Equip.new(@status_window.index)
when 0 # 状态
$scene = Scene_Status.new(@status_window.index)
end
end
end
end
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# * 返回之前的画面
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Menu.new(2)
end
end
#以下几个因重新定义command位置 所以重定义取消时回到的指令位置
class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# * 返回之前的画面
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Menu.new(3)
end
end
class Scene_Status < Scene_Base
#--------------------------------------------------------------------------
# * 返回之前的画面
#--------------------------------------------------------------------------
def return_scene
$scene = Scene_Menu.new(0)
end
end
#覆写menustatus的位置&光标等设置
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * 物件初始化
# x : 视窗X座标
# y : 视窗Y座标
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 544,276)
refresh
self.active = false
self.index = -1
self.opacity = 0
end
#--------------------------------------------------------------------------
# * 更新内容显示
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.members.size
for actor in $game_party.members
if actor.index < 2
if actor.index % 2 == 0
actor_position_x = 0
else
actor_position_x = 250
end
actor_position_y = 0
else
if actor.index % 2 == 0
actor_position_x = 140
else
actor_position_x = 390
end
actor_position_y = 110
end
draw_halfbody(actor.face_name,actor.face_index,actor_position_x,actor_position_y)
if actor.index < 2
if actor.index % 2 == 0
actor_position_x = 0
else
actor_position_x = 250
end
actor_position_y = 0
x = 100 + actor_position_x
y = actor_position_y + 40 + WLH / 2
else
if actor.index % 2 == 0
actor_position_x = 0
else
actor_position_x = 250
end
actor_position_y = 100
x = 20 + actor_position_x
y = actor_position_y + 45 + WLH / 2
end
draw_actor_name(actor, x + 20, y - WLH + 5)
draw_actor_level(actor, x , y)
draw_actor_state(actor, x, y + WLH * 2)
draw_actor_hp(actor, x, y + WLH * 1)
draw_actor_mp(actor, x, y + WLH * 2)
end
end
def draw_halfbody(half_name,half_index, x, y)
half_name = half_name + "_" + half_index
bitmap = Cache.load_bitmap("Graphics/Battlers/", half_name)
rect = Rect.new(0, 0, 0, 0)
rect.x = 0
rect.y = 0
rect.width = 128
rect.height = 135
self.contents.blt(x,y,bitmap,rect)
bitmap.dispose
end
#--------------------------------------------------------------------------
# * 更新游标绘制
#--------------------------------------------------------------------------
def update_cursor
if @index < 0 # 无光标
self.cursor_rect.empty
elsif @index < @item_max # 正常状态
if @index < 2
if @index % 2 == 0
actor_position_x = 95
else
actor_position_x = 345
end
actor_position_y = 22+WLH/2
self.cursor_rect.set(actor_position_x-10, actor_position_y, 165, 96)
else
if @index % 2 == 0
actor_position_x = 22
else
actor_position_x = 272
end
actor_position_y = 128+WLH/2
self.cursor_rect.set(actor_position_x-10, actor_position_y, 165, 96)
end
elsif @index >= 100 # 使用者自身
self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)
else # 全体队员
if @item_max < 3
contents_height = 140
if @item_max == 1
contents_width = 177
else
contents_width = contents.width
end
self.cursor_rect.set(0, 0, contents_width, contents_height )
else
contents_height = 244
self.cursor_rect.set(0, 0, contents.width, contents_height)
end
end
end
end
|
|