Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public abstract class AbstractTime : MyMono
- {
- #region variables
- public static AbstractTime Instance { get; private set; }
- #region fields
- private float greenTime,
- yellowTime,
- orangeTime,
- redTime;
- public float time = 10;
- #endregion
- #region props
- protected float GreenTime
- {
- get { return this.greenTime; }
- set { this.greenTime = value; }
- }
- protected float YellowTime
- {
- get { return this.yellowTime; }
- set { this.yellowTime = value; }
- }
- protected float OrangeTime
- {
- get { return this.orangeTime; }
- set { this.orangeTime = value; }
- }
- protected float RedTime
- {
- get { return this.redTime; }
- set { this.redTime = value; }
- }
- #endregion
- #endregion
- #region methods
- protected override void Awake()
- {
- base.Awake();
- Instance = this;
- }
- protected virtual void Start()
- {
- this.UpdateTiming();
- this.SetupTimingColours();
- this.ChangeColor(Color.green);
- }
- protected virtual void Update()
- {
- if (GameIntroScript.HasIntroBeenShown && !GameScript<>.Instance.GameOver)
- {
- this.UpdateTiming();
- }
- }
- protected virtual void UpdateTiming()
- {
- GetComponent<Text>().text = ((int)time).ToString();
- }
- protected void ChangeColor(Color color)
- {
- GetComponent<Text>().color = color;
- }
- protected virtual void SetupTimingColours()
- {
- }
- public void AddTime(float seconds)
- {
- this.time += seconds;
- this.UpdateTiming();
- }
- #endregion
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement