| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- var ObjectPool = require("ObjectPool");
- // Learn cc.Class:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
- // Learn Attribute:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
- cc.Class({
- extends: cc.Component,
- properties: {
- 对象池: {
- default: null,
- type: ObjectPool
- },
- 拳套: cc.Node,
- 拳套蓝: cc.Node,
- 我方分数: cc.Label,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- Games = this;
- },
- quan(){
- this.glovesDragon = this.拳套.getComponent(dragonBones.ArmatureDisplay);
- this.glovesDragonlan = this.拳套蓝.getComponent(dragonBones.ArmatureDisplay);
- },
- start () {
- // Log.info("我方都有什么", this.我方);
- // this.spotlamps = [
- // {
- // x : -230,
- // y : -72
- // },
- // {
- // x : -18.1,
- // y : 192.4
- // },
- // {
- // x : 162,
- // y : -63
- // }
- // ]
- ObjectPools._init();
- this.我方 = UtilsNode.getNode("我方父级",this.node)
- app.myDishuPool = [];
- // setTimeout(function () {
- // window.spotlamp.setPandShowAll(true,this.spotlamps);
- // }.bind(this),500)
- // setTimeout(function () {
- // window.spotlamp.setPandShowAll(false,this.spotlamps);
- // }.bind(this),5000)
- // Log.info("应该会掉",this.StartLishen)
- if (this.StartLishen) {
- this.StartLishen();
- }
- this.quan();
- },
- setScore : function(player,score){
- if (player == 0) {
- this.我方分数.string = score;
- this.我方分数.getComponent(cc.Animation).play();
- }else {
- this.敌方分数.string = score;
- }
- },
- setStartLishen(StartLishen){
- this.StartLishen = StartLishen;
- },
- 随机生成(index,父级,Pool) {
- // Log.info("走的是这个吧",index)
- // let temp = this.checkDishuPool(Pool);
- let temp = index;
- //现在就返回给 正常的地鼠
- let type = 1;
- 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) {
- var item = this.对象池.生成教育地鼠();
- item.parent = parents;
- // if (parents.children.length == 0) {
- //
- // } else {
- // // this.随机生成(父级);
- // return;
- // }
- // console.log("给的什么","状态数组", i,"状态",dishuType[i]);
- item.getComponent("dishu_teaching").init(父级, randomShapeIndex);
- item.getComponent("dishu_teaching").initData(temp, type, dishuManager.setConf(0),Pool);
- // Log.info("父类是谁",parents)
- // 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);
- // // console.log("对象池有什么", this.对象池.getDishuPool());
- //
- // }
- }
- // for (var i = 0; i <randomIndex.length ; i++) {
- //
- //
- //
- // }
- },
- 连击播放(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;
- }
- }
- },
- 随机生成ZD(index,父级,Pool) {
- Log.info("走的是这个吧",index)
- // let temp = this.checkDishuPool(Pool);
- let temp = index;
- //现在就返回给 正常的地鼠
- let type = 1;
- type = 1;
- // 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) {
- var item = this.对象池.生成教育炸弹();
- // Pool[temp] = item.getComponent("zhadan");
- item.parent = parents;
- // if (parents.children.length == 0) {
- //
- // } else {
- // // this.随机生成(父级);
- // return;
- // }
- // Log.info("现在是 教育炸弹",item)
- item.getComponent("zhadan_teaching").init(父级, randomShapeIndex);
- item.getComponent("zhadan_teaching").initData(temp, type, dishuManager.setConf(0),Pool);
- }
- // for (var i = 0; i <randomIndex.length ; i++) {
- //
- //
- //
- // }
- },
- 掉血(父级, 血量) {
- Log.info("死亡掉血")
- if (this.BeAttackedLishen) {
- this.BeAttackedLishen()
- }
- tip.tiplayoutc.playOut();
- // 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 = 当前血量;
- //
- //
- // }
- },
- setBeAttackedLishen(BeAttackedLishen){
- this.BeAttackedLishen = BeAttackedLishen;
- }
- // update (dt) {},
- });
|