Commit ae654dd7 authored by Jonas's avatar Jonas

Duplicate of Showcountdown removed

parent 6de62506
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ShowCountdown : MonoBehaviour
{
public TextMeshProUGUI delayTextField;
private float _timer = 0;
// called zero
void Awake()
{
Debug.Log("Awake");
}
// called first
void OnEnable()
{
Debug.Log("OnEnable called");
SceneManager.sceneLoaded += OnSceneLoaded;
}
//
// called second
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
// Debug.Log("OnSceneLoaded: " + scene.name);
// Debug.Log(mode);
delayTextField.text = "funcs";
_timer = 0;
StartCoroutine(UpdateDelayText());
}
IEnumerator UpdateDelayText() //TODO : Anpassen an Runden Countdown/Zwischen Runden
{
float sec = 1;
float framerate = (sec / Time.unscaledDeltaTime);
int dt = GameManager.instance.data.DelayTime-1;
WaitForSecondsRealtime waiting = new WaitForSecondsRealtime(0.06f);
for (int i = 0; i < GameManager.instance.data.DelayTime; i++)
{
delayTextField.text = dt + "";
for (float frame = 0; frame < 1; frame += 1 / framerate)
{
delayTextField.fontSize -= Mathf.Lerp(0, 1, frame) * 10;
//print(delayTextField.fontSize);
yield return waiting;
}
delayTextField.fontSize = 300;
dt--;
if (dt < 1)
{
delayTextField.text = "Go!";
continue;
}
}
/*int dt = GameManager.instance.data.DelayTime - 1;
for (int i = 0; i < GameManager.instance.data.DelayTime; i++)
{
if(dt-i < 1)
continue;
delayTextField.text = (dt- i) + "";
for (int w = 0; w < 50; w++)
{
delayTextField.fontSize -= 2f;
yield return new WaitForSecondsRealtime(0.01f );
}
delayTextField.fontSize = 300;
}
delayTextField.text = "GO!";*/
}
void LoadDelayTimer()
{
delayTextField.text = "funktioniert";
}
// called third
void Start()
{
Debug.Log("Start");
}
// called when the game is terminated
void OnDisable()
{
Debug.Log("OnDisable");
SceneManager.sceneLoaded -= OnSceneLoaded;
}
}
fileFormatVersion: 2
guid: a2a46c9de6bb9b94a918138671cc1332
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment