bakershoemaker

KeepTrackOfTime.cs

Apr 5th, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. public class KeepTrackOfTime : Monobehavior
  2. {
  3. private float seconds;
  4. private float hours;
  5. private float minutes;
  6.  
  7. private float minutesInSeconds;
  8. private float hoursInSeconds;
  9. private float secondsInSeconds; //don't really need this.
  10.  
  11. private float totalSeconds;
  12. private float startTimeInSeconds;
  13.  
  14. void Start()
  15. {
  16. //----------------------------------------
  17. //USER INPUTS
  18. //----------------------------------------
  19. hours = 2;
  20. minutes = 10;
  21. seconds = 29;
  22.  
  23. //----------------------------------------
  24. //DO CONVERSIONS -
  25. //----------------------------------------
  26. if (hours > 0){hoursInSeconds = 3600 * hours;}else { hoursInSeconds = 0; }
  27. if (minutes > 0) { minutesInSeconds = 60 * minutes; } else { minutesInSeconds = 0; }
  28. secondsInSeconds = seconds;
  29.  
  30. //Add up the total seconds
  31. totalSeconds = hoursInSeconds + minutesInSeconds + secondsInSeconds;
  32. Debug.Log("----------------------------------------");
  33. }
  34.  
  35. void Update()
  36. {
  37. //Count down the timer---- This will be the textfield for timer.
  38. totalSeconds -= 1 * Time.deltaTime;
  39. Debug.Log("----------------------------------------------");
  40. Debug.Log("Current time: " + totalSeconds.ToString("0"));
  41. }
  42.  
  43. }
Add Comment
Please, Sign In to add comment