NTime.cs 866 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using UnityEngine;
  3. public class NTime
  4. {
  5. public static float time
  6. {
  7. get
  8. {
  9. return NTime.m_fNow;
  10. }
  11. }
  12. public static float realtimeSinceStartup
  13. {
  14. get
  15. {
  16. return NTime.m_fNow;
  17. }
  18. }
  19. public static float deltaTime
  20. {
  21. get
  22. {
  23. return NTime.m_fDelta;
  24. }
  25. }
  26. public static void Reset()
  27. {
  28. NTime.m_fDelay = (NTime.m_fNow = (NTime.m_fBack = (NTime.m_fDelta = 0f)));
  29. }
  30. public static void SetDelay(float f_nDelay)
  31. {
  32. NTime.m_fDelay = f_nDelay;
  33. }
  34. public static void UpdateNowTime(float f_nNow)
  35. {
  36. NTime.m_fNow = f_nNow;
  37. NTime.m_fDelta = NTime.m_fNow - NTime.m_fBack;
  38. if (NTime.m_fDelta < 0f)
  39. {
  40. Debug.LogError("時間がマイナスです。");
  41. }
  42. NTime.m_fBack = NTime.m_fNow;
  43. }
  44. private static float m_fDelay;
  45. private static float m_fNow;
  46. private static float m_fBack;
  47. private static float m_fDelta;
  48. }