赞 | 2 |
VIP | 0 |
好人卡 | 0 |
积分 | 42 |
经验 | 13328 |
最后登录 | 2024-8-10 |
在线时间 | 258 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 4169
- 在线时间
- 258 小时
- 注册时间
- 2013-10-13
- 帖子
- 815
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
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, 120, 160, 128)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
alias old_refresh refresh
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
gold_1=$game_party.gold_1*(1+$game_map.date_minute*0.5)
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,
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
module Date
RATE = Graphics.frame_rate
#============================================================================
# ■ 2、时间系统的运作
#============================================================================
def Date.run_date_system
#Graphics.frame_count=80桢 折合成2秒/
#每40桢刷新一次,date_minute记数加1/游戏中1分=现实1秒
#Graphics.frame_count是画面更新次数的计数/1秒记数40次
#/记数1直到40,*40是计数一下子就40
#Graphics.frame_rate是1秒钟更新画面的次数
if Graphics.frame_count%Date::RATE == 0 #1分所用时间
$game_map.date_minute += 1
end
if $game_map.date_minute >= 60 #1小时所用时间
$game_map.date_minute = 0
$game_map.date_hour += 1
end
if $game_map.date_hour >= 24
$game_map.date_hour = 0
$game_map.date_day += 1
$game_map.date_week += 1
end
if $game_map.date_week >= 8
$game_map.date_week = 1
end
if $game_map.date_day >= 30
$game_map.date_day = 1
$game_map.date_month += 1
end
if $game_map.date_day > 90
$game_map.date_season += 1
end
if $game_map.date_season >= 5
$game_map.date_season = 1
end
if $game_map.date_month>=12
$game_map.date_month = 1
$game_map.date_year += 1
end
end
end
class Window_TimeDate < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 86)
self.contents = Bitmap.new(width - 32, height - 32)
# self.opacity = 0
refresh
end
def refresh
self.contents.clear
@fen_timedate = $game_map.date_minute # 此变量用于刷新 画面
# 描绘年
self.contents.font.size = 22
self.contents.font.color=text_color(2)
self.contents.draw_text(0, 0, 52, 52, "年")
self.contents.font.size = 22
self.contents.font.color=normal_color
self.contents.draw_text(32, 0, 52, 52, $game_map.date_year.to_s)
# 描绘 季节
if $game_map.date_season == 2
seasoncolor = Color.new(250,80,5)
wordj = "夏"
elsif $game_map.date_season == 4
seasoncolor = Color.new(150,170,250)
wordj = "冬"
elsif $game_map.date_season == 1
seasoncolor = Color.new(5,255,50)
wordj = "春"
else
seasoncolor = Color.new(228,208,38)
wordj = "秋"
end
self.contents.font.size = 22
self.contents.font.name = ["楷体_GB2312","黑体"]
self.contents.font.color = seasoncolor
self.contents.draw_text(64, 0, 52, 52, wordj)
#描绘月
self.contents.font.size = 22
self.contents.font.color=text_color(2)
self.contents.draw_text(96, 0, 52, 52, "月")
self.contents.font.size = 22
self.contents.font.color=text_color(2)
self.contents.draw_text(128, 0, 52, 52, $game_map.date_month.to_s)
# 描绘 号数
self.contents.font.size = 22
self.contents.font.color=text_color(2)
self.contents.draw_text(160, 0, 52, 52, "天")
self.contents.font.size = 22
self.contents.font.name = ["楷体_GB2312","黑体"]
self.contents.draw_text(192, 0, 84, 42,$game_map.date_day.to_s)
# 描绘 星期
case $game_map.date_week
when 1
self.contents.font.color = Color.new(170,170,170,255)
wordx = "月"
when 2
self.contents.font.color = Color.new(50,100,240,255)
wordx = "火"
when 3
self.contents.font.color = Color.new(227,59,13,255)
wordx = "水"
when 4
self.contents.font.color = Color.new(74,4,4,255)
wordx = "木"
when 5
self.contents.font.color = Color.new(228,231,10,255)
wordx = "金"
when 6
self.contents.font.color = Color.new(155,50,36,255)
wordx = "土"
when 7
self.contents.font.color = Color.new(55,244,246,255)
wordx = "日"
end
self.contents.font.size = 22
self.contents.font.name = ["楷体_GB2312","黑体"]
self.contents.draw_text(224, 22, 128, 32, wordx)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(224+24, 22, 128, 32, "曜日")
self.contents.font.size = 22
self.contents.font.color = Color.new(0,0,0,255)
# 描绘 时间
tt = sprintf("%2d点%2d分", $game_map.date_hour,$game_map.date_minute)
self.contents.draw_text(224, 0, 128, 32, tt)
end #end refresh
def update
super
# 刷新窗口
if @fen_timedate != $game_map.date_minute
refresh
end
end
end
class Game_Map
attr_accessor :date_minute
attr_accessor :date_hour
attr_accessor :date_day
attr_accessor :date_week
attr_accessor :date_season
attr_accessor :date_month
attr_accessor :date_year
# attr_reader :every_month_days
attr_accessor :date_system_window_on_or_off
attr_accessor :weather1
attr_accessor :weather2
attr_accessor :waittime
def initialize
@date_minute = 50
@date_hour = 7
@date_day = 1
@date_week = 5
@date_season = 4
@date_month = 1
# @data_month = 0
@date_year = 0
# @data_year = 0
@date_system_window_on_or_off = true
@weather1 = [false,0,0]
@weather2 = [false,0,0]
@waittime = [0,0]
end
end
class Scene_Map
# 主处理
alias main_old main
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
@tt = Window_TimeDate.new
if $game_map.date_system_window_on_or_off == false
@tt.visible = false
end
main_old
@b_window.dispose
@gold_window.dispose
@confirm_window.dispose
@yes_no_window.dispose
@spriteset.dispose
@gold_1_window.dispose
@tt.dispose
end
# 更新
alias update_old update
def update
if $game_map.date_system_window_on_or_off == false
@tt.visible = false
else
@tt.visible = true
end
#----------------------
# Date.change_screen_tone
Date.run_date_system
# Date.rand_weather_type
#----------------------
@tt.update
update_old
@gold_1_window.refresh
@b_window.update
if @b_window.active
b_update
return
end
if @yes_no_window.active
confirm_update
return
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=Scene_Map.new
end
if Input.trigger?(Input::C)
case @b_window.index
when 0#存钱
if @yes_no_window.index==0 #确定
if $game_party.gold>10000
$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)
end
else #放弃
$scene=Bank_Scene.new(@b_window.index)
end
when 1#取钱
if @yes_no_window.index==0 #确定
if $game_party.gold_1>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)
end
else
$scene=Bank_Scene.new(@b_window.index)
end
when 2#取消
$scene=Bank_Scene.new(@b_window.index)
end
end
end
end
上面的脚本本意是建立一个yinhang系统,yinhang的存钱随时间的变化而增加。我在地图上放了加钱的事件。我有几个问题:
1,上面的脚本身上的钱不增加了,为什么?
2,要达到随时间加钱,脚本应该怎么改?
3,一按B键就暴错,为什么?
|
|