Skip to content
Snippets Groups Projects
Commit 387af850 authored by RAMIRES Antoine's avatar RAMIRES Antoine
Browse files

No commit message

No commit message
parent 3ea43ddf
Branches
No related tags found
No related merge requests found
fileFormatVersion: 2
guid: 4b82b051e41a4e2459dc05bdfc30bbbe
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -5,30 +5,26 @@ using UnityEngine;
public class ScenarioMamie : MonoBehaviour
{
Timer timer1;
Timer timer1 = new Timer(2);
public TextMeshPro text1;
public TextMeshPro text_timer1 ;
// Start is called before the first frame update
void Start()
{
timer1 = new Timer(2);
timer1.
}
// Update is called once per frame
void Update()
{
if (Chrono.chrono > 10)
if (Chrono.chrono > 5)
{
timer1 = new Timer(2);
text1.SetText("Aider la mamie à prendre son repas");
text_timer1 = timer1.getText();
timer1.StartTimer();
print("" + timer1.GetCurrentTime());
timer1.UpdateTimer();
text_timer1.SetText(timer1.ConvertTime(timer1.GetCurrentTime()));
}
}
}
using UnityEngine;
using TMPro;
public class Timer : MonoBehaviour
public class Timer
{
public int timer_minutes;
private TextMeshPro text;
private int timer_minutes;
//private TextMeshPro text;
private float current_time;
private float start_time;
private bool isStoped;
......@@ -13,36 +13,35 @@ public class Timer : MonoBehaviour
public Timer(int timer)
{
timer_minutes = timer;
}
// Start is called before the first frame update
void Start()
{
text = GetComponent<TextMeshPro>();
isStoped = true;
isReset = true;
current_time = timer_minutes * 60;
text.SetText(ConvertTime(current_time));
//text.SetText(ConvertTime(current_time));
}
// Start is called before the first frame update
void Start(){}
// Update is called once per frame
void Update()
void Update(){}
public void UpdateTimer()
{
if (!isStoped)
{
current_time = (timer_minutes * 60) - (Time.time - start_time);
if (current_time > 0)
{
text.SetText(ConvertTime(current_time));
//text.SetText(ConvertTime(current_time));
}
else
{
text.SetText("00:00");
//text.SetText("00:00");
isStoped = true;
}
}
}
private string ConvertTime(float t)
public string ConvertTime(float t)
{
string minutes = Mathf.Floor(t / 60).ToString("00");
string seconds = Mathf.Floor(t % 60).ToString("00");
......@@ -59,17 +58,14 @@ public class Timer : MonoBehaviour
return isReset;
}
public bool StartTimer()
public void StartTimer()
{
bool started = false;
if (isStoped && isReset)
{
isStoped = false;
isReset = false;
start_time = Time.time;
started = true;
}
return started;
}
public void ResetTimer()
......@@ -77,12 +73,12 @@ public class Timer : MonoBehaviour
isStoped = true;
isReset = true;
current_time = timer_minutes * 60;
text.SetText(ConvertTime(current_time));
//text.SetText(ConvertTime(current_time));
}
public void StopTimer()
{
isStopped = true;
isStoped = true;
}
public int getTimer()
......@@ -90,8 +86,8 @@ public class Timer : MonoBehaviour
return timer_minutes;
}
public TextMeshPro getText()
public float GetCurrentTime()
{
return text;
return current_time;
}
}
{
"m_SettingKeys": [
"VR Device Disabled",
"VR Device User Alert",
"VR Device Transitioned Groups"
"VR Device User Alert"
],
"m_SettingValues": [
"True",
"True",
"Standalone"
"False",
"False"
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment