This repository has been archived on 2026-05-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
rpgskeleton/Scripts/RPG/Game_Timer.rb

58 lines
2.0 KiB
Ruby
Raw Normal View History

2014-04-23 21:59:50 -07:00
# -*- coding: utf-8 -*-
#==============================================================================
# ** Game_Timer
#------------------------------------------------------------------------------
# This class handles timers. Instances of this class are referenced by
# $game_timer.
#==============================================================================
class Game_Timer
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@count = 0
@working = false
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if @working && @count > 0
@count -= 1
on_expire if @count == 0
end
end
#--------------------------------------------------------------------------
# * Start
#--------------------------------------------------------------------------
def start(count)
@count = count
@working = true
end
#--------------------------------------------------------------------------
# * Stop
#--------------------------------------------------------------------------
def stop
@working = false
end
#--------------------------------------------------------------------------
# * Determine if Working
#--------------------------------------------------------------------------
def working?
@working
end
#--------------------------------------------------------------------------
# * Get Seconds
#--------------------------------------------------------------------------
def sec
@count / Graphics.frame_rate
end
#--------------------------------------------------------------------------
# * Processing When Timer Reaches 0
#--------------------------------------------------------------------------
def on_expire
BattleManager.abort
end
end