|
- using System;
- using SUISS.Core;
- using SUISS.Core.Utilities;
- using SUISS.Storage;
- using SUISSEngine;
- using UnityEngine;
-
- public sealed class GameInterface : Singleton<GameInterface>
- {
-
- public void RegisterOnApplicationPauseHandler(Action<bool> action)
- {
- if (this._listener == null)
- {
- GameObject gameObject = new GameObject();
- gameObject.name = "OnApplicationPauseListener";
- this._listener = gameObject.AddComponent<ApplicationPauseListener>();
- UnityEngine.Object.DontDestroyOnLoad(gameObject);
- }
- this._listener.applicationPauseEvent += delegate(bool x)
- {
- action(x);
- };
- }
-
- public long GetUserId()
- {
- if (SingletonMonobehaviour<CIGWebService>.IsAvailable)
- {
- return SingletonMonobehaviour<CIGWebService>.Instance.UserId;
- }
- Storage storage = Storage.Get(StorageLifecycle.Player);
- return storage.Root.GetLong("userId", -1L);
- }
-
- public string GetUserKey()
- {
- if (SingletonMonobehaviour<CIGWebService>.IsAvailable)
- {
- return SingletonMonobehaviour<CIGWebService>.Instance.UserKey;
- }
- Storage storage = Storage.Get(StorageLifecycle.Player);
- return storage.Root.GetString("userKey", string.Empty);
- }
-
- public bool IsWebServiceAvailable()
- {
- return SingletonMonobehaviour<CIGWebService>.IsAvailable;
- }
-
- public void RegisterPullRequestCompletedHandler(Action action)
- {
- if (SingletonMonobehaviour<CIGWebService>.IsAvailable)
- {
- SingletonMonobehaviour<CIGWebService>.Instance.PullRequestCompleted += delegate()
- {
- action();
- };
- }
- else
- {
- UnityEngine.Debug.LogWarning("GameInterface.RegisterPullRequestCompletedHandler: no CIGWebService instance available.");
- }
- }
-
- public void ForcePullRequest()
- {
- if (SingletonMonobehaviour<CIGWebService>.IsAvailable)
- {
- SingletonMonobehaviour<CIGWebService>.Instance.ForcePullRequest();
- }
- else
- {
- UnityEngine.Debug.LogWarning("GameInterface.ForcePullRequest: no CIGWebService instance available.");
- }
- }
-
- public void MuteAudio()
- {
- if (SingletonMonobehaviour<CIGAudioManager>.IsAvailable)
- {
- SingletonMonobehaviour<CIGAudioManager>.Instance.Mute();
- }
- }
-
- public void RestoreAudio()
- {
- if (SingletonMonobehaviour<CIGAudioManager>.IsAvailable)
- {
- SingletonMonobehaviour<CIGAudioManager>.Instance.Unmute();
- }
- }
-
- public long GetTotalMinutesPlayed()
- {
- if (SingletonMonobehaviour<CIGGameState>.IsAvailable)
- {
- return SingletonMonobehaviour<CIGGameState>.Instance.TotalMinutesPlayed;
- }
- return 0L;
- }
-
- public bool ShowAdInfoPopup()
- {
- return false;
- }
-
-
- private ApplicationPauseListener _listener;
- }
|