赞 | 1 |
VIP | 0 |
好人卡 | 0 |
积分 | 92 |
经验 | 0 |
最后登录 | 2024-10-20 |
在线时间 | 466 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 9163
- 在线时间
- 466 小时
- 注册时间
- 2015-5-8
- 帖子
- 866
|
8楼
楼主 |
发表于 2022-5-14 07:01:32
|
只看该作者
本帖最后由 taeckle 于 2022-5-15 03:02 编辑
下面公布答案(总共192行,$game_variables[1]需首先是个一维数组):
#==============================================================================
class Scene_Skisele < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(id,limit=[])
@id = id
@limit = limit
@skill_lv = 0
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@screen = Spriteset_Map.new
#技能选择窗口上面部分
@skill_list_upper = Skill_list_upper.new
@skill_list_upper.draw_text
@skill_list_upper.active = true
@skill_list_upper.visible = true
@skill_list_upper.x = 137
@skill_list_upper.y = 90
@skill_list_upper.opacity = 120
#技能选择窗口
@skill_list_window = Window_Skill_List.new(@id,@limit)
@skill_list_window.active = true
@skill_list_window.visible = true
@skill_list_window.opacity = 120
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@skill_list_upper.dispose
@skill_list_window.dispose
@screen.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@screen.update
@skill_list_window.update
if Input.trigger?(Input::B)
@skill_list_upper.active = false
@skill_list_upper.visible = false
@skill_list_window.active = false
@skill_list_window.visible = false
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
return
end
if Input.trigger?(Input::C)
@skill_list_upper.active = false
@skill_list_upper.visible = false
@skill_list_window.active = false
@skill_list_window.visible = false
for i in 0...$game_party.actors.size
$game_party.actors.learn_skill(@skill_list_window.learn_content[@skill_list_window.index])
end
p "恭喜全队都学会了技能 #{$data_skills[@skill_list_window.learn_content[@skill_list_window.index]].name}"
$scene = Scene_Map.new
return
end
end
end
#================================文字提示===================================
class Skill_list_upper < Window_Base
def initialize
super(0, 0, 366, 72)
self.contents = Bitmap.new(width - 32, height - 32)
end
def draw_text
self.contents.clear
self.contents.font.size = 23
self.contents.font.color = system_color
self.contents.draw_text(40, 5, self.width - 32, 32, "现在想学习哪个技能呢?")
end
end
#==============================================================================
class Window_Skill_List < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(id,limit)
super(137, 50, 366, 360)
@id = id
@limit = limit
@column_max = 1
@item_max = @id.size
if @item_max>=8
self.height = 288
else
self.height = @item_max*32+32
end
self.y = 162
self.opacity = 160
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def skill
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 给对象调用参数用的
#--------------------------------------------------------------------------
def learn_content
return @id
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data=[]
for i in @id
skill_id = $data_skills
@data.push(skill_id)
end
@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]
self.contents.font.color = normal_color
if @limit[index] != nil
lv = @limit[index]
else
lv = 10
end
x = 2
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(skill.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
case skill.name.size
when 0..18
self.contents.font.size = 20
when 19..24
self.contents.font.size = 16
when 25..30
self.contents.font.size = 12
end
self.contents.draw_text(x + 28, y, 212, 32, skill.name, 0)
end
end |
|