LoyalGameSDK.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace LoyalSoftSDK
  5. {
  6. public enum Platform
  7. {
  8. Default,
  9. Android,
  10. IOS
  11. }
  12. public abstract class LoyalGameSDK
  13. {
  14. //这个改成Default可以在uinity简单看下效果,导出的时候一定要改回Android
  15. public static Platform platform = Platform.Default;
  16. private static LoyalGameSDK instance;
  17. public static LoyalGameSDK Instance
  18. {
  19. get
  20. {
  21. if (instance == null)
  22. {
  23. if (GlobalConfig.is_SandBox == true)
  24. {
  25. platform = Platform.Default;
  26. }
  27. else
  28. {
  29. if ( (GlobalConfig.netType == eNetType.Online || GlobalConfig.netType == eNetType.Online_dev)) // 正式网络
  30. {
  31. if (Application.platform == RuntimePlatform.Android)
  32. {
  33. platform = Platform.Android;
  34. }
  35. else if (Application.platform == RuntimePlatform.WindowsEditor)
  36. {
  37. platform = Platform.Default;
  38. }
  39. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  40. {
  41. platform = Platform.IOS;
  42. }
  43. }
  44. }
  45. if (platform == Platform.Default)
  46. {
  47. instance = new LoyalGameSDKDefault();
  48. }
  49. else if (platform == Platform.Android)
  50. {
  51. instance = new LoyalGameSDKAndroid();
  52. }
  53. else if (platform == Platform.IOS)
  54. {
  55. instance = new LoyalGameSDKIOS();
  56. }
  57. else
  58. {
  59. Debug.LogError("应用平台未知!");
  60. }
  61. }
  62. return instance;
  63. }
  64. }
  65. //
  66. public string plantName = "";
  67. public const string appid = "102";
  68. //SDK消息回调
  69. public delegate void CallBackHandler(LoyalGameCallbackData data);
  70. public CallBackHandler onSDKCallBack;
  71. /// <summary>
  72. /// 平台初始化
  73. /// </summary>
  74. public abstract void Init();
  75. /// <summary>
  76. /// 登录
  77. /// </summary>
  78. public abstract void Login(bool autoLogin);
  79. /// <summary>
  80. /// 登录
  81. /// 用于腾讯应用宝,QQ登录,plant="QQ";微信登录,plant="WX"
  82. /// </summary>
  83. /// <param name="plant">用于腾讯应用宝,QQ登录,plant="QQ";微信登录,plant="WX"</param>
  84. public abstract void Login(string plant);
  85. /// <summary>
  86. /// 登出
  87. /// </summary>
  88. public abstract void Logout();
  89. /// <summary>
  90. /// 上传用户游戏数据
  91. /// </summary>
  92. public abstract void SubmitGameData(LoyalGameExtraData extraData);
  93. /// <summary>
  94. /// 退出游戏(IOS没有)
  95. /// </summary>
  96. public abstract void ExitGame(LoyalGameExtraData extraData);
  97. /// <summary>
  98. /// 支付
  99. /// </summary>
  100. public abstract void Pay(LoyalGamePayData payData);
  101. /// <summary>
  102. /// 打开网页
  103. /// </summary>
  104. /// <param name="url"></param>
  105. public abstract void OpenUrl(string url);
  106. /// <summary>
  107. /// 扩展项,考虑特殊平台的必要方法实现
  108. /// </summary>
  109. /// <param name="funcName"></param>
  110. /// <param name="param"></param>
  111. public abstract void CallOther(string funcName, params object[] param);
  112. /// <summary>
  113. /// 游戏重新启动(Android端)
  114. /// </summary>
  115. public abstract void Restar();
  116. /// <summary>
  117. /// Android端退出游戏
  118. /// </summary>
  119. public abstract void FoceExit();
  120. }
  121. }