| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939 |
- var ObjectPool = require("ObjectPool");
- window.app = {
- dadishu: null,
- myDishuPool: null,
- hisDishuPool: null,
- Camera: null,
- // removeAlldishu : function (index) {
- // // this.myDishuPool = [null,null,null]
- // this.dadishu.waitTime()
- // for (var i = 0; i < this.myDishuPool.length; i++) {
- // if (this.myDishuPool[i] != null) {
- // if (i != index) {
- // ObjectPools.地鼠回收(this.myDishuPool[i].node);
- // }
- //
- // // Log.info("地鼠盒子里面的数据是",this.myDishuPool[i])
- // }
- // }
- // // setTimeout(function () {
- // // ObjectPools.地鼠回收(this.myDishuPool[index].node);
- // // }.bind(this),1000)
- //
- // },
- // baozha(){
- // Log.info("爆炸")
- // }
- }
- window.CameraManager = {
- startAnimation() {
- app.Camera.getComponent(cc.Animation).play();
- }
- }
- window.dishuManager = {
- confs: [
- {
- top: {
- time: 0.2,
- timeScale: 3
- },
- mid: {
- time: 2.6,
- timeScale: 1
- },
- lower: {
- time: 0.1,
- timeScale: 3
- },
- },
- {
- top: {
- time: 0.2,
- timeScale: 3
- },
- mid: {
- time: 2,
- timeScale: 1
- },
- lower: {
- time: 0.1,
- timeScale: 3
- }
- },
- {
- top: {
- time: 0.2,
- timeScale: 3
- },
- mid: {
- time: 1.8,
- timeScale: 1
- },
- lower: {
- time: 0.1,
- timeScale: 3
- }
- },
- ],
- scheduleTimes : [2,1.25,1.25],
- num: 0,
- //奖励分数
- rewardScore : 10,
- setConf: function (num) {
- this.num = num;
- return this.confs[this.num];
- },
- getConf: function () {
- return this.confs[this.num];
- },
- setScheduleTimes: function (num) {
- this.num = num;
- return this.scheduleTimes[this.num];
- },
- getScheduleTimes: function () {
- // Log.info("到底是什么",this.num,this.scheduleTimes)
- return this.scheduleTimes[this.num];
- },
- }
- cc.Class({
- extends: cc.Component,
- properties: {
- 我方: cc.Node,
- 敌方: cc.Node,
- head1: cc.Node,
- head2: cc.Node,
- 对象池: {
- default: null,
- type: ObjectPool
- },
- 敌方血条: cc.Node,
- 我方血条: cc.Node,
- 倒计时: cc.Label,
- 敌方分数: cc.Label,
- 我方分数: cc.Label,
- 连击动画: cc.Node,
- 拳套: cc.Node,
- 拳套蓝: cc.Node,
- 计时标志: false,
- 爆笑音效: cc.Node,
- toch: cc.Node,
- },
- clickstart: function () {
- Games = this;
- this.glovesDragon = this.拳套.getComponent(dragonBones.ArmatureDisplay);
- this.glovesDragonlan = this.拳套蓝.getComponent(dragonBones.ArmatureDisplay);
- console.log(this.时分(parseInt(MySetting.match_time)));
- this.初始化();
- },
- clickpause: function () {
- cc.director.pause()
- // this.getComponent("dialog").setShow(1);
- // console.log("对话框" + this.getComponent("dialog"));
- },
- clickrestart: function () {
- cc.director.resume();
- // this.getComponent("dialog").setShow(0);
- },
- clickgameoverrestart: function () {
- utils.isMobile(function () {
- manager_android_js.gamestatus = 1;
- }.bind(this));
- // this.重新开始();
- if (this.restartCallBack != null) {
- this.restartCallBack();
- }
- },
- restartCallBack: function () {
- },
- setRestartCallBack: function (restartCallBack) {
- this.restartCallBack = restartCallBack;
- },
- //删除所有的地鼠
- removeAlldishu : function (index) {
- // this.myDishuPool = [null,null,null]
- app.dadishu.waitTime()
- for (var i = 0; i < app.myDishuPool.length; i++) {
- if (app.myDishuPool[i] != null) {
- if (i != index) {
- ObjectPools.地鼠回收(app.myDishuPool[i].node);
- }
- // Log.info("地鼠盒子里面的数据是",this.myDishuPool[i])
- }
- }
- // setTimeout(function () {
- // ObjectPools.地鼠回收(this.myDishuPool[index].node);
- // }.bind(this),1000)
- },
- onLoad() {
- this.dishuPool = new cc.NodePool();
- app.Camera = cc.find("Canvas/Main Camera");
- // console.log("当前摄像机",app.Camera);
- app.dadishu = this;
- app.myDishuPool = [null, null, null];
- utils.isMobile(function () {
- manager_android_js.dishunameger = this;
- this.toch.active = false;
- }.bind(this));
- // manager_android_js.myPlayerInfo = PlayerInfo;
- // console.log("人员信息 设置",PlayerInfo);
- // console.log("人员信息 查看",manager_android_js.myPlayerInfo);
- //如果是第一次就去 开启新手教学
- if (PlayerInfo.Left.isfirst == true) {
- this.getComponent("new").init();
- this.getComponent("new").setProcessCallback(function () {
- this.getComponent("ready").init();
- }.bind(this))
- } else {
- this.getComponent("ready").init();
- }
- // 设置头像
- this.setHead();
- MySetting.share = "https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3078873712,1340878922&fm=26&gp=0.jpg";
- // this.gameovers = this.node.getComponent("gameovers");
- //
- // this.结束界面 = this.gameovers;
- this.life = 1 / MySetting.life_value;
- console.log("每次扣血", this.life, "总血量", MySetting.life_value);
- // this.结束界面.hide();
- // this.结束界面.active = true;
- //
- // var data = {
- // fen1: this.我方分数.string,
- // fen2: this.敌方分数.string,
- //
- // type: 0
- //
- // }
- // this.gameovers.setDatas(data);
- // console.log("都有啥", this.gameovers);
- this.Countdown = UtilsNode.getNode("Countdown",this.node);
- this.Countdownc = this.Countdown.getComponent("Countdown");
- },
- setHead: function () {
- PlayerInfo.Left.head = utils.getNewHttpImage(PlayerInfo.Left.head);
- Log.info("现在头像是",PlayerInfo.Left.head)
- this.loadImg(this.head1, PlayerInfo.Left.head, 90, 90);
- // this.loadImg(this.head2, PlayerInfo.Right.head, 90, 90);
- },
- loadImg: function (container, url, w, h) {
- // console.log("现在进来的是什么",container,url);
- //
- // return;
- cc.loader.load(url, function (err, texture) {
- var sprite = new cc.SpriteFrame(texture);
- container.getComponent(cc.Sprite).spriteFrame = sprite;
- if (w != null) {
- container.width = w;
- }
- if (h != null) {
- container.height = h;
- }
- });
- },
- countDownTime: function () {
- //播放开始动画
- // console.log("播放开始倒计时");
- this.callbackcountDownTime = function () {
- this.clickstart();
- utils.isMobile(function () {
- manager_android_js.gamestatus = 1;
- }.bind(this));
- }
- this.scheduleOnce(this.callbackcountDownTime, 0.1);
- },
- 初始化() {
- this.gameTag = true;
- GameData.gameStartTime = new Date().getTime()
- utils.isMobile(function () {
- manager_android_js.gamestatus = 1;
- }.bind(this));
- Statistics.restStart();
- this.startAudioSource();
- tip = null
- this.敌方血条.getComponent(cc.ProgressBar).progress = 1;
- this.我方血条.getComponent(cc.ProgressBar).progress = 1;
- this.倒计 = parseInt(MySetting.match_time);
- this.计时标志 = true;
- this.敌方分数.string = 0;
- this.我方分数.string = 0;
- ObjectPools._init();
- this.Countdownc.setTimeInit(this.倒计);
- app.myDishuPool = [];
- for (var i = 0; i < this.我方.children.length; i++) {
- app.myDishuPool[i] = null
- }
- app.hisDishuPool = [];
- for (var i = 0; i < this.敌方.children.length; i++) {
- app.hisDishuPool[i] = null
- }
- // this.unschedule(this.callback);
- this.startLoop();
- Log.info("正常打地鼠")
- this.Countdownc.setTimeEndCallBack(function () {
- console.log("时间到",this.倒计);
- // this.倒计 = 0;
- this.倒计时结束();
- }.bind(this));
- this.Countdownc.setTimeUpdateCallBack(function (time) {
- this.倒计 = time;
- // console.log("倒计时",Math.floor(parseInt(time)));
- }.bind(this));
- },
- //根据时间的不同 上中下速度 的变更
- checkTime: function () {
- let time = 0;
- if (this.倒计 <= MySetting.match_time && this.倒计 > MySetting.time[0]) {
- } else if (this.倒计 <= MySetting.time[0] && this.倒计 > MySetting.time[1]) {
- time = 1;
- } else if (this.倒计 <= MySetting.time[1]) {
- time = 2;
- }
- return time;
- },
- endLoop: function () {
- },
- startLoop: function () {
- this.count = dishuManager.getScheduleTimes();
- // this.unschedule(this.callback);
- // console.log("现在我方 地鼠盒子", app.myDishuPool);
- // Log.info("什么问题",this.count)
- this.currld = new Date().getTime();
- this.callback = function () {
- if (this.count != dishuManager.getScheduleTimes()) {
- // 在第六次执行回调时取消这个计时器
- this.count = dishuManager.getScheduleTimes();
- this.unschedule(this.callback);
- this.startLoop();
- return;
- }
- // let time = new Date().getTime();
- // // console.log("相差时间 ",time-this.currld);
- // this.currld = time;
- this.doSomething();
- // this.startLoop();
- // this.count++;
- }
- this.schedule(this.callback, dishuManager.getScheduleTimes());
- },
- waitTime (){
- this.unschedule(this.callback);
- setTimeout(function () {
- if (this.gameTag) {
- this.startLoop();
- }
- }.bind(this),3000)
- },
- doSomething: function () {
- this.随机生成(this.我方,app.myDishuPool);
- // this.随机生成(this.敌方,app.hisDishuPool);
- // Log.info("现在生成地鼠",this.倒计,this.checkTime())
- },
- //开启声音
- startAudioSource: function () {
- this.getComponent(cc.AudioSource).volume = MySetting.sound_value;
- this.getComponent(cc.AudioSource).play();
- },
- setAudioSource: function () {
- this.getComponent(cc.AudioSource).volume = MySetting.sound_value;
- if (MySetting.sound_value == 0) {
- cc.audioEngine.stopAll();
- }
- },
- start() {
- },
- setScore : function(player,score){
- if (player == 0) {
- this.我方分数.string = score;
- this.我方分数.getComponent(cc.Animation).play();
- }else {
- this.敌方分数.string = score;
- }
- },
- // 掉血(父级, 血量) {
- //
- // utils.isMobile(function () {
- // if (manager_android_js.gamestatus == 3) {
- // return;
- // }
- // }.bind(this));
- //
- //
- // console.log("哪一方", 父级.name, "血量", 血量, "");
- // if (父级.name == this.我方.name) {
- // // 炸弹爆炸时分数不加
- // if (血量 == 0) {
- //
- //
- // var 当前血量 = this.敌方血条.getComponent(cc.ProgressBar).progress;
- // 当前血量 -= 1 * this.life;
- // // 当前血量 = 当前血量.toFixed(1);
- // this.敌方血条.getComponent(cc.ProgressBar).progress = 当前血量;
- // console.log("点到炸弹_", 父级.name, "当前血量_", 当前血量);
- // if (当前血量 <= 0.009) {
- // 当前血量 = 0;
- // this.敌方血条.getComponent(cc.ProgressBar).progress = 0;
- // this.游戏成功();
- //
- // }
- // return;
- // }
- // var 分数 = parseInt(this.我方分数.string);
- // 分数++;
- // this.我方分数.string = 分数.toString();
- //
- // var 当前血量 = this.敌方血条.getComponent(cc.ProgressBar).progress;
- // 当前血量 -= 血量 * this.life;
- // // 当前血量 = 当前血量.toFixed(1);
- // console.log("点到地鼠_", 父级.name, "当前血量_", 当前血量);
- // if (当前血量 <= 0.009) {
- // 当前血量 = 0;
- // this.敌方血条.getComponent(cc.ProgressBar).progress = 0;
- // this.游戏成功();
- // return;
- // }
- // this.敌方血条.getComponent(cc.ProgressBar).progress = 当前血量;
- //
- //
- // } else {
- // // 炸弹爆炸时分数不加
- // if (血量 == 0) {
- //
- // var 当前血量 = this.我方血条.getComponent(cc.ProgressBar).progress;
- // 当前血量 -= 1 * this.life;
- // // 当前血量 = 当前血量.toFixed(1);
- // this.我方血条.getComponent(cc.ProgressBar).progress = 当前血量;
- //
- // console.log("点到炸弹_", 父级.name, "当前血量_", 当前血量);
- // if (当前血量 <= 0.009) {
- // 当前血量 = 0;
- // this.我方血条.getComponent(cc.ProgressBar).progress = 0;
- // this.游戏失败();
- //
- // }
- // return;
- //
- // }
- // var 分数 = parseInt(this.敌方分数.string);
- // 分数++;
- // this.敌方分数.string = 分数.toString();
- //
- // var 当前血量 = this.我方血条.getComponent(cc.ProgressBar).progress;
- // 当前血量 -= 血量 * this.life;
- // // 当前血量 = 当前血量.toFixed(1);
- // console.log("点到地鼠_", 父级.name, "当前血量_", 当前血量);
- // if (当前血量 <= 0.009) {
- // 当前血量 = 0;
- // this.我方血条.getComponent(cc.ProgressBar).progress = 0;
- // this.游戏失败();
- // return;
- // }
- // this.我方血条.getComponent(cc.ProgressBar).progress = 当前血量;
- //
- //
- // }
- // },
- 掉血(父级, 血量) {
- utils.isMobile(function () {
- if (manager_android_js.gamestatus == 3) {
- return;
- }
- }.bind(this));
- // console.log("哪一方", 父级.name, "血量", 血量, "");
- if (父级.name == this.我方.name) {
- // 炸弹爆炸时分数不加
- if (血量 == 0) {
- // this.Effect = cc.find("Effect");
- // this.Effect.getComponent("Effect").setShow();
- // CameraManager.startAnimation();
- // var 当前血量 = this.我方血条.getComponent(cc.ProgressBar).progress;
- // 当前血量 -= 1 * this.life;
- // // 当前血量 = 当前血量.toFixed(1);
- // this.我方血条.getComponent(cc.ProgressBar).progress = 当前血量;
- //
- // console.log("点到炸弹_", 父级.name, "当前血量_", 当前血量);
- // if (当前血量 <= 0.009) {
- // 当前血量 = 0;
- // this.我方血条.getComponent(cc.ProgressBar).progress = 0;
- // this.游戏失败();
- //
- // }
- // console.log("地鼠下去了");
- // timer.setTime(-10);
- return;
- }
- // var 分数 = parseInt(this.我方分数.string);
- // 分数++;
- // this.我方分数.string = 分数.toString();
- //
- // var 当前血量 = this.敌方血条.getComponent(cc.ProgressBar).progress;
- // 当前血量 -= 血量 * this.life;
- // // 当前血量 = 当前血量.toFixed(1);
- // console.log("点到地鼠_", 父级.name, "当前血量_", 当前血量);
- // if (当前血量 <= 0.009) {
- // 当前血量 = 0;
- // this.敌方血条.getComponent(cc.ProgressBar).progress = 0;
- // this.游戏成功();
- // return;
- // }
- // this.敌方血条.getComponent(cc.ProgressBar).progress = 当前血量;
- } else {
- // 炸弹爆炸时分数不加
- if (血量 == 0) {
- // this.Effect = cc.find("Effect");
- // this.Effect.getComponent("Effect").setShow();
- // var 当前血量 = this.敌方血条.getComponent(cc.ProgressBar).progress;
- // 当前血量 -= 1 * this.life;
- // // 当前血量 = 当前血量.toFixed(1);
- // this.敌方血条.getComponent(cc.ProgressBar).progress = 当前血量;
- // console.log("点到炸弹_", 父级.name, "当前血量_", 当前血量);
- // if (当前血量 <= 0.009) {
- // 当前血量 = 0;
- // this.敌方血条.getComponent(cc.ProgressBar).progress = 0;
- // this.游戏成功();
- //
- // }
- // console.log("点到炸弹了");
- // CameraManager.startAnimation();
- // timer.setTime(-15);
- return;
- }
- // var 分数 = parseInt(this.敌方分数.string);
- // 分数++;
- // this.敌方分数.string = 分数.toString();
- //
- // var 当前血量 = this.我方血条.getComponent(cc.ProgressBar).progress;
- // 当前血量 -= 血量 * this.life;
- // // 当前血量 = 当前血量.toFixed(1);
- // console.log("点到地鼠_", 父级.name, "当前血量_", 当前血量);
- // if (当前血量 <= 0.009) {
- // 当前血量 = 0;
- // this.我方血条.getComponent(cc.ProgressBar).progress = 0;
- // this.游戏失败();
- // return;
- // }
- // this.我方血条.getComponent(cc.ProgressBar).progress = 当前血量;
- }
- },
- 游戏成功() {
- Statistics.playwin = PlayerInfo.Left;
- this.游戏结束(0);
- },
- 游戏失败() {
- Statistics.playwin = PlayerInfo.Right;
- this.游戏结束(1);
- },
- 倒计时结束() {
- this.unscheduleAllCallbacks();
- if (parseInt(this.我方分数.string) > parseInt(this.敌方分数.string)) {
- // console.log("胜利");
- this.游戏结束(0);
- } else if (parseInt(this.我方分数.string) == parseInt(this.敌方分数.string)) {
- // console.log("平局");
- this.游戏结束(1);
- } else {
- // console.log("失败");
- this.游戏结束(1);
- }
- },
- 游戏结束(type) {
- if (this.gameTag) {
- this.gameTag = false;
- }else{
- return;
- }
- console.log("准备跳转",this.倒计);
- Statistics.playtime = MySetting.match_time - this.倒计;
- this.unscheduleAllCallbacks();
- this.拳套.active = false;
- this.拳套蓝.active = false;
- // cc.director.pause();
- this.getComponent(cc.AudioSource).stop();
- cc.audioEngine.stopAll();
- this.setAudioSource();
- // utils.isMobile(function () {
- // if (manager_android_js.gamestatus == 3) {
- // return;
- // }
- // }.bind(this));
- // var c = this.结束界面.getChildByName('重新开始');
- this.计时标志 = false;
- var data = {
- fen1: this.我方分数.string,
- fen2: this.敌方分数.string,
- type: type,
- max: Statistics.player1.continuitymax
- }
- Statistics.player1.score = data.fen1;
- // Statistics.player1.score
- // console.log("都有啥", this.gameovers);
- // this.gameovers.setDatas(data);
- // this.glovesDragon.armature().animation.stop();
- for (var i = 0; i < this.连击动画.children.length; i++) {
- this.连击动画.children[i].active = false;
- }
- utils.getShareData(function (data) {
- UserInfo.args = data;
- // console.log("游戏产生数据" + UserInfo.args);
- console.log("游戏成绩" + JSON.stringify(UserInfo.args.setResult));
- console.log("游戏成绩 最高连击数",Statistics.player1.continuitymax);
- console.log("游戏成绩 打死了多少地鼠",Statistics.player1.attackCount);
- //
- // console.log("游戏数据是" + UserInfo.PlayerGameData);
- // console.log("游戏数据是 json" + JSON.stringify(UserInfo));
- // console.log("游戏数据是 args" + JSON.stringify(UserInfo.args));
- // console.log("假装 获得到的排行榜数据 json" + JSON.stringify(RankingListData));
- // utils.isMobile(function () {
- // Manager.chengji();
- // //真的数据来了 就注释此行
- // // this.showRankingList();
- // }.bind(this));
- // manager_android_js.chengji();
- utils.isMobile(function () {
- setTimeout(function () {
- //给数据到设备
- manager_android_js.gameover();
- }.bind(this),1000)
- }.bind(this));
- }.bind(this));
- // app.myDishuPool = [null, null, null];
- // app.hisDishuPool = [null, null, null];
- utils.isWeb(function () {
- setTimeout(function () {
- utils.toLoadScene("end");
- }.bind(this),1000)
- }.bind(this));
- },
- goToEnd : function(){
- utils.toLoadScene("end");
- },
- restgame: function () {
- if (this.restartCallBack != null) {
- this.restartCallBack();
- }
- },
- 重新开始() {
- // cc.director.resume();
- GameData.gameStartTime = new Date().getTime()
- Games.拳套.active = false;
- Games.拳套蓝.active = false;
- this.glovesDragon.armature().animation.stop();
- this.glovesDragonlan.armature().animation.stop();
- // this.glovesDragon.playAnimation("<None>", 1);
- for (var i = 0; i < this.我方.children.length; i++) {
- var childs = this.我方.children[i].children[0];
- if (childs.children.length == 1) {
- ObjectPools.地鼠回收(childs.children[0]);
- }
- }
- for (var i = 0; i < this.敌方.children.length; i++) {
- var childs = this.敌方.children[i].children[0];
- if (childs.children.length == 1) {
- ObjectPools.地鼠回收(childs.children[0]);
- }
- }
- // this.初始化();
- // this.结束界面.active = false;
- // this.结束界面.hide();
- },
- 随机生成(父级,Pool) {
- if (!this.gameTag) {
- return;
- }
- utils.isMobile(function () {
- if (manager_android_js.gamestatus == 3) {
- return;
- }
- }.bind(this));
- // var flag = false;
- // for (var i = 0; i < 父级.children.length; i++) {
- // var childs = 父级.children[i].children[0];
- // // if (父级.name == this.我方.name) {
- // // console.log("现在有多少炸弹和地鼠" ,childs.children);
- // // }
- // if (childs.children.length == 0) {
- // flag = true;
- // }
- // }
- // if (flag == false)
- // return;
- // var randomIndex = parseInt(Math.random() * 3, 10);
- // console.log("现在数字" + randomIndex );
- // console.log("假定0" + "左" );
- // console.log("假定1" + "中" );
- // console.log("假定2" + "右" );
- let temp = this.checkDishuPool(Pool);
- //现在就返回给 正常的地鼠
- let type = this.returnType();
- type = 0;
- // console.log("现在是什么" , 父级.name ,"判断结果哪个是空的可以上地鼠的",temp , Pool);
- if (temp == -1) {
- return;
- }
- // let randomIndex = [0,1];
- let dishuType = [0, 1];
- var parents = 父级.children[temp].getChildByName("Mask");
- var ran = Math.ceil(Math.random() * 100);
- var randomShapeIndex = parseInt(Math.random() * 4, 10) + 1;
- if (Pool[temp] == null) {
- if (ran > 95 && ran < 100) {
- var item = this.对象池.生成炸弹();
- // Pool[temp] = item.getComponent("zhadan");
- item.parent = parents;
- // if (parents.children.length == 0) {
- //
- // } else {
- // // this.随机生成(父级);
- // return;
- // }
- item.getComponent("zhadan").init(父级, randomShapeIndex);
- item.getComponent("zhadan").initData(temp, type, dishuManager.setConf(this.checkTime()),Pool);
- } else {
- var item = this.对象池.生成地鼠();
- item.parent = parents;
- // if (parents.children.length == 0) {
- //
- // } else {
- // // this.随机生成(父级);
- // return;
- // }
- // console.log("给的什么","状态数组", i,"状态",dishuType[i]);
- item.getComponent("dishu").init(父级, randomShapeIndex);
- item.getComponent("dishu").initData(temp, type, dishuManager.setConf(this.checkTime()),Pool);
- if (testUI) {
- testUI.showDishu(temp,true);
- }
- // console.log("对象池有什么", this.对象池.getDishuPool());
- // Log.info("父类是谁",parents)
- }
- }
- // for (var i = 0; i <randomIndex.length ; i++) {
- //
- //
- //
- // }
- },
- //检查 现在 地鼠池 可以出生的地鼠的位置
- checkDishuPool: function (pools) {
- let arr = [];
- for (var i = 0; i < pools.length; i++) {
- if (pools[i] == null) {
- arr.push(i);
- }
- }
- let returnNum = -1;
- if (arr.length > 1) {
- returnNum = UtilsNode.getRandom(4, null, null, arr);
- } else if (arr.length == 1) {
- returnNum = arr[0]
- }
- return returnNum;
- },
- //检查 现在 地鼠池 可以出生的地鼠的位置
- returnType: function () {
- //0是正常的地鼠 1 是干扰的地鼠
- let returnNum = 0;
- // returnNum = UtilsNode.getRandom(0, 0, 2);
- // console.log("现在给", returnNum);
- let ran = Math.ceil(Math.random() * 100);
- if (ran > 30 && ran < 100) {
- }else{
- returnNum = 1;
- }
- return returnNum;
- },
- checkTouch: function (target, location) {
- let node = target;
- let pointInNode = node.convertToNodeSpaceAR(location);
- let i, j, c = false;
- if (!target.getComponent(cc.PolygonCollider))
- return;
- let nvert = target.getComponent(cc.PolygonCollider).points.length;
- let testx = pointInNode.x;
- let testy = pointInNode.y;
- let vert = target.getComponent(cc.PolygonCollider).points;
- for (i = 0, j = nvert - 1; i < nvert; j = i++) {
- if (((vert[i].y > testy) != (vert[j].y > testy)) &&
- (testx < (vert[j].x - vert[i].x) * (testy - vert[i].y) / (vert[j].y - vert[i].y) + vert[i].x))
- c = !c;
- }
- return c;
- },
- // 输出03:05:59 时分秒
- 时分(result) {
- var h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
- var m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
- var s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
- //return result = h + ":" + m + ":" + s;
- return result = m + ":" + s;
- },
- 连击播放(p, obj, str) {
- for (var i = 0; i < obj.children.length; i++) {
- var exp = obj.children[i];
- var labelstr = exp.getChildByName("New Label").getComponent(cc.Label);
- labelstr.string = str;
- if (exp.active == false) {
- exp.position = p;
- exp.active = true;
- break;
- }
- }
- },
- update(dt) {
- // if (this.计时标志) {
- // if (this.倒计 <= 0) {
- // this.倒计时结束();
- // this.计时标志 = false;
- // }
- // this.倒计 -= dt;
- // var 时间 = this.时分(this.倒计);
- // this.倒计时.string = 时间.toString();
- // }
- },
- 设置() {
- this.爆笑音效.active = true;
- cc.director.pause();
- },
- });
|