204 lines
6.8 KiB
JavaScript
204 lines
6.8 KiB
JavaScript
// Learn cc.Class:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
|
|
// Learn Attribute:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
var SDKManage = require("SDKManage")
|
|
var wxVoice = require("wxVoice")
|
|
var battlenet = require("battlenetmanage")
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
condition: 1,
|
|
waittime: 0,
|
|
logkey: "",
|
|
logdes: "",
|
|
soundname: "",
|
|
lb_des: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
this.node.opacity = 0
|
|
this.time = 0
|
|
this.canupdate = false
|
|
},
|
|
onDestroy() {
|
|
cc.Notifier.off('jiantingbeidong', this);
|
|
cc.Notifier.off('jiantingskill', this);
|
|
cc.Notifier.off('jiantingzhongjiezhe', this);
|
|
cc.Notifier.off('jiantingjiajia', this);
|
|
cc.Notifier.off('newbieanimation', this);
|
|
},
|
|
jiantingbeidong() {
|
|
this.playani()
|
|
cc.Notifier.off('jiantingbeidong', this);
|
|
},
|
|
jiantingskill(res) {
|
|
this.time = 0
|
|
this.node.active = true
|
|
this.lb_des.string = res
|
|
this.playani()
|
|
},
|
|
jiantingzhongjiezhe() {
|
|
this.playani()
|
|
cc.Notifier.off('jiantingzhongjiezhe', this);
|
|
},
|
|
jiantingjiajia() {
|
|
this.playani()
|
|
cc.Notifier.off('jiantingjiajia', this);
|
|
},
|
|
|
|
newbieanimation(v) {
|
|
if (this.logkey == v&&this.condition<21) {
|
|
this.time = 0
|
|
this.node.active = true
|
|
this.playani()
|
|
}
|
|
},
|
|
|
|
|
|
start() {
|
|
if (battlenet.newbiemode) {
|
|
cc.Notifier.on('newbieanimation', this, this.newbieanimation.bind(this));
|
|
this.node.active = false
|
|
return
|
|
}
|
|
|
|
|
|
|
|
if (cc.gameMgr.firstzombie) {
|
|
if (this.condition == 21) {
|
|
cc.Notifier.on('jiantingbeidong', this, this.jiantingbeidong.bind(this));
|
|
} else if (this.condition == 22) {
|
|
cc.Notifier.on('jiantingskill', this, this.jiantingskill.bind(this));
|
|
} else if (this.condition == 23) {
|
|
cc.Notifier.on('jiantingzhongjiezhe', this, this.jiantingzhongjiezhe.bind(this));
|
|
} else if (this.condition == 24) {
|
|
cc.Notifier.on('jiantingjiajia', this, this.jiantingjiajia.bind(this));
|
|
}
|
|
}
|
|
|
|
|
|
this.node.opacity = 255
|
|
this.node.active = false
|
|
if (this.condition == 1) {
|
|
// if(cc.gameMgr.battlecount==1){
|
|
// this.node.active = true
|
|
// this.canupdate = true
|
|
// this.node.opacity = 0
|
|
// }
|
|
} else if (this.condition == 2 || this.condition == 3 || this.condition == 5 || this.condition == 6 || this.condition == 7 || this.condition == 8 || this.condition == 9 || this.condition == 12 || this.condition == 13) {
|
|
// if(cc.gameMgr.battlecount==1){
|
|
// this.node.active = true
|
|
// this.node.opacity = 0
|
|
// }
|
|
} else if (this.condition == 4) {
|
|
// if(cc.gameMgr.battlecount==2){
|
|
// this.node.active = true
|
|
// this.canupdate = true
|
|
// }
|
|
} else if (this.condition == 10 || this.condition == 11) {
|
|
// if(cc.gameMgr.battlecount==2){
|
|
// this.node.active = true
|
|
// this.node.opacity = 0
|
|
// }
|
|
} else if (this.condition == 21 || this.condition == 22 || this.condition == 23 || this.condition == 24) {
|
|
if (cc.gameMgr.firstzombie) {
|
|
this.node.active = true
|
|
this.node.opacity = 0
|
|
}
|
|
}
|
|
|
|
|
|
},
|
|
playani() {
|
|
this.canupdate = true
|
|
this.node.opacity = 255
|
|
var ani = this.node.getComponent(cc.Animation)
|
|
if (ani) {
|
|
ani.play()
|
|
}
|
|
if(this.condition<21){
|
|
SDKManage.logEvent(this.logkey, this.logdes)
|
|
}
|
|
|
|
if (this.soundname != "") {
|
|
wxVoice.playSound(this.soundname)
|
|
}
|
|
},
|
|
update(dt) {
|
|
if (battlenet.newbiemode) {
|
|
this.time += dt
|
|
if (this.time > 2) {
|
|
this.node.active = false
|
|
}
|
|
return
|
|
}
|
|
|
|
|
|
|
|
if (this.canupdate == false && cc.gameMgr.player) {
|
|
var player = cc.gameMgr.player.pctrl
|
|
var needcg = false
|
|
if (this.condition == 2 && player.guns[1] != 0 && player.guns[2] != 0) {
|
|
needcg = true
|
|
} else if (this.condition == 3 && (player.yaoArr[0] > 0 || player.yaoArr[1] > 0)) { //&& player.getHpBar()<0.4
|
|
needcg = true
|
|
} else if (this.condition == 5 && (player.hat != 0 || player.cloth != 0)) {
|
|
needcg = true
|
|
} else if (this.condition == 6 && player.backpack != 0) {
|
|
needcg = true
|
|
} else if (this.condition == 7 && player.getfake) {
|
|
needcg = true
|
|
} else if (this.condition == 8 && cc.gameMgr.airstart) {
|
|
needcg = true
|
|
} else if (this.condition == 9 && cc.gameMgr.suoquanstart) {
|
|
needcg = true
|
|
} else if (this.condition == 10 && player.teamMembers.length > 0) {
|
|
needcg = true
|
|
} else if (this.condition == 11 && cc.gameMgr.memberhurt) {
|
|
needcg = true
|
|
} else if (this.condition == 12 && cc.gameMgr.gameStart) {
|
|
needcg = true
|
|
} else if (this.condition == 13 && cc.gameMgr.findenmey) {
|
|
needcg = true
|
|
}
|
|
|
|
if (needcg) {
|
|
this.playani()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (this.waittime >= 0 && this.condition == 1) {
|
|
this.waittime -= dt
|
|
if (this.waittime < 0) {
|
|
this.node.getComponent(cc.Animation).play()
|
|
this.node.opacity = 255
|
|
SDKManage.logEvent(this.logkey, this.logdes)
|
|
if (this.soundname != "") {
|
|
wxVoice.playSound(this.soundname)
|
|
}
|
|
}
|
|
return
|
|
}
|
|
if (this.canupdate) {
|
|
this.time += dt
|
|
}
|
|
|
|
if (this.time > 4) {
|
|
this.node.active = false
|
|
}
|
|
},
|
|
}); |