Added Main menu Changes to UI
Added Rules Menu Changes to UI Added Cutscenes to the rules scene Reorganised Files
This commit is contained in:
87
Assets/Scripts/Other Scripts/TimerHelper.cs
Normal file
87
Assets/Scripts/Other Scripts/TimerHelper.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public enum TimerDirection
|
||||
{
|
||||
TimerIncrement,
|
||||
TimerDecrement
|
||||
}
|
||||
|
||||
public class TimerHelper
|
||||
{
|
||||
private float _timerInterval;
|
||||
private float _timerMax;
|
||||
private float _timerTick;
|
||||
|
||||
private int _timesRun;
|
||||
|
||||
private bool _timerRepeats;
|
||||
|
||||
private TimerDirection _timerDirection;
|
||||
|
||||
public TimerHelper(float timeMax, bool repeating = true, TimerDirection direction = TimerDirection.TimerIncrement)
|
||||
{
|
||||
_timerMax = timeMax;
|
||||
_timerRepeats = repeating;
|
||||
_timerDirection = direction;
|
||||
|
||||
if (_timerDirection == TimerDirection.TimerDecrement)
|
||||
{
|
||||
_timerInterval = 0.0f;
|
||||
_timerTick = -_timerMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timerInterval = _timerMax;
|
||||
_timerTick = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public float CurrentTick
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Abs(_timerTick);
|
||||
}
|
||||
}
|
||||
|
||||
public int TimesRun
|
||||
{
|
||||
get
|
||||
{
|
||||
return _timesRun;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasTicked(float currentTimestamp)
|
||||
{
|
||||
if (_timerTick >= _timerInterval)
|
||||
{
|
||||
_timesRun++;
|
||||
if (_timerRepeats)
|
||||
{
|
||||
RestartTimer();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timerTick += currentTimestamp;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void RestartTimer()
|
||||
{
|
||||
if (_timerDirection == TimerDirection.TimerDecrement)
|
||||
{
|
||||
_timerTick = -_timerMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timerTick = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user