Manager.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. window.Manager = {
  2. UserInfo : null,
  3. strike : null,
  4. main : null,
  5. layoutManager : null,
  6. sceneType : 0,
  7. login : null,
  8. Multimain : null,
  9. sharelayoutManager : null,
  10. loginTag : false,
  11. closeTag : false,
  12. goMainTag : false,
  13. gameState : 0,
  14. getNavigator: function () {
  15. //js判断当前移动设备平台
  16. var isiOs = this.isiOs = false;
  17. var isAndroid = this.isAndroid = false;
  18. var isWindowsPhone = this.isWindowsPhone = false;
  19. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  20. this.isiOS = true;
  21. } else if (/(Android)/i.test(navigator.userAgent)) {
  22. this.isAndroid = true;
  23. } else if (/(Windows Phone)/i.test(navigator.userAgent)) {
  24. this.isWindowsPhone = true;
  25. }
  26. },
  27. //游戏结束
  28. gameover: function () {
  29. if (this.isAndroid) {
  30. document.getElementById("button_gameover").click();
  31. }
  32. if (this.isiOS) {
  33. document.getElementById("button_gameover_ios").click();
  34. }
  35. // alert("震动");
  36. },
  37. goShare: function () {
  38. if (this.isAndroid) {
  39. document.getElementById("button_goShare").click();
  40. }
  41. if (this.isiOS) {
  42. document.getElementById("button_goShare_ios").click();
  43. }
  44. // alert("震动");
  45. },
  46. getRanking: function () {
  47. if (this.isAndroid) {
  48. document.getElementById("button_getRanking").click();
  49. }
  50. if (this.isiOS) {
  51. document.getElementById("button_getRanking_ios").click();
  52. }
  53. // alert("震动");
  54. },
  55. restartGame: function () {
  56. if (this.isAndroid) {
  57. document.getElementById("button_restGame").click();
  58. }
  59. if (this.isiOS) {
  60. document.getElementById("button_restGame_ios").click();
  61. }
  62. // alert("震动");
  63. },
  64. }
  65. //方法
  66. // function Hit_correctly(pow) {
  67. /**
  68. *
  69. * @param der 方向 1234
  70. * @param pianyi 1 打中 0打偏
  71. * @param pow 力量值
  72. * @param ballSpeed 球速
  73. */
  74. function action_punch(der,pianyi,power,ballSpeed) {
  75. console.log("流浪地球-接口数据 正确的击中了"+Manager.sceneType,power);
  76. console.log(" 流浪地球-接口数据 击中了的数据是"+"方向 "+der+
  77. " 流浪地球-接口数据 打 1 中 0偏 "+pianyi+
  78. " 流浪地球-接口数据 力量值 "+power+
  79. " 流浪地球-接口数据 球速 "+ballSpeed
  80. );
  81. //这里是为了看打击数据才return的,正式版本千万要注释
  82. // return;
  83. if (Manager.gameState == 1) {
  84. return;
  85. }
  86. var datastrike = {
  87. der : der,
  88. pianyi : pianyi,
  89. power : power,
  90. ballSpeed : ballSpeed
  91. }
  92. switch (Manager.sceneType) {
  93. case 0:
  94. if (pianyi != 1) {
  95. return;
  96. }
  97. if (Manager.loginTag) {
  98. return;
  99. }
  100. Manager.loginTag = true;
  101. setTimeout(function () {
  102. Manager.loginTag = false;
  103. }.bind(this),10000)
  104. //进入游戏
  105. Manager.login.goMain();
  106. break;
  107. case 1:
  108. //打拳
  109. Manager.strike.onclickcallback(datastrike);
  110. // Manager.strike.javascript:action_punch(1,1,1,1);
  111. break;
  112. case 2:
  113. if (pianyi != 0) {
  114. return;
  115. }
  116. if (Manager.closeTag) {
  117. return;
  118. }
  119. Manager.closeTag = true;
  120. setTimeout(function () {
  121. Manager.closeTag = false;
  122. }.bind(this),5000)
  123. //跳过分享
  124. Manager.sharelayoutManager.close();
  125. break;
  126. case 3:
  127. if (pianyi != 1) {
  128. return;
  129. }
  130. if (Manager.goMainTag) {
  131. return;
  132. }
  133. Manager.goMainTag = true;
  134. setTimeout(function () {
  135. Manager.goMainTag = false;
  136. }.bind(this),5000)
  137. //结算 重新 来一局
  138. Manager.Settlementlayout.goMain();
  139. break;
  140. }
  141. }
  142. //游戏暂停
  143. function action_pause() {
  144. cc.game.pause();
  145. Manager.gameState = 1;
  146. }
  147. //游戏恢复
  148. function action_continue() {
  149. cc.game.resume();
  150. Manager.gameState = 0;
  151. }
  152. //再来一局
  153. function jsCall_restartGame() {
  154. window.android.jsCall_restartGame();
  155. }
  156. //方法
  157. function Deviation(pow) {
  158. console.log("流浪地球-接口数据 打偏了 小老弟",pow);
  159. Manager.strike.onclickcallback(0,pow);
  160. }
  161. //方法
  162. function Reset(pow) {
  163. console.log("流浪地球-接口数据 重置");
  164. Manager.main.myinit();
  165. Manager.strike._init();
  166. }
  167. //设置人员信息
  168. function setUserInfo(userInfo) {
  169. console.log("流浪地球-接口数据 用户设置数据", userInfo);
  170. UserInfo.Player = userInfo;
  171. }
  172. //给排行版
  173. function putRanking(RankingListDatas) {
  174. console.log("流浪地球-接口数据 给排行榜数据"+ RankingListData);
  175. // console.log("给排行榜数据 JSON"+ JSON.parse(RankingListData);
  176. if (RankingListData != null){
  177. RankingListData = RankingListDatas;
  178. }
  179. console.log("流浪地球-接口数据 带数据排行榜内容"+ RankingListData);
  180. console.log("流浪地球-接口数据 带数据排行榜内容 JSON"+ JSON.stringify(RankingListData));
  181. Manager.layoutManager.showRankingList();
  182. }
  183. function jsCall_Ranking() {
  184. window.android.jsCall_Ranking();
  185. }
  186. function jsCallios_Ranking() {
  187. }
  188. //android 游戏结束
  189. function jsCallAndroid_GameOver() {
  190. // Statistics.playtime = MySetting.match_time - Statistics.time;
  191. // Statistics.player2.playerUserInfo = PlayerInfo.Right;
  192. window.android.jsCall_Game_Over(JSON.stringify(UserInfo));
  193. // rsetStatistics();
  194. }
  195. //ios 游戏结束
  196. function jsCallios_GameOver() {
  197. // Statistics.player2.playerUserInfo = PlayerInfo.Right;
  198. // jsCallios_GameOvermy(JSON.stringify(Statistics));
  199. window.webkit.messageHandlers.jsCallios_GameOver.postMessage(JSON.stringify(UserInfo));
  200. // rsetStatistics();
  201. }
  202. function jsCallAndroid_goShare() {
  203. console.log("流浪地球-接口数据 去分享 "+ ShareImage.img);
  204. window.android.jsCall_Share(ShareImage.img);
  205. }
  206. function jsCallios_goShare() {
  207. window.webkit.messageHandlers.jsCallios_GoShare.postMessage(JSON.stringify(ShareImage.img));
  208. }
  209. function jsCall_restGame() {
  210. console.log("流浪地球-接口数据 重新开始游戏 ");
  211. window.android.jsCall_restartGame();
  212. }
  213. function jsCallios_restGame() {
  214. window.webkit.messageHandlers.jsCallios_restartGame.postMessage();
  215. }