Timer Mode
parent
761fe0f0e3
commit
c128924706
@ -0,0 +1,5 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"visualstudiotoolsforunity.vstuc"
|
||||
]
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to Unity",
|
||||
"type": "vstuc",
|
||||
"request": "attach"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
{
|
||||
"files.exclude": {
|
||||
"**/.DS_Store": true,
|
||||
"**/.git": true,
|
||||
"**/.gitmodules": true,
|
||||
"**/*.booproj": true,
|
||||
"**/*.pidb": true,
|
||||
"**/*.suo": true,
|
||||
"**/*.user": true,
|
||||
"**/*.userprefs": true,
|
||||
"**/*.unityproj": true,
|
||||
"**/*.dll": true,
|
||||
"**/*.exe": true,
|
||||
"**/*.pdf": true,
|
||||
"**/*.mid": true,
|
||||
"**/*.midi": true,
|
||||
"**/*.wav": true,
|
||||
"**/*.gif": true,
|
||||
"**/*.ico": true,
|
||||
"**/*.jpg": true,
|
||||
"**/*.jpeg": true,
|
||||
"**/*.png": true,
|
||||
"**/*.psd": true,
|
||||
"**/*.tga": true,
|
||||
"**/*.tif": true,
|
||||
"**/*.tiff": true,
|
||||
"**/*.3ds": true,
|
||||
"**/*.3DS": true,
|
||||
"**/*.fbx": true,
|
||||
"**/*.FBX": true,
|
||||
"**/*.lxo": true,
|
||||
"**/*.LXO": true,
|
||||
"**/*.ma": true,
|
||||
"**/*.MA": true,
|
||||
"**/*.obj": true,
|
||||
"**/*.OBJ": true,
|
||||
"**/*.asset": true,
|
||||
"**/*.cubemap": true,
|
||||
"**/*.flare": true,
|
||||
"**/*.mat": true,
|
||||
"**/*.meta": true,
|
||||
"**/*.prefab": true,
|
||||
"**/*.unity": true,
|
||||
"build/": true,
|
||||
"Build/": true,
|
||||
"Library/": true,
|
||||
"library/": true,
|
||||
"obj/": true,
|
||||
"Obj/": true,
|
||||
"ProjectSettings/": true,
|
||||
"temp/": true,
|
||||
"Temp/": true
|
||||
},
|
||||
"dotnet.defaultSolution": "PlumberUltimateAds.sln"
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a55ee4efaad27d948ba5f03fc6d7bc80
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed9b95dc6ed6d0647ad7f1a8f305385d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TimerManager : MonoBehaviour
|
||||
{
|
||||
private TimeSpan _remainingTime;
|
||||
private TimeSpan _initialTime;
|
||||
private bool _isTimerRunning;
|
||||
|
||||
// Event triggered when the timer starts
|
||||
public event Action TimerStarted;
|
||||
|
||||
// Event triggered when the timer ends
|
||||
//public event Action TimerEnded;
|
||||
public UnityEvent TimerEnded = new UnityEvent();
|
||||
public TextMeshProUGUI timer;
|
||||
public GameObject timerObj;
|
||||
public GameObject gameoverPanelObj;
|
||||
|
||||
//public Textmeshprougui timertext;
|
||||
private void Start()
|
||||
{
|
||||
if (GamePlayManager.isTimerLevel)
|
||||
{
|
||||
timerObj.SetActive(true);
|
||||
InitializeTimer(0, 2, 0);
|
||||
}
|
||||
|
||||
}
|
||||
// Initialize the timer with hours, minutes, and seconds
|
||||
public void InitializeTimer(int hours, int minutes, int seconds)
|
||||
{
|
||||
_initialTime = new TimeSpan(hours, minutes, seconds);
|
||||
_remainingTime = _initialTime;
|
||||
StartTimer();
|
||||
}
|
||||
|
||||
// Start the timer
|
||||
public void StartTimer()
|
||||
{
|
||||
if (_remainingTime.TotalSeconds > 0 && !_isTimerRunning)
|
||||
{
|
||||
_isTimerRunning = true;
|
||||
TimerStarted?.Invoke(); // Trigger the TimerStarted event
|
||||
}
|
||||
}
|
||||
|
||||
// Stop the timer
|
||||
public void StopTimer()
|
||||
{
|
||||
_isTimerRunning = false;
|
||||
}
|
||||
|
||||
// Reset the timer to its initial value
|
||||
public void ResetTimer()
|
||||
{
|
||||
StopTimer();
|
||||
_remainingTime = _initialTime;
|
||||
}
|
||||
|
||||
// Get the remaining time
|
||||
public TimeSpan GetRemainingTime()
|
||||
{
|
||||
return _remainingTime;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (_isTimerRunning)
|
||||
{
|
||||
// Subtract deltaTime from the remaining time
|
||||
_remainingTime = _remainingTime.Subtract(TimeSpan.FromSeconds(Time.deltaTime));
|
||||
timer.text = _remainingTime.ToString("m\\:ss");
|
||||
// If the timer has reached 0 or less, stop it
|
||||
if (_remainingTime.TotalSeconds <= 0)
|
||||
{
|
||||
_remainingTime = TimeSpan.Zero;
|
||||
_isTimerRunning = false;
|
||||
TimerEnded?.Invoke(); // Trigger the TimerEnded event
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b99d58f7291a21a40999b35d7b8ba8e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,2 +1,2 @@
|
||||
m_EditorVersion: 2022.3.17f1
|
||||
m_EditorVersionWithRevision: 2022.3.17f1 (4fc78088f837)
|
||||
m_EditorVersion: 2022.3.49f1
|
||||
m_EditorVersionWithRevision: 2022.3.49f1 (4dae1bb8668d)
|
||||
|
Loading…
Reference in New Issue