Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- public class Timmer : MonoBehaviour {
- public Text Tempo;
- public float tiempo = 0.0f;
- // Update is called once per frame
- void Update () {
- tiempo -= Time.deltaTime;
- Tempo.text = "Tiempo:" + " " + tiempo.ToString ("f0");
- }
- }
- public class Timmer : MonoBehaviour
- {
- public Text Tempo;
- public float Tiempo = 0.0f;
- public bool DebeAumentar = false;
- void Update()
- {
- if (DebeAumentar)
- Tiempo += Time.deltaTime;
- // Primero se comprueba que sea falso el tener que aumentar.
- else
- {
- if (Tiempo <= 0.0f) // Comprueba si es menor o igual a cero.
- { DebeAumentar = true; } // Para volver true a este.
- else
- { Tiempo -= Time.deltaTime; } // De lo contrario, sigue bajando.
- }
- if (Tiempo <= 30.0f)
- { Tempo.color = Color.Red; } // Comprueba para cambiar el color del text.
- else { Tempo.color = Color.Green; } // Vuelve a verde cuando aumente...
- Tempo.text = "Tiempo:" + " " + Tiempo.ToString ("f0");
- }
- }
- public class Timmer : MonoBehaviour
- {
- public Text Tempo;
- public float Tiempo = 0.0f;
- public bool DebeAumentar = false;
- void Update()
- {
- // Se comprueba si debe aumentar el valor primero...
- DebeAumentar = (Tiempo <= 0.0f) ? true : false;
- // Luego se efectua el aumento.
- if (DebeAumentar) Tiempo += Time.deltaTime;
- else Tiempo -= Time.deltaTime;
- // Se asigna el color dependiendo del tiempo restante.
- Tempo.color = (Tiempo <= 30.0f) ? Color.Red : Color.Green;
- Tempo.text = "Tiempo:" + " " + Tiempo.ToString ("f0");
- }
- }
- Var = (Condición) ? (Si cumple la condición, se asigna este valor) : (De lo contrario, este);
- public class Countdown: MonoBehaviour {
- public int duration = 60;
- public int timeRemaining;
- public bool isCountingDown = false;
- public void Begin()
- {
- if (!isCountingDown) {
- isCountingDown = true;
- timeRemaining = duration;
- Invoke ( "_tick", 1f );
- }
- }
- private _tick() {
- timeRemaining--;
- if(timeRemaining > 0) {
- Invoke ( "_tick", 1f );
- } else {
- isCountingDown = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement