You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

111 regels
2.6 KiB

  1. using System;
  2. using SUISS.Core;
  3. using SUISS.Core.Utilities;
  4. using SUISS.Storage;
  5. using SUISSEngine;
  6. using UnityEngine;
  7. public sealed class GameInterface : Singleton<GameInterface>
  8. {
  9. public void RegisterOnApplicationPauseHandler(Action<bool> action)
  10. {
  11. if (this._listener == null)
  12. {
  13. GameObject gameObject = new GameObject();
  14. gameObject.name = "OnApplicationPauseListener";
  15. this._listener = gameObject.AddComponent<ApplicationPauseListener>();
  16. UnityEngine.Object.DontDestroyOnLoad(gameObject);
  17. }
  18. this._listener.applicationPauseEvent += delegate(bool x)
  19. {
  20. action(x);
  21. };
  22. }
  23. public long GetUserId()
  24. {
  25. if (SingletonMonobehaviour<CIGWebService>.IsAvailable)
  26. {
  27. return SingletonMonobehaviour<CIGWebService>.Instance.UserId;
  28. }
  29. Storage storage = Storage.Get(StorageLifecycle.Player);
  30. return storage.Root.GetLong("userId", -1L);
  31. }
  32. public string GetUserKey()
  33. {
  34. if (SingletonMonobehaviour<CIGWebService>.IsAvailable)
  35. {
  36. return SingletonMonobehaviour<CIGWebService>.Instance.UserKey;
  37. }
  38. Storage storage = Storage.Get(StorageLifecycle.Player);
  39. return storage.Root.GetString("userKey", string.Empty);
  40. }
  41. public bool IsWebServiceAvailable()
  42. {
  43. return SingletonMonobehaviour<CIGWebService>.IsAvailable;
  44. }
  45. public void RegisterPullRequestCompletedHandler(Action action)
  46. {
  47. if (SingletonMonobehaviour<CIGWebService>.IsAvailable)
  48. {
  49. SingletonMonobehaviour<CIGWebService>.Instance.PullRequestCompleted += delegate()
  50. {
  51. action();
  52. };
  53. }
  54. else
  55. {
  56. UnityEngine.Debug.LogWarning("GameInterface.RegisterPullRequestCompletedHandler: no CIGWebService instance available.");
  57. }
  58. }
  59. public void ForcePullRequest()
  60. {
  61. if (SingletonMonobehaviour<CIGWebService>.IsAvailable)
  62. {
  63. SingletonMonobehaviour<CIGWebService>.Instance.ForcePullRequest();
  64. }
  65. else
  66. {
  67. UnityEngine.Debug.LogWarning("GameInterface.ForcePullRequest: no CIGWebService instance available.");
  68. }
  69. }
  70. public void MuteAudio()
  71. {
  72. if (SingletonMonobehaviour<CIGAudioManager>.IsAvailable)
  73. {
  74. SingletonMonobehaviour<CIGAudioManager>.Instance.Mute();
  75. }
  76. }
  77. public void RestoreAudio()
  78. {
  79. if (SingletonMonobehaviour<CIGAudioManager>.IsAvailable)
  80. {
  81. SingletonMonobehaviour<CIGAudioManager>.Instance.Unmute();
  82. }
  83. }
  84. public long GetTotalMinutesPlayed()
  85. {
  86. if (SingletonMonobehaviour<CIGGameState>.IsAvailable)
  87. {
  88. return SingletonMonobehaviour<CIGGameState>.Instance.TotalMinutesPlayed;
  89. }
  90. return 0L;
  91. }
  92. public bool ShowAdInfoPopup()
  93. {
  94. return false;
  95. }
  96. private ApplicationPauseListener _listener;
  97. }