Timer Mode

dev-hazim
Ali Sharoz 1 month ago
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"
}

@ -214,6 +214,7 @@ public class _2dxFX_GrayScale : MonoBehaviour
CanvasImage.material = ForceMaterial;
}
}
Start();
}
}

@ -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:

@ -37,7 +37,7 @@ AnimatorStateMachine:
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 20000}
m_Position: {x: 0, y: 0, z: 0}
m_Position: {x: 110, y: -50, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -19,9 +19,21 @@ public class GameManager
{
PlayerPrefs.SetInt("currentLevelNo", value);
}
}
public static int CurrentLevelGroupIndex
}
public static int CurrentLevelNo_Timer
{
get
{
return PlayerPrefs.GetInt("currentLevelNo_Timer", 1);
}
set
{
PlayerPrefs.SetInt("currentLevelNo_Timer", value);
}
}
public static int CurrentLevelGroupIndex
{
get
{

File diff suppressed because it is too large Load Diff

@ -16,6 +16,7 @@ using MS;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
@ -67,7 +68,7 @@ public class HomeScene : MonoBehaviour
public Popup[] popups;
public static HomeScene instance;
public UnityEvent OnPlayButtonPressed=new UnityEvent();
private List<int> ReverseNumbers = new List<int>{4, 6, 10, 12, 16, 18,22,24,28,30,34,36,40,42,46,48};
private void Start()
{
@ -113,7 +114,15 @@ public class HomeScene : MonoBehaviour
public void ShowDetailLevel(LevelGroupButton lb)
{
int completedLevel = lb.levelGroup.CompletedLevel;
int completedLevel = 0;
if(!GamePlayManager.isTimerLevel)
{
completedLevel = lb.levelGroup.CompletedLevel;
}
else
{
completedLevel = lb.levelGroup.CompletedLevel_Timer;
}
LD_TitleLbl.text = lb.levelGroup.LevelGroupName.ToUpper();
LD_LevelCompletdLbl.text = completedLevel + " / " + lb.levelGroup.TotalLevel;
// LD_AwardGoldImage.SetActive(completedLevel >= lb.levelGroup.TotalLevel);
@ -281,6 +290,7 @@ public class HomeScene : MonoBehaviour
public void PlayButton()
{
OnPlayButtonPressed.Invoke();
Sound.instance.PlayButton();
}

@ -17,63 +17,87 @@ using UnityEngine;
[CreateAssetMenu(fileName = "LevelGroup", menuName = "PipeOut/Create LevelGroup", order = 1)]
public class LevelGroup : ScriptableObject
{
public string LevelGroupName = "Easy";
public int TotalLevel = 50;
public string ResourcesFolderPath = "Easy\\";
public Color bgColor;
public int StarXPReward = 1;
public int NoOfHint = 4;
public Sprite LevelDetailBG;
public Sprite LevelHeaderBG;
public int CompletedLevel
{
get
{
return PlayerPrefs.GetInt("Completed_" + LevelGroupName.ToUpper(), 0);
}
set
{
PlayerPrefs.SetInt("Completed_" + LevelGroupName.ToUpper(), value);
}
}
public float AverageCompletedTime
{
get
{
return PlayerPrefs.GetFloat("AverageTime_" + LevelGroupName.ToUpper(), 0f);
}
set
{
PlayerPrefs.SetFloat("AverageTime_" + LevelGroupName.ToUpper(), value);
}
}
public string AverageCompletedTimeString
{
get
{
int num = Mathf.FloorToInt(AverageCompletedTime);
return (num / 60).ToString("00") + " : " + (num % 60).ToString("00");
}
}
public void SetLevelCompleted(int LevelNo, float TimeToComplete)
{
if (CompletedLevel <= LevelNo)
{
CompletedLevel = LevelNo;
}
float averageCompletedTime = AverageCompletedTime;
averageCompletedTime = Mathf.Abs(averageCompletedTime * (float)(CompletedLevel - 1) + TimeToComplete);
averageCompletedTime = (AverageCompletedTime = averageCompletedTime / (float)CompletedLevel);
}
public string LevelGroupName = "Easy";
public int TotalLevel = 50;
public string ResourcesFolderPath = "Easy\\";
public Color bgColor;
public int StarXPReward = 1;
public int NoOfHint = 4;
public Sprite LevelDetailBG;
public Sprite LevelHeaderBG;
public int CompletedLevel
{
get
{
return PlayerPrefs.GetInt("Completed_" + LevelGroupName.ToUpper(), 0);
}
set
{
PlayerPrefs.SetInt("Completed_" + LevelGroupName.ToUpper(), value);
}
}
public int CompletedLevel_Timer
{
get
{
return PlayerPrefs.GetInt("Completed_" + LevelGroupName.ToUpper() + "_Timer", 0);
}
set
{
PlayerPrefs.SetInt("Completed_" + LevelGroupName.ToUpper() + "_Timer", value);
}
}
public float AverageCompletedTime
{
get
{
return PlayerPrefs.GetFloat("AverageTime_" + LevelGroupName.ToUpper(), 0f);
}
set
{
PlayerPrefs.SetFloat("AverageTime_" + LevelGroupName.ToUpper(), value);
}
}
public string AverageCompletedTimeString
{
get
{
int num = Mathf.FloorToInt(AverageCompletedTime);
return (num / 60).ToString("00") + " : " + (num % 60).ToString("00");
}
}
public void SetLevelCompleted(int LevelNo, float TimeToComplete)
{
if (!GamePlayManager.isTimerLevel)
{
if (CompletedLevel <= LevelNo)
{
CompletedLevel = LevelNo;
}
float averageCompletedTime = AverageCompletedTime;
averageCompletedTime = Mathf.Abs(averageCompletedTime * (float)(CompletedLevel - 1) + TimeToComplete);
averageCompletedTime = (AverageCompletedTime = averageCompletedTime / (float)CompletedLevel);
}
else
{
if (CompletedLevel_Timer <= LevelNo)
{
CompletedLevel_Timer = LevelNo;
}
float averageCompletedTime = AverageCompletedTime;
averageCompletedTime = Mathf.Abs(averageCompletedTime * (float)(CompletedLevel_Timer - 1) + TimeToComplete);
averageCompletedTime = (AverageCompletedTime = averageCompletedTime / (float)CompletedLevel_Timer);
}
}
}

@ -20,35 +20,50 @@ using UnityEngine.UI;
[ExecuteInEditMode]
public class LevelGroupButton : MonoBehaviour
{
public LevelGroup levelGroup;
public TMP_Text TitleLbl;
public TMP_Text LevelCompletdLbl;
public GameObject AwardGoldImage;
private void Start()
{
UpdateUI();
GetComponent<Button>().onClick.AddListener(delegate
{
HomeScene.instance.ShowDetailLevel(this);
HomeScene.instance.PlayButton();
GameObject.FindWithTag("LevelGroupPopup").GetComponent<Popup>().Close();
});
}
private void Update()
{
}
[ContextMenu("UpdateUI")]
public void UpdateUI()
{
base.name = levelGroup.LevelGroupName;
TitleLbl.text = base.name.ToUpper();
LevelCompletdLbl.text = levelGroup.CompletedLevel + " / " + levelGroup.TotalLevel;
AwardGoldImage.GetComponent<_2dxFX_GrayScale>().enabled = !(levelGroup.CompletedLevel >= levelGroup.TotalLevel);
}
public LevelGroup levelGroup;
public TMP_Text TitleLbl;
public TMP_Text LevelCompletdLbl;
public GameObject AwardGoldImage;
public void Start()
{
UpdateUI();
GetComponent<Button>().onClick.AddListener(delegate
{
HomeScene.instance.ShowDetailLevel(this);
HomeScene.instance.PlayButton();
GameObject.FindWithTag("LevelGroupPopup").GetComponent<Popup>().Close();
});
HomeScene.instance.OnPlayButtonPressed.AddListener(() =>
{
UpdateUI();
});
}
private void Update()
{
}
[ContextMenu("UpdateUI")]
public void UpdateUI()
{
base.name = levelGroup.LevelGroupName;
TitleLbl.text = base.name.ToUpper();
if (!GamePlayManager.isTimerLevel)
{
LevelCompletdLbl.text = levelGroup.CompletedLevel + " / " + levelGroup.TotalLevel;
AwardGoldImage.GetComponent<_2dxFX_GrayScale>().enabled = !(levelGroup.CompletedLevel >= levelGroup.TotalLevel);
}
else
{
LevelCompletdLbl.text = levelGroup.CompletedLevel_Timer + " / " + levelGroup.TotalLevel;
AwardGoldImage.GetComponent<_2dxFX_GrayScale>().enabled = !(levelGroup.CompletedLevel_Timer >= levelGroup.TotalLevel);
}
}
}

@ -19,37 +19,47 @@ using UnityEngine.UI;
[ExecuteInEditMode]
public class LevelGroupState : MonoBehaviour
{
public LevelGroup levelGroup;
[Header("Show Detail")]
[SerializeField]
private TMP_Text TitleLbl;
[SerializeField]
private TMP_Text LevelCompletdLbl;
[SerializeField]
private TMP_Text AvarageTimeLbl;
[SerializeField]
private GameObject AwardGoldImage;
private void Start()
{
UpdateUI();
}
private void Update()
{
}
[ContextMenu("UpdateUI")]
public void UpdateUI()
{
base.name = levelGroup.LevelGroupName;
TitleLbl.text = base.name.ToUpper();
LevelCompletdLbl.text = levelGroup.CompletedLevel + " / " + levelGroup.TotalLevel;
AvarageTimeLbl.text = levelGroup.AverageCompletedTimeString;
AwardGoldImage.GetComponent<_2dxFX_GrayScale>().enabled = !(levelGroup.CompletedLevel >= levelGroup.TotalLevel);
}
public LevelGroup levelGroup;
[Header("Show Detail")]
[SerializeField]
private TMP_Text TitleLbl;
[SerializeField]
private TMP_Text LevelCompletdLbl;
[SerializeField]
private TMP_Text AvarageTimeLbl;
[SerializeField]
private GameObject AwardGoldImage;
private void Start()
{
UpdateUI();
}
private void Update()
{
}
[ContextMenu("UpdateUI")]
public void UpdateUI()
{
base.name = levelGroup.LevelGroupName;
TitleLbl.text = base.name.ToUpper();
if (!GamePlayManager.isTimerLevel)
{
LevelCompletdLbl.text = levelGroup.CompletedLevel + " / " + levelGroup.TotalLevel;
AwardGoldImage.GetComponent<_2dxFX_GrayScale>().enabled = !(levelGroup.CompletedLevel >= levelGroup.TotalLevel);
}
else
{
LevelCompletdLbl.text = levelGroup.CompletedLevel_Timer + " / " + levelGroup.TotalLevel;
AwardGoldImage.GetComponent<_2dxFX_GrayScale>().enabled = !(levelGroup.CompletedLevel_Timer >= levelGroup.TotalLevel);
}
AvarageTimeLbl.text = levelGroup.AverageCompletedTimeString;
}
}

@ -38,6 +38,11 @@ namespace MS
public UnityEvent onClose;
public UnityEvent onOpen;
public GameObject ChooseModePanel;
public void isTimerSetter(bool isTimer)
{
GamePlayManager.isTimerLevel = isTimer;
}
private void Start()
{

@ -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…
Cancel
Save