Project1
标题:
昼夜变幻 ——讲解+工程
[打印本页]
作者:
571341163
时间:
2012-5-25 22:08
标题:
昼夜变幻 ——讲解+工程
本帖最后由 Kimu 于 2012-5-29 23:56 编辑
在【Game_Temp】中,找到如下地方添加语句。
#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
# 在没有存档的情况下,处理临时数据的类。这个类的实例请参考
# $game_temp 。
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :map_bgm # 地图画面 BGM (战斗时记忆用)
attr_accessor :message_text # 信息文章
attr_accessor :message_proc # 信息 返回调用 (Proc)
attr_accessor :choice_start # 选择项 开始行
attr_accessor :choice_max # 选择项 项目数
attr_accessor :choice_cancel_type # 选择项 取消的情况
attr_accessor :choice_proc # 选择项 返回调用 (Proc)
attr_accessor :num_input_start # 输入数值 开始行
attr_accessor :num_input_variable_id # 输入数值 变量 ID
attr_accessor :num_input_digits_max # 输入数值 位数
attr_accessor :message_window_showing # 显示信息窗口
attr_accessor :common_event_id # 公共事件 ID
attr_accessor :in_battle # 战斗中的标志
attr_accessor :battle_calling # 调用战斗的标志
attr_accessor :battle_troop_id # 战斗 队伍 ID
attr_accessor :battle_can_escape # 战斗中 允许逃跑 ID
attr_accessor :battle_can_lose # 战斗中 允许失败 ID
attr_accessor :battle_proc # 战斗 返回调用 (Proc)
attr_accessor :battle_turn # 战斗 回合数
attr_accessor :battle_event_flags # 战斗 事件执行执行完毕的标志
attr_accessor :battle_abort # 战斗 中断标志
attr_accessor :battle_main_phase # 战斗 状态标志
attr_accessor :battleback_name # 战斗背景 文件名
attr_accessor :forcing_battler # 强制行动的战斗者
attr_accessor :shop_calling # 调用商店的标志
attr_accessor :shop_goods # 商店 商品列表
attr_accessor :name_calling # 输入名称 调用标志
attr_accessor :name_actor_id # 输入名称 角色 ID
attr_accessor :name_max_char # 输入名称 最大字数
attr_accessor :menu_calling # 菜单 调用标志
attr_accessor :menu_beep # 菜单 SE 演奏标志
attr_accessor :save_calling # 存档 调用标志
attr_accessor :debug_calling # 调试 调用标志
attr_accessor :player_transferring # 主角 场所移动标志
attr_accessor :player_new_map_id # 主角 移动目标地图 ID
attr_accessor :player_new_x # 主角 移动目标 X 坐标
attr_accessor :player_new_y # 主角 移动目标 Y 坐标
attr_accessor :player_new_direction # 主角 移动目标 朝向
attr_accessor :transition_processing # 过渡处理中标志
attr_accessor :transition_name # 过渡 文件名
attr_accessor :gameover # 游戏结束标志
attr_accessor :to_title # 返回标题画面标志
attr_accessor :last_file_index # 最后存档的文件编号
attr_accessor :debug_top_row # 调试画面 保存状态用
attr_accessor :debug_index # 调试画面 保存状态用
#--------------------------------------------------
attr_accessor :zhou_ye # 昼夜
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
@map_bgm = nil
@message_text = nil
@message_proc = nil
@choice_start = 99
@choice_max = 0
@choice_cancel_type = 0
@choice_proc = nil
@num_input_start = 99
@num_input_variable_id = 0
@num_input_digits_max = 0
@message_window_showing = false
@common_event_id = 0
@in_battle = false
@battle_calling = false
@battle_troop_id = 0
@battle_can_escape = false
@battle_can_lose = false
@battle_proc = nil
@battle_turn = 0
@battle_event_flags = {}
@battle_abort = false
@battle_main_phase = false
@battleback_name = ''
@forcing_battler = nil
@shop_calling = false
@shop_id = 0
@name_calling = false
@name_actor_id = 0
@name_max_char = 0
@menu_calling = false
@menu_beep = false
@save_calling = false
@debug_calling = false
@player_transferring = false
@player_new_map_id = 0
@player_new_x = 0
@player_new_y = 0
@player_new_direction = 0
@transition_processing = false
@transition_name = ""
@gameover = false
@to_title = false
@last_file_index = 0
@debug_top_row = 0
@debug_index = 0
#--------------------------------------------------
@zhou_ye = 0
#--------------------------------------------------
end
end
在【Game_Party】中,找到如下地方添加语句。
#--------------------------------------------------------------------------
# ● 减少金钱
# n : 金额
#--------------------------------------------------------------------------
def lose_gold(n)
# 调用数值逆转 gain_gold
gain_gold(-n)
end
#--------------------------------------------------------------------------
# ● 增加步数
#--------------------------------------------------------------------------
def increase_steps
@steps = [@steps + 1, 9999999].min
#----------------------------------------
$game_temp.zhou_ye += 1
#-----------------------------------------
end
#--------------------------------------------------------------------------
# ● 获取物品的所持数
# item_id : 物品 ID
#--------------------------------------------------------------------------
def item_number(item_id)
# 如果 hash 个数数值不存在就返回 0
return @items.include?(item_id) ? @items[item_id] : 0
end
在【Scene_Map】中,找到如下地方添加语句。
# 遇敌计数为 0 且、且遇敌列表不为空的情况下
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
# 不是在事件执行中或者禁止遇敌中
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
# 确定队伍
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
# 队伍有效的话
if $data_troops[troop_id] != nil
# 设置调用战斗标志
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troop_id
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
end
end
end
#---------------------------------------------------
#昼夜系统
if $game_map.tileset_name != "土之洞窟" #除掉这个地图外
zhouye_bianhuan
end
#----------------------------------------------------------
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 不是在事件执行中或菜单禁止中
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
# 设置菜单调用标志以及 SE 演奏
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
# 调试模式为 ON 并且按下 F9 键的情况下
if $DEBUG and Input.press?(Input::F9)
# 设置调用调试标志
$game_temp.debug_calling = true
end
# 不在主角移动中的情况下
unless $game_player.moving?
# 执行各种画面的调用
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
#--------------------------------------------------------------------------
# ● 昼夜变幻
#--------------------------------------------------------------------------
def zhouye_bianhuan
if $game_temp.zhou_ye >= 100 and $game_temp.zhou_ye < 110
$game_screen.start_tone_change(Tone.new(-10,-10,-10,0), 10)
elsif $game_temp.zhou_ye >= 110 and $game_temp.zhou_ye < 115
$game_screen.start_tone_change(Tone.new(-20,-20,-20,0), 10)
elsif $game_temp.zhou_ye >= 115 and $game_temp.zhou_ye < 120
$game_screen.start_tone_change(Tone.new(-40,-40,-40,0), 10)
elsif $game_temp.zhou_ye >= 120 and $game_temp.zhou_ye < 125
$game_screen.start_tone_change(Tone.new(-50,-50,-50,0), 10)
elsif $game_temp.zhou_ye >= 125 and $game_temp.zhou_ye < 150
$game_screen.start_tone_change(Tone.new(-60,-60,-60,0), 10)
elsif $game_temp.zhou_ye >= 150 and $game_temp.zhou_ye < 155
$game_screen.start_tone_change(Tone.new(-90,-90,-90,0), 10)
elsif $game_temp.zhou_ye >= 155 and $game_temp.zhou_ye < 160
$game_screen.start_tone_change(Tone.new(-100,-100,-100,0), 10)
elsif $game_temp.zhou_ye >= 160 and $game_temp.zhou_ye < 165
$game_screen.start_tone_change(Tone.new(-110,-110,-110,0), 10)
elsif $game_temp.zhou_ye >= 165 and $game_temp.zhou_ye < 195
$game_screen.start_tone_change(Tone.new(-120,-120,-120,0), 10)
elsif $game_temp.zhou_ye >= 195 and $game_temp.zhou_ye < 200
$game_screen.start_tone_change(Tone.new(-140,-140,-140,0), 10)
elsif $game_temp.zhou_ye >= 200 and $game_temp.zhou_ye < 315
$game_screen.start_tone_change(Tone.new(-150,-150,-150,0), 10)
elsif $game_temp.zhou_ye >= 315 and $game_temp.zhou_ye < 320
$game_screen.start_tone_change(Tone.new(-140,-140,-140,0), 10)
elsif $game_temp.zhou_ye >= 320 and $game_temp.zhou_ye < 350
$game_screen.start_tone_change(Tone.new(-120,-120,-120,0), 10)
elsif $game_temp.zhou_ye >= 350 and $game_temp.zhou_ye < 355
$game_screen.start_tone_change(Tone.new(-110,-110,-110,0), 10)
elsif $game_temp.zhou_ye >= 355 and $game_temp.zhou_ye < 360
$game_screen.start_tone_change(Tone.new(-100,-100,-100,0), 10)
elsif $game_temp.zhou_ye >= 360 and $game_temp.zhou_ye < 365
$game_screen.start_tone_change(Tone.new(-90,-90,-90,0), 10)
elsif $game_temp.zhou_ye >= 365 and $game_temp.zhou_ye < 400
$game_screen.start_tone_change(Tone.new(-60,-60,-60,0), 10)
elsif $game_temp.zhou_ye >= 400 and $game_temp.zhou_ye < 405
$game_screen.start_tone_change(Tone.new(-50,-50,-50,0), 10)
elsif $game_temp.zhou_ye >= 405 and $game_temp.zhou_ye < 410
$game_screen.start_tone_change(Tone.new(-40,-40,-40,0), 10)
elsif $game_temp.zhou_ye >= 410 and $game_temp.zhou_ye < 415
$game_screen.start_tone_change(Tone.new(-20,-20,-20,0), 10)
elsif $game_temp.zhou_ye >= 415 and $game_temp.zhou_ye < 420
$game_screen.start_tone_change(Tone.new(-10,-10,-10,0), 10)
elsif $game_temp.zhou_ye >= 420
$game_screen.start_tone_change(Tone.new(0,0,0,0), 10)
$game_temp.zhou_ye = 0
else
$game_screen.start_tone_change(Tone.new(0,0,0,0), 10)
end
end
#--------------------------------------------------------------------------
# ● 调用战斗
#--------------------------------------------------------------------------
def call_battle
# 清除战斗调用标志
$game_temp.battle_calling = false
# 清除菜单调用标志
$game_temp.menu_calling = false
$game_temp.menu_beep = false
# 生成遇敌计数
$game_player.make_encounter_count
# 记忆地图 BGM 、停止 BGM
$game_temp.map_bgm = $game_system.playing_bgm
$game_system.bgm_stop
# 演奏战斗开始 SE
$game_system.se_play($data_system.battle_start_se)
# 演奏战斗 BGM
$game_system.bgm_play($game_system.battle_bgm)
# 矫正主角姿势
$game_player.straighten
# 切换到战斗画面
$scene = Scene_Battle.new
end
在【Scene_Battle 1】中,找到如下地方添加语句。
class Scene_Battle
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
zhouye #昼夜
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# 初始化战斗用的各种暂时数据
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
# 初始化战斗用事件解释器
添加 Scene_Battle 5
内容:
#==============================================================================
# ■ Scene_Battle (分割定义 5)
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 昼夜
#--------------------------------------------------------------------------
def zhouye
$game_temp.zhou_ye = 0 if $game_temp.zhou_ye < 100
$game_temp.zhou_ye = 200 if $game_temp.zhou_ye >= 200 and $game_temp.zhou_ye < 315
end
end
复制代码
2.jpg
(127.69 KB, 下载次数: 6)
下载附件
保存到相册
2012-5-25 22:07 上传
1.jpg
(154.01 KB, 下载次数: 5)
下载附件
保存到相册
2012-5-25 22:07 上传
昼夜变幻.zip
(195.48 KB, 下载次数: 1004)
2012-5-25 22:08 上传
点击文件名下载附件
昼夜变幻
作者:
雁行疏
时间:
2012-5-25 22:57
为嘛我觉得用个开关,然后自动执行的事件来调画面色调比较简单。。。。
作者:
天使喝可乐
时间:
2012-5-25 23:16
吐槽“:zhou_ye”……
另外 是否需要昼夜,最好按地图名判断,写脚本里改比较麻烦。
作者:
kangxi0109
时间:
2012-5-26 00:20
晚上的室内需要和白天一样亮,白天的山洞要和夜晚一样暗...还要调用有关灯光的开关、某些需要在某个时段更新的变量、某些只有白天/晚上才会出现的剧情...用步数来积累昼夜交替,如果用跑步的话?(于是速度越快时间流逝越快,爱因斯坦的相对论被推翻了@_@b)...
作者:
chd114
时间:
2012-5-26 16:31
用事件会怎样?
作者:
LOVE丶莫颜
时间:
2012-5-27 09:25
用事件不是更简单吗?....
还能随意调换....
但是也是支持LZ了。
作者:
夏侬
时间:
2012-5-27 09:53
用脚本控制适合契合大型的游戏
作者:
mynameisurer
时间:
2012-5-27 10:48
这确实是个好东西啊,要是设定上能再简化些就好了
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1