pros-plan-for-elves/Scripts/_.27.rb

101 lines
No EOL
3.8 KiB
Ruby
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#==============================================================================
# タイマーの一時停止と再開
# 
# 作動中のタイマーの一時停止と再開を実装します。
#
# 起動方法
#  以下の3種類をご用意しましたので、目的に合わせて、
#  スクリプトに記述してください。
#   一時停止
#    timer_pause
#   再開
#    timer_resume
#   自動切換え
#    timer_auto_switch
#
# 利用規約
#  連絡不要
#  商用可
# 改造可
# 再配布可(無改造の場合はクレジットを消さないでください)
# アダルト可
#  利用された際、クレジットはあると喜びます 
# GYM
# http://gymaterials.jp/
#
#==============================================================================
# ■ Game_Timer
#------------------------------------------------------------------------------
#  タイマーを扱うクラスです。このクラスのインスタンスは $game_timer で参照さ
# れます。
#==============================================================================
class Game_Timer
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias timer_pause_initialize initialize
def initialize
timer_pause_initialize
@pause = false
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
if @working && @count > 0
@count -= 1 unless @pause
on_expire if @count == 0
end
end
#--------------------------------------------------------------------------
# ● 一時停止
#--------------------------------------------------------------------------
def pause
@pause = true
end
#--------------------------------------------------------------------------
# ● 一時停止中かどうかの判定
#--------------------------------------------------------------------------
def pause?
@pause
end
#--------------------------------------------------------------------------
# ● 再開
#--------------------------------------------------------------------------
def resume
@pause = false
end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● タイマーの一時停止
#--------------------------------------------------------------------------
def timer_pause
$game_timer.pause if $game_timer.working?
end
#--------------------------------------------------------------------------
# ● タイマーの再開
#--------------------------------------------------------------------------
def timer_resume
$game_timer.resume if $game_timer.working?
end
#--------------------------------------------------------------------------
# ● タイマーの一時停止と再開の自動切換え
#  多用するとややこしい事になるかも。
#--------------------------------------------------------------------------
def timer_auto_switch
if $game_timer.pause?
timer_resume
else
timer_pause
end
end
end