PlatformTapManager.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using ET;
  2. using TapTap.Bootstrap;
  3. using TapTap.Common;
  4. using TapTap.TapDB;
  5. //using Plugins.AntiAddictionUIKit;
  6. namespace GFGGame
  7. {
  8. public class PlatformTapManager
  9. {
  10. public static void InitSDK()
  11. {
  12. if (!PlatformManager.IsTaptap)
  13. {
  14. return;
  15. }
  16. var config = new TapConfig.Builder()
  17. .ClientID("K7bDyPGYlVx2AAtk6q")
  18. .ClientToken("fjwWBtibB4Dj3UjyRQxK2tZ3f8fGNgg14tcRW38D")
  19. .ServerURL("https://k7bdypgy.cloud.tds1.tapapis.cn")
  20. .RegionType(RegionType.CN)
  21. .TapDBConfig(true, "tap", null, true)
  22. .ConfigBuilder();
  23. TapBootstrap.Init(config);
  24. string gameIdentifier = "游戏的 Client ID";
  25. // 是否启用时长限制功能
  26. bool useTimeLimit = true;
  27. // 是否启用消费限制功能
  28. bool usePaymentLimit = true;
  29. // 是否显示切换账号按钮
  30. bool showSwitchAccount = false;
  31. //AntiAddictionUIKit.Init(gameIdentifier, useTimeLimit, usePaymentLimit, showSwitchAccount,
  32. // (antiAddictionCallbackData) => {
  33. // int code = antiAddictionCallbackData.code;
  34. // MsgExtraParams extras = antiAddictionCallbackData.extras;
  35. // // 根据 code 不同提示玩家不同信息,详见下面的说明
  36. // if (code == 500)
  37. // {
  38. // // 开始计时
  39. // AntiAddictionUIKit.EnterGame();
  40. // Debug.Log("玩家登录后判断当前玩家可以进行游戏");
  41. // }
  42. // },
  43. // (exception) => {
  44. // // 处理异常
  45. //}
  46. //);
  47. }
  48. public static void OnEnterGame()
  49. {
  50. if(!PlatformManager.IsTaptap)
  51. {
  52. return;
  53. }
  54. var serverInfosComponent = GameGlobal.zoneScene.GetComponent<ServerInfosComponent>();
  55. var accountInfoComponent = GameGlobal.zoneScene.GetComponent<AccountInfoComponent>();
  56. var roleInfosComponent = GameGlobal.zoneScene.GetComponent<RoleInfosComponent>();
  57. var currentRole = roleInfosComponent.GetCurrentRole();
  58. TapDB.SetUser(accountInfoComponent.Account);
  59. TapDB.SetName(currentRole.Name);
  60. TapDB.SetLevel(RoleDataManager.lvl);
  61. TapDB.SetServer(serverInfosComponent.GetCurrentServerInfo().ServerName);
  62. }
  63. public static void OnQuitGame()
  64. {
  65. if (!PlatformManager.IsTaptap)
  66. {
  67. return;
  68. }
  69. TapDB.ClearUser();
  70. }
  71. }
  72. }