QuickSDKInterfaceUnity.mm 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // PlatformInterface_Unity.m
  3. // Unity-iPhone
  4. //
  5. // Created by niko on 14-5-12.
  6. //
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "QuickSDKInterfaceUnity.h"
  10. #import "QuickSDK_ios.h"
  11. #import <SMPCQuickSDK/SMPCQuickSDK.h>
  12. #if defined(__cplusplus)
  13. extern "C"{
  14. #endif
  15. void quicksdk_nativeSetListener(const char *gameObjectName)
  16. {
  17. [[QuickSDK_ios shareInstance] setListener:[NSString stringWithUTF8String:gameObjectName]];
  18. }
  19. void quicksdk_nativeLogin()
  20. {
  21. [[QuickSDK_ios shareInstance] login];
  22. }
  23. void quicksdk_nativeLogout()
  24. {
  25. [[QuickSDK_ios shareInstance] logout];
  26. }
  27. void quicksdk_nativePay(const char *goodsId, const char *goodsName, const char *goodsDesc, const char *quantifier, const char *cpOrderId, const char *callbackUrl, const char *extrasParams, double price, double amount, int count, const char *serverId, const char *serverName, const char *gameRoleName, const char *gameRoleId, const char *gameRoleBalance, const char *vipLevel, const char *gameRoleLevel, const char *partyName, const char *fightPower, const char * profession)
  28. {
  29. SMPCQuickSDKPayOrderInfo *orderInfo = [[SMPCQuickSDKPayOrderInfo alloc] init];
  30. SMPCQuickSDKGameRoleInfo *gameRoleInfo = [[SMPCQuickSDKGameRoleInfo alloc] init];
  31. orderInfo.goodsID = [NSString stringWithUTF8String:goodsId ? goodsId : ""];
  32. orderInfo.productName = [NSString stringWithUTF8String:goodsName ? goodsName: ""];
  33. // orderInfo.productDesc = [NSString stringWithUTF8String:goodsDesc ? goodsDesc: ""]; //停用的属性
  34. // orderInfo.quantifier = [NSString stringWithUTF8String:quantifier ? quantifier: ""]; //停用的属性
  35. orderInfo.cpOrderID = [NSString stringWithUTF8String:cpOrderId ? cpOrderId: ""];
  36. // orderInfo.price = price; //停用的属性
  37. orderInfo.count = count;
  38. orderInfo.amount = amount;
  39. orderInfo.callbackUrl = [NSString stringWithUTF8String:callbackUrl ? callbackUrl: ""];
  40. orderInfo.extrasParams = [NSString stringWithUTF8String:extrasParams ? extrasParams: ""];
  41. gameRoleInfo.serverId = [NSString stringWithUTF8String:serverId ? serverId: ""];
  42. gameRoleInfo.serverName = [NSString stringWithUTF8String:serverName ? serverName: ""];
  43. gameRoleInfo.gameRoleName = [NSString stringWithUTF8String:gameRoleName ? gameRoleName: ""];
  44. gameRoleInfo.gameRoleID = [NSString stringWithUTF8String:gameRoleId ? gameRoleId: ""];
  45. gameRoleInfo.gameUserBalance = [NSString stringWithUTF8String:gameRoleBalance ? gameRoleBalance: ""];
  46. gameRoleInfo.vipLevel = [NSString stringWithUTF8String:vipLevel ? vipLevel: ""];
  47. gameRoleInfo.gameUserLevel = [NSString stringWithUTF8String:gameRoleLevel ? gameRoleLevel: ""];
  48. gameRoleInfo.partyName = [NSString stringWithUTF8String:partyName ? partyName: ""];
  49. gameRoleInfo.fightPower = [NSString stringWithUTF8String:fightPower ? fightPower:""];
  50. gameRoleInfo.profession = [NSString stringWithUTF8String:profession ? profession:""];
  51. [[QuickSDK_ios shareInstance] pay:orderInfo gameRoleInfo:gameRoleInfo];
  52. }
  53. const char* quicksdk_nativeUserId()
  54. {
  55. return [[[QuickSDK_ios shareInstance] userId] UTF8String];
  56. }
  57. void quicksdk_nativeUpdateRoleInfoWith(const char *serverId, const char *serverName, const char *gameRoleName, const char *gameRoleId, const char *gameRoleBalance, const char *vipLevel, const char *gameRoleLevel, const char *partyName, const char * creatTime, const char *fightPower, const char * profession)
  58. {
  59. SMPCQuickSDKGameRoleInfo *gameRoleInfo = [[SMPCQuickSDKGameRoleInfo alloc] init];
  60. gameRoleInfo.serverId = [NSString stringWithUTF8String:serverId ? serverId: ""];
  61. gameRoleInfo.serverName = [NSString stringWithUTF8String:serverName ? serverName: ""];
  62. gameRoleInfo.gameRoleName = [NSString stringWithUTF8String:gameRoleName ? gameRoleName: ""];
  63. gameRoleInfo.gameRoleID = [NSString stringWithUTF8String:gameRoleId ? gameRoleId: ""];
  64. gameRoleInfo.gameUserBalance = [NSString stringWithUTF8String:gameRoleBalance ? gameRoleBalance: ""];
  65. gameRoleInfo.vipLevel = [NSString stringWithUTF8String:vipLevel ? vipLevel: ""];
  66. gameRoleInfo.gameUserLevel = [NSString stringWithUTF8String:gameRoleLevel ? gameRoleLevel: ""];
  67. gameRoleInfo.partyName = [NSString stringWithUTF8String:partyName ? partyName: ""];
  68. gameRoleInfo.creatTime = [NSString stringWithUTF8String:creatTime ? creatTime: ""];
  69. gameRoleInfo.fightPower = [NSString stringWithUTF8String:fightPower ? fightPower:""];
  70. gameRoleInfo.profession = [NSString stringWithUTF8String:profession ? profession:""];
  71. [[QuickSDK_ios shareInstance] updateRoleInfoWith:gameRoleInfo isCreate:NO];
  72. }
  73. void quicksdk_nativeUpdateRoleInfo(const char *serverId, const char *serverName, const char *gameRoleName, const char *gameRoleId, const char *gameRoleBalance, const char *vipLevel, const char *gameRoleLevel, const char *partyName, const char *creatTime, const char *fightPower, const char * profession, BOOL isCreate){
  74. SMPCQuickSDKGameRoleInfo *gameRoleInfo = [[SMPCQuickSDKGameRoleInfo alloc] init];
  75. gameRoleInfo.serverId = [NSString stringWithUTF8String:serverId ? serverId: ""];
  76. gameRoleInfo.serverName = [NSString stringWithUTF8String:serverName ? serverName: ""];
  77. gameRoleInfo.gameRoleName = [NSString stringWithUTF8String:gameRoleName ? gameRoleName: ""];
  78. gameRoleInfo.gameRoleID = [NSString stringWithUTF8String:gameRoleId ? gameRoleId: ""];
  79. gameRoleInfo.gameUserBalance = [NSString stringWithUTF8String:gameRoleBalance ? gameRoleBalance: ""];
  80. gameRoleInfo.vipLevel = [NSString stringWithUTF8String:vipLevel ? vipLevel: ""];
  81. gameRoleInfo.gameUserLevel = [NSString stringWithUTF8String:gameRoleLevel ? gameRoleLevel: ""];
  82. gameRoleInfo.partyName = [NSString stringWithUTF8String:partyName ? partyName: ""];
  83. gameRoleInfo.creatTime = [NSString stringWithUTF8String:creatTime ? creatTime: ""];
  84. gameRoleInfo.fightPower = [NSString stringWithUTF8String:fightPower ? fightPower:""];
  85. gameRoleInfo.profession = [NSString stringWithUTF8String:profession ? profession:""];
  86. [[QuickSDK_ios shareInstance] updateRoleInfoWith:gameRoleInfo isCreate:isCreate];
  87. }
  88. void quicksdk_nativeEnterYunKeFuCenter(const char *gameRoleId, const char *gameRoleName, const char *serverName, const char *vipLevel){
  89. SMPCQuickSDKGameRoleInfo *gameRoleInfo = [[SMPCQuickSDKGameRoleInfo alloc] init];
  90. gameRoleInfo.serverName = [NSString stringWithUTF8String:serverName ? serverName: ""];
  91. gameRoleInfo.gameRoleName = [NSString stringWithUTF8String:gameRoleName ? gameRoleName: ""];
  92. gameRoleInfo.gameRoleID = [NSString stringWithUTF8String:gameRoleId ? gameRoleId: ""];
  93. gameRoleInfo.vipLevel = [NSString stringWithUTF8String:vipLevel ? vipLevel: ""];
  94. [[QuickSDK_ios shareInstance] enterYunKeFuCenter:gameRoleInfo];
  95. }
  96. void quicksdk_getLocalized(const char *productIds)
  97. {
  98. [[QuickSDK_ios shareInstance] Getlocalized:[NSString stringWithUTF8String:productIds ? productIds: ""]];
  99. }
  100. int quicksdk_nativeRealNameAuth(int show) {
  101. return [[QuickSDK_ios shareInstance] showRealNameAuth:show];
  102. }
  103. int quicksdk_nativeEnterUserCenter()
  104. {
  105. return [[QuickSDK_ios shareInstance] enterUserCenter];
  106. }
  107. int quicksdk_nativeEnterCustomerCenter()
  108. {
  109. return [[QuickSDK_ios shareInstance] enterCustomerCenter];
  110. }
  111. int quicksdk_nativeEnterBBS()
  112. {
  113. return [[QuickSDK_ios shareInstance] enterBBS];
  114. }
  115. int quicksdk_nativeShowToolBar(int place)
  116. {
  117. return [[QuickSDK_ios shareInstance] showToolBar:place];
  118. }
  119. int quicksdk_nativeHideToolBar()
  120. {
  121. return [[QuickSDK_ios shareInstance] hideToolBar];
  122. }
  123. int quicksdk_nativePausedGame()
  124. {
  125. return [[QuickSDK_ios shareInstance] pausedGame];
  126. }
  127. bool quicksdk_nativeIsFunctionTypeSupported(int type)
  128. {
  129. return [[QuickSDK_ios shareInstance] isFunctionTypeSupported:type];
  130. }
  131. const char *quicksdk_nativeChannelName()
  132. {
  133. return [[[QuickSDK_ios shareInstance] channelName] UTF8String];
  134. }
  135. const char *quicksdk_nativeChannelVersion()
  136. {
  137. return [[[QuickSDK_ios shareInstance] channelVersion] UTF8String];
  138. }
  139. int quicksdk_nativeChannelType()
  140. {
  141. return [[QuickSDK_ios shareInstance] channelType];
  142. }
  143. const char* quicksdk_nativeSDKVersion()
  144. {
  145. return [[[QuickSDK_ios shareInstance] SDKVersion] UTF8String];
  146. }
  147. const char* quicksdk_nativeGetConfigValue(const char* key)
  148. {
  149. return [[[QuickSDK_ios shareInstance] getConfigValue:[NSString stringWithUTF8String:key ? key : ""]] UTF8String];
  150. }
  151. #if defined(__cplusplus)
  152. }
  153. #endif