赞 | 2 |
VIP | 0 |
好人卡 | 0 |
积分 | 42 |
经验 | 13328 |
最后登录 | 2024-8-10 |
在线时间 | 258 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 4169
- 在线时间
- 258 小时
- 注册时间
- 2013-10-13
- 帖子
- 815
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
#召唤方式:$scene=Bank_Scene.new
class Bank_Window < Window_Selectable
def initialize
@operate=["存钱","取钱","取消"]
super(320-120,240,240,64+64)
@[email protected]
@column_max=3
@index=0
self.contents=Bitmap.new(self.width-32,self.height-32)
refresh
end
def refresh
for i in [email protected]
self.contents.draw_text(i*64,0,64,32,@operate[i])
end
# self.contents.draw_text(300,0,64,32,$data_system.words.gold)
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+16)
y = @index / @column_max * 32 - self.oy
# 更新光标矩形
self.cursor_rect.set(x, y, cursor_width, 32)
end
end
class Window_Gold < Window_Base
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 128)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
self.contents.draw_text(4,32,160-32,32,"身上的钱的数目")
end
end
class Window_Gold_1 < Window_Base #yinhang窗口
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
super(0, 240, 160, 128)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
cx = contents.text_size($data_system.words.gold).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold_1.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
self.contents.draw_text(4,32,160-32,32,"yinhang的钱的数目")
end
end
class Game_Party
attr_reader :gold_1 #yinhang的钱的数目
alias old_initialize initialize
def initialize
old_initialize
@gold_1=0
end
def gain_1_gold(n)
@gold_1=gold_1+n
end
def lose_1_gold(n)
@gold_1=gold_1-n
end
end
class Bank_Scene
def initialize(bank_index=0)
@bank_index=bank_index
end
def main
@b_window=Bank_Window.new
@b_window.index=@bank_index
@gold_1_window=Window_Gold_1.new #yinhang的钱的窗口
# 生成活动块
@spriteset = Spriteset_Map.new
@gold_window=Window_Gold.new
@confirm_window=Window_Base.new(120, 88, 400, 64)
@confirm_window.visible=false
@yes_no_window = Window_Command.new(100, ["确定", "放弃"])
@yes_no_window.x=120
@yes_no_window.y=88+64
@yes_no_window.visible=false
@yes_no_window.active=false
Graphics.transition
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@b_window.dispose
@gold_window.dispose
@confirm_window.dispose
@yes_no_window.dispose
@spriteset.dispose
@gold_1_window.dispose
end
def update
@b_window.update
if @b_window.active
b_update
return
end
if @yes_no_window.active
confirm_update
end
end
def b_update
if Input.trigger?(Input::B)
$scene=Scene_Map.new
end
if Input.trigger?(Input::C)
if @b_window.index==0 #存钱
@b_window.active=false
@yes_no_window.active=true
elsif @b_window.index==1#取钱
@b_window.active=false
@yes_no_window.active=true
elsif @b_window.index==2#取消
$scene=Scene_Map.new
end
end
end
def confirm_update
@bank_index=@b_window.index
@yes_no_window.active=true
@yes_no_window.visible=true
@yes_no_window.update
@confirm_window.visible=true
@confirm_window.contents=Bitmap.new(@confirm_window.width-32,
@confirm_window.height-32)
if @b_window.index==0
@confirm_window.contents.draw_text(0,0,300,32,"想存钱?")
elsif @b_window.index==1
@confirm_window.contents.draw_text(0,0,300,32,"想取钱?")
end
if Input.trigger?(Input::B)
$scene=Bank_Scene.new(@b_window.index)
end
if @yes_no_window.index==0
if Input.trigger?(Input::C)
if @b_window.index==0 #存钱
if $game_party.gold>10000
if @yes_no_window.index==0 #确定
$game_party.lose_gold(10000)
@gold_window.refresh
$game_party.gain_1_gold(10000)
@gold_1_window.refresh
$scene=Bank_Scene.new(@b_window.index)
elsif @yes_no_window.index==1#放弃
p 1
$scene=Bank_Scene.new(@b_window.index)
end
end
elsif @b_window.index==1#取钱
if $game_party.gold_1>0
if @yes_no_window.index==0 #确定
$game_party.lose_1_gold(10000)
@gold_1_window.refresh
$game_party.gain_gold(10000)
@gold_window.refresh
$scene=Bank_Scene.new(@b_window.index)
elsif @yes_no_window.index==1#放弃
$scene=Bank_Scene.new(@b_window.index)
end
else
return
end
elsif @b_window.index==2
$scene=Bank_Scene.new(@b_window.index)
end
end
else
return
end
end
end
第一次写脚本,写的比较粗糙,特别是P1下面的$scene=Bank_Scene.new(@b_window.index)运行不了,点“确定”可以执行,为什么点“放弃”就执行不了?
在地图建立一个事件,运用脚本$scene=Bank_Scene.new,点回车,再点确定,可以运行,但是点放弃,就执行不了,不知道为什么?
|
|