TapTapManager.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using TapIabHelper;
  3. using UnityEngine;
  4. [DisallowMultipleComponent]
  5. public class TapTapManager : MonoBehaviour
  6. {
  7. private void Start()
  8. {
  9. TapTapAPI.OnStart(new TapTapAPI.Callback(this.LicenseCallback));
  10. UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
  11. }
  12. private void OnApplicationQuit()
  13. {
  14. TapTapAPI.OnDestroy();
  15. }
  16. private void LicenseCallback(int code)
  17. {
  18. code = 0;
  19. TapTapManager.LicenseState = code;
  20. switch (code)
  21. {
  22. case 0:
  23. this._licenseState = "授权状态:\n LICENSE_OK";
  24. return;
  25. case 1:
  26. this._licenseState = "授权状态:\n LICENSE_NOT_INSTALL_TAPTAP";
  27. return;
  28. case 2:
  29. this._licenseState = "授权状态:\n LICENSE_NO";
  30. return;
  31. case 3:
  32. this._licenseState = "授权状态:\n LICENSE_NOT_SERVICE_UNAVAILABLE";
  33. return;
  34. default:
  35. this._licenseState = "授权状态:\n 未知状态";
  36. return;
  37. }
  38. }
  39. public static void OpenTapTap()
  40. {
  41. TapTapAPI.OpenTapTap();
  42. }
  43. public static void DownloadTapTap()
  44. {
  45. TapTapAPI.DownloadTapTap();
  46. }
  47. public static void QuitGame()
  48. {
  49. TapTapAPI.OnDestroy();
  50. Application.Quit();
  51. }
  52. public static int LicenseState = 3;
  53. private string _licenseState;
  54. }