Advertisement
Guest User

Untitled

a guest
Feb 12th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. public abstract class AbstractTime : MyMono
  6. {
  7.     #region variables
  8.     public static AbstractTime Instance { get; private set; }
  9.  
  10.     #region fields
  11.     private float greenTime,
  12.                   yellowTime,
  13.                   orangeTime,
  14.                   redTime;
  15.  
  16.     public float time = 10;
  17.     #endregion
  18.  
  19.     #region props
  20.     protected float GreenTime
  21.     {
  22.         get { return this.greenTime; }
  23.         set { this.greenTime = value; }
  24.     }
  25.  
  26.     protected float YellowTime
  27.     {
  28.         get { return this.yellowTime; }
  29.         set { this.yellowTime = value; }
  30.     }
  31.  
  32.     protected float OrangeTime
  33.     {
  34.         get { return this.orangeTime; }
  35.         set { this.orangeTime = value; }
  36.     }
  37.  
  38.     protected float RedTime
  39.     {
  40.         get { return this.redTime; }
  41.         set { this.redTime = value; }
  42.     }
  43.     #endregion
  44.     #endregion
  45.  
  46.     #region methods
  47.     protected override void Awake()
  48.     {
  49.         base.Awake();
  50.         Instance = this;
  51.     }
  52.  
  53.     protected virtual void Start()
  54.     {
  55.         this.UpdateTiming();
  56.         this.SetupTimingColours();
  57.         this.ChangeColor(Color.green);
  58.     }
  59.  
  60.     protected virtual void Update()
  61.     {
  62.         if (GameIntroScript.HasIntroBeenShown && !GameScript<>.Instance.GameOver)
  63.         {
  64.             this.UpdateTiming();
  65.         }        
  66.     }
  67.  
  68.     protected virtual void UpdateTiming()
  69.     {
  70.         GetComponent<Text>().text = ((int)time).ToString();
  71.     }
  72.  
  73.     protected void ChangeColor(Color color)
  74.     {
  75.         GetComponent<Text>().color = color;
  76.     }
  77.  
  78.     protected virtual void SetupTimingColours()
  79.     {
  80.     }
  81.  
  82.     public void AddTime(float seconds)
  83.     {
  84.         this.time += seconds;
  85.         this.UpdateTiming();
  86.     }
  87.     #endregion
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement