| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- window.Manager = {
- UserInfo : null,
- strike : null,
- main : null,
- layoutManager : null,
-
- sceneType : 0,
- login : null,
- Multimain : null,
- sharelayoutManager : null,
- loginTag : false,
- closeTag : false,
- goMainTag : false,
- gameState : 0,
- getNavigator: function () {
- //js判断当前移动设备平台
- var isiOs = this.isiOs = false;
- var isAndroid = this.isAndroid = false;
- var isWindowsPhone = this.isWindowsPhone = false;
- if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
- this.isiOS = true;
- } else if (/(Android)/i.test(navigator.userAgent)) {
- this.isAndroid = true;
- } else if (/(Windows Phone)/i.test(navigator.userAgent)) {
- this.isWindowsPhone = true;
- }
- },
- //游戏结束
- gameover: function () {
- if (this.isAndroid) {
- document.getElementById("button_gameover").click();
- }
- if (this.isiOS) {
- document.getElementById("button_gameover_ios").click();
- }
- // alert("震动");
- },
- goShare: function () {
- if (this.isAndroid) {
- document.getElementById("button_goShare").click();
- }
- if (this.isiOS) {
- document.getElementById("button_goShare_ios").click();
- }
- // alert("震动");
- },
- getRanking: function () {
- if (this.isAndroid) {
- document.getElementById("button_getRanking").click();
- }
- if (this.isiOS) {
- document.getElementById("button_getRanking_ios").click();
- }
- // alert("震动");
- },
- restartGame: function () {
- if (this.isAndroid) {
- document.getElementById("button_restGame").click();
- }
- if (this.isiOS) {
- document.getElementById("button_restGame_ios").click();
- }
- // alert("震动");
- },
- }
- //方法
- // function Hit_correctly(pow) {
- /**
- *
- * @param der 方向 1234
- * @param pianyi 1 打中 0打偏
- * @param pow 力量值
- * @param ballSpeed 球速
- */
- function action_punch(der,pianyi,power,ballSpeed) {
- console.log("流浪地球-接口数据 正确的击中了"+Manager.sceneType,power);
- console.log(" 流浪地球-接口数据 击中了的数据是"+"方向 "+der+
- " 流浪地球-接口数据 打 1 中 0偏 "+pianyi+
- " 流浪地球-接口数据 力量值 "+power+
- " 流浪地球-接口数据 球速 "+ballSpeed
- );
- //这里是为了看打击数据才return的,正式版本千万要注释
- // return;
- if (Manager.gameState == 1) {
- return;
- }
- var datastrike = {
- der : der,
- pianyi : pianyi,
- power : power,
- ballSpeed : ballSpeed
- }
- switch (Manager.sceneType) {
- case 0:
- if (pianyi != 1) {
- return;
- }
- if (Manager.loginTag) {
- return;
- }
- Manager.loginTag = true;
- setTimeout(function () {
- Manager.loginTag = false;
- }.bind(this),10000)
- //进入游戏
- Manager.login.goMain();
- break;
- case 1:
- //打拳
- Manager.strike.onclickcallback(datastrike);
- // Manager.strike.javascript:action_punch(1,1,1,1);
- break;
- case 2:
- if (pianyi != 0) {
- return;
- }
- if (Manager.closeTag) {
- return;
- }
- Manager.closeTag = true;
- setTimeout(function () {
- Manager.closeTag = false;
- }.bind(this),5000)
- //跳过分享
- Manager.sharelayoutManager.close();
- break;
- case 3:
- if (pianyi != 1) {
- return;
- }
- if (Manager.goMainTag) {
- return;
- }
- Manager.goMainTag = true;
- setTimeout(function () {
- Manager.goMainTag = false;
- }.bind(this),5000)
- //结算 重新 来一局
- Manager.Settlementlayout.goMain();
- break;
- }
- }
- //游戏暂停
- function action_pause() {
- cc.game.pause();
- Manager.gameState = 1;
- }
- //游戏恢复
- function action_continue() {
- cc.game.resume();
- Manager.gameState = 0;
- }
- //再来一局
- function jsCall_restartGame() {
- window.android.jsCall_restartGame();
- }
- //方法
- function Deviation(pow) {
- console.log("流浪地球-接口数据 打偏了 小老弟",pow);
- Manager.strike.onclickcallback(0,pow);
- }
- //方法
- function Reset(pow) {
- console.log("流浪地球-接口数据 重置");
- Manager.main.myinit();
- Manager.strike._init();
- }
- //设置人员信息
- function setUserInfo(userInfo) {
- console.log("流浪地球-接口数据 用户设置数据", userInfo);
- UserInfo.Player = userInfo;
- }
- //给排行版
- function putRanking(RankingListDatas) {
- console.log("流浪地球-接口数据 给排行榜数据"+ RankingListData);
- // console.log("给排行榜数据 JSON"+ JSON.parse(RankingListData);
- if (RankingListData != null){
- RankingListData = RankingListDatas;
- }
- console.log("流浪地球-接口数据 带数据排行榜内容"+ RankingListData);
- console.log("流浪地球-接口数据 带数据排行榜内容 JSON"+ JSON.stringify(RankingListData));
- Manager.layoutManager.showRankingList();
- }
- function jsCall_Ranking() {
- window.android.jsCall_Ranking();
- }
- function jsCallios_Ranking() {
- }
- //android 游戏结束
- function jsCallAndroid_GameOver() {
- // Statistics.playtime = MySetting.match_time - Statistics.time;
- // Statistics.player2.playerUserInfo = PlayerInfo.Right;
- window.android.jsCall_Game_Over(JSON.stringify(UserInfo));
- // rsetStatistics();
- }
- //ios 游戏结束
- function jsCallios_GameOver() {
- // Statistics.player2.playerUserInfo = PlayerInfo.Right;
- // jsCallios_GameOvermy(JSON.stringify(Statistics));
- window.webkit.messageHandlers.jsCallios_GameOver.postMessage(JSON.stringify(UserInfo));
- // rsetStatistics();
- }
- function jsCallAndroid_goShare() {
- console.log("流浪地球-接口数据 去分享 "+ ShareImage.img);
- window.android.jsCall_Share(ShareImage.img);
- }
- function jsCallios_goShare() {
- window.webkit.messageHandlers.jsCallios_GoShare.postMessage(JSON.stringify(ShareImage.img));
- }
- function jsCall_restGame() {
- console.log("流浪地球-接口数据 重新开始游戏 ");
- window.android.jsCall_restartGame();
- }
- function jsCallios_restGame() {
- window.webkit.messageHandlers.jsCallios_restartGame.postMessage();
- }
|