// 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 var gameConfig = require('gameConfig'); var battlenet = require('battlenetmanage'); var baseconfig = require('Config'); var wxvoice = require('wxVoice'); var jcgamelog = require('jcfw').gamelog; var gotoScene = 'MainScene'; // var SDKManage = require('SDKManage'); var playerData = require('playerData'); var NetManage = require('NetManage'); var Main = require('Main'); const { type } = require('../netBattle/net/proto/bytebuffer'); // const { // tonyInfo // } = require("../NUI/TonyInfo"); var skillConfig = gameConfig.skillConfig; var battletiparr = []; cc.Class({ extends: cc.Component, properties: { btn_skill: { default: null, type: cc.Node, }, skilljoy: { default: null, type: cc.Node, }, movejoy: { default: null, type: cc.Node, }, shotjoy: { default: null, type: cc.Node, }, btn_door: { default: null, type: cc.Node, }, btn_guns: { default: [], type: cc.Node, }, ndYao: { default: [], type: cc.Node, }, mask_hp: { default: null, type: cc.Node, }, lb_bulletCount: { default: null, type: cc.Label, }, lb_bulletCount2: { default: null, type: cc.Label, }, sp_hat: { default: null, type: cc.Sprite, }, sp_cloth: { default: null, type: cc.Sprite, }, sp_bag: { default: null, type: cc.Sprite, }, lb_view: { default: null, type: cc.Label, }, lb_alive: { default: null, type: cc.Label, }, lb_kill: { default: null, type: cc.Label, }, nd_map: { default: null, type: cc.Node, }, nd_mapMy: { default: null, type: cc.Node, }, nd_line: { default: null, type: cc.Node, }, nd_safeMak: { default: null, type: cc.Node, }, lb_tips: { default: null, type: cc.Label, }, nd_mapAll: { default: null, type: cc.Node, }, nd_mapback: { default: null, type: cc.Node, }, nd_mapback2: { default: null, type: cc.Node, }, nd_sea: { default: null, type: cc.Node, }, ////setting nd_setting: { default: null, type: cc.Node, }, nd_lock1: { default: null, type: cc.Node, }, nd_lock2: { default: null, type: cc.Node, }, tg_sound: { default: null, type: cc.Toggle, }, tg_shake: { default: null, type: cc.Toggle, }, tg_heal: { default: null, type: cc.Toggle, }, nd_emote: { default: null, type: cc.Node, }, nd_plane: { default: null, type: cc.Node, }, nd_mapdrop: { default: null, type: cc.Node, }, nd_info: { default: null, type: cc.Node, }, pbover: { default: null, type: cc.Prefab, }, lb_time: { default: null, type: cc.Label, }, hpteam: { default: null, type: cc.Prefab, }, nd_team: { default: null, type: cc.Node, }, nd_label: { default: null, type: cc.Node, }, teamarrow: { default: null, type: cc.Prefab, }, lb_others: { default: [], type: cc.Label, }, // pr_time:{ // default: null, // type: cc.ProgressBar, // }, // pr_def:{ // default: null, // type: cc.ProgressBar, // }, nd_hangxian: { default: null, type: cc.Node, }, // pr_san:{ // default: null, // type: cc.ProgressBar, // }, btn_voice: { default: null, type: cc.Node, }, btn_voiceTeam: { default: null, type: cc.Node, }, // sp_back2:{ // default:null, // type: cc.Sprite, // }, ndIcons: { default: [], type: cc.Node, }, pb_message: { default: null, type: cc.Prefab, }, btn_watchback: { default: null, type: cc.Node, }, nd_tips: { default: null, type: cc.Node, }, pb_tip: { default: null, type: cc.Prefab, }, pb_kill: { default: null, type: cc.Prefab, }, nd_wait: { default: null, type: cc.Node, }, lb_wait: { default: null, type: cc.Label, }, lb_321: { default: null, type: cc.Label, }, nd_warning: { default: null, type: cc.Node, }, btn_reload: { default: null, type: cc.Node, }, nd_redwaring: { default: null, type: cc.Node, }, nd_fred: { default: null, type: cc.Node, }, nd_gastip: { default: null, type: cc.Node, }, pbrevive: { default: null, type: cc.Prefab, }, mapnode: { default: null, type: cc.Node, }, nd_sea2: { default: null, type: cc.Node, }, nd_gas: { default: null, type: cc.Node, }, nd_get: { default: null, type: cc.Node, }, lb_wname: { default: null, type: cc.Label, }, btn_save: { default: null, type: cc.Node, }, nd_offtank: { default: null, type: cc.Node, }, nd_reload: { default: null, type: cc.Node, }, lb_timereload: { default: null, type: cc.Label, }, pr_reload: { default: null, type: cc.ProgressBar, }, lb_reloaddes: { default: null, type: cc.Label, }, pr_skill: { default: null, type: cc.ProgressBar, }, pr_skill2: { default: null, type: cc.ProgressBar, }, nd_lowhp: { default: null, type: cc.Node, }, nd_lowyao1: { default: null, type: cc.Node, }, nd_lowyao2: { default: null, type: cc.Node, }, nd_fake: { default: null, type: cc.Node, }, // pb_god:{ // default:null, // type: cc.Prefab, // }, btn_god: { default: null, type: cc.Node, }, ani_god: { default: null, type: cc.Animation, }, pb_newbie1: { default: null, type: cc.Prefab, }, pb_newbiebattle1: { default: null, type: cc.Prefab, }, nd_buttom: { default: null, type: cc.Node, }, nds_zombiehide: { default: [], type: cc.Node, }, pbrevive2: { default: null, type: cc.Prefab, }, lb_alivepeople: { default: null, type: cc.Label, }, lb_alivezombie: { default: null, type: cc.Label, }, nds_zombiemodehide: { default: [], type: cc.Node, }, nds_zombiemodeshow: { default: [], type: cc.Node, }, sp_skill: { default: null, type: cc.Sprite, }, sp_skill2: { default: null, type: cc.Sprite, }, pbover2: { default: null, type: cc.Prefab, }, sp_raceicon: { default: null, type: cc.Sprite, }, nd_racetip: { default: null, type: cc.Node, }, lb_racetip: { default: null, type: cc.Label, }, pb_fuckbox: { default: null, type: cc.Prefab, }, pbover3: { default: null, type: cc.Prefab, }, btn_san: { default: null, type: cc.Node, }, nd_boomlist: { default: null, type: cc.Node, }, btn_boom: { default: null, type: cc.Node, }, ndmaxskill: { default: null, type: cc.Node, }, lb_skill1: { default: null, type: cc.Label, }, lb_skill2: { default: null, type: cc.Label, }, pr_skillcount: { default: null, type: cc.ProgressBar, }, nd_choseyao: { default: null, type: cc.Node, }, sp_yao: { default: null, type: cc.Sprite, }, lb_yaocount: { default: null, type: cc.Label, }, btn_emote: { default: null, type: cc.Node, }, nd_closeall: { default: null, type: cc.Node, }, nd_tankhidenodes: { default: [], type: cc.Node, }, sp_shotpoint: { default: null, type: cc.Sprite, }, nd_fenduan: { default: null, type: cc.Node, }, nd_efftioasna: { default: null, type: cc.Node, }, nd_kongxi: { default: null, type: cc.Node, }, nd_you: { default: null, type: cc.Node, }, pr_you: { default: null, type: cc.ProgressBar, }, btn_yinni: { default: null, type: cc.Node, }, btn_name: { default: null, type: cc.Label, }, nd_quxiao: { default: null, type: cc.Node, }, jijiabullet: { default: null, type: cc.Label, }, sp_btnicon: { default: null, type: cc.Sprite, }, btn_driver: { default: [], type: cc.Node, }, lb_cd1: { default: null, type: cc.Label, }, lb_cd2: { default: null, type: cc.Label, }, nd_sound: { default: null, type: cc.Node, }, nd_jinyin: { default: null, type: cc.Node, }, nd_jinyin2: { default: null, type: cc.Node, }, pbitemarrow: { default: null, type: cc.Prefab, }, btn_xiaqian: { default: null, type: cc.Node, }, nd_donghua: { default: null, type: cc.Node, }, }, onclickxiaqian() { cc.gameMgr.player.pctrl.doxiaqian(); }, refreshAlive(msg) { this.lb_alive.string = msg.alive_count; this.alive_count = msg.alive_count; if (this.kill_count < msg.kill_count) { this.kill_count = msg.kill_count; this.lb_kill.string = this.kill_count; this.killPeople(this.kill_count); } if (msg.alive_count <= 1 && !battlenet.newbiemode) { this.bugprotect = true; this.bugtime = 0; } if (battlenet.gamemode == 1) { this.lb_alivepeople.string = msg.human_num; this.lb_alivezombie.string = msg.zombie_num; } }, updateGameTime(c) { var lt = Math.ceil(c / 1000); var m = Math.floor(lt / 60); var s = lt % 60; if (s < 10) { s = '0' + s; } this.lb_time.string = cc.language.stringformat('shengyushijian') + m + ':' + s; }, onclickdriver(v1, v2) { cc.gameMgr.player.pctrl.switch_seat = Number(v2); }, callgod() { // if(this.selfPlayer){ // if(this.selfPlayer.isdead()||this.selfPlayer.isdown){ // return // } // } // if(!this.godnode){ // this.godnode = cc.instantiate(this.pb_god) // this.node.addChild( this.godnode ) // } // this.godnode.getComponent('gamegodmode').initdata() // this.godnode.active = true }, opencloseTeamVoice(v) { if (v.isChecked) { // wxvoice.closeTeamVoice(); } else { // wxvoice.openTeamVoice(); } }, callboomlist() { for (var i = 3; i < cc.gameMgr.player.pctrl.guns.length; i++) { if (cc.gameMgr.player.pctrl.guns[i] > 0) { this.nd_boomlist.active = true; this.nd_closeall.active = true; break; } } }, callyaolist() { for (var i = 0; i < cc.gameMgr.player.pctrl.yaoArr.length; i++) { if (cc.gameMgr.player.pctrl.yaoArr[i] > 0) { this.nd_choseyao.active = true; this.nd_closeall.active = true; break; } } }, // LIFE-CYCLE CALLBACKS: start() { window.firstgun = null; window.secondgun = null; this.nd_efftioasna.active = false; for (var i = 0; i < 4; i++) { this.btn_driver[i].active = false; } this.lb_cd1.string = ''; this.lb_cd2.string = ''; this.nd_sound.active = false; this.nd_jinyin.active = false; this.nd_jinyin2.active = false; this.nd_choseyao.active = false; this.pr_skillcount.progress = 0; this.ndmaxskill.active = false; this.lb_skill1.string = ''; this.lb_skill2.string = ''; this.nd_boomlist.active = false; this.nd_kongxi.active = false; this.choseyaoidx = 0; this.preidx = 0; this.kongxitime = 0; this.nd_you.active = false; this.btn_yinni.active = false; this.nd_quxiao.active = false; if (!battlenet.newbiemode) { } if (battlenet.gamemode == 1) { for (var i = 0; i < this.nds_zombiemodehide.length; i++) { this.nds_zombiemodehide[i].active = false; } for (var i = 0; i < this.nds_zombiemodeshow.length; i++) { this.nds_zombiemodeshow[i].active = true; } } else { for (var i = 0; i < this.nds_zombiemodehide.length; i++) { this.nds_zombiemodehide[i].active = true; } for (var i = 0; i < this.nds_zombiemodeshow.length; i++) { this.nds_zombiemodeshow[i].active = false; } } this.nd_racetip.active = false; // this.safebili = Number(gameConfig.parameterConfig['lower_hp_notice'].param_value) / 100 this.stime = 10; this.etime = 2; if ( Main.config.mainConfig.blackTech && Main.config.mainConfig.readybanner_switch ) { playerData.bannerflag = true; SDKManage.banner(6); } this.savemask = this.mask_hp.width; this.huaweiopt = 0; cc.gameMgr.playbgm('gamestart'); this.lb_alive.string = battlenet.AliveCount; this.kill_count = 0; this.nd_hangxian.active = false; this.time2 = 0; this.alive_count = 0; this.ndIcons.push(this.sp_hat.node); this.ndIcons.push(this.sp_cloth.node); this.ndIcons.push(this.sp_bag.node); this.btn_watchback.active = false; this.bugprotect = false; this.bugtime = 0; this.teamarrnode = new cc.Node(); this.node.addChild(this.teamarrnode); this.refreshTank(battlenet.tankarr); this.nd_sea.zIndex = -2; cc.uiHelper.resetpos(); this.nd_offtank.active = false; this.mapnode.opacity = 160; this.btn_god.active = false; this.daojishi = 0; this.daojishistr = ''; this.btn_san.active = false; if (cc.pcmode) { this.nd_boomlist.active = true; this.nd_choseyao.active = true; } }, readd(arr) { // var pos1 = Human.humanArr[i].displays[0].parent.convertToWorldSpaceAR(Human.humanArr[i].displays[0].getPosition()); // var pos2 = this.flagarr[i].parent.convertToNodeSpaceAR(pos1); for (var i = 0; i < arr.length; i++) { let pos1 = arr[i].node.parent.convertToWorldSpaceAR( arr[i].node.getPosition() ); let pos2 = this.nd_label.convertToNodeSpaceAR(pos1); var scale = arr[i].node.scale * arr[i].node.parent.scale; arr[i].node.removeFromParent(false); this.nd_label.addChild(arr[i].node); arr[i].node.setPosition(pos2); arr[i].node.scale = scale; } }, dodrawCall() { if (battlenet.newbiemode) { return; } var arr = [this.lb_bulletCount, this.lb_bulletCount2, this.lb_tips]; this.readd(arr); this.readd(this.lb_others); }, test() { cc.gameMgr.resetGame(); this.reset(); }, netGameOver(res) { if (this.overlayer) { this.overlayer.getComponent('GameOverUINew').dogameover(res); return; } cc.gameMgr.targetView = gameConfig.viewScale[0]; this.onGetGlass(0); var pbove = battlenet.gamemode == 1 ? this.pbover2 : this.pbover; var scpname = battlenet.gamemode == 1 ? 'GameOverUIZombie' : 'GameOverUINew'; if (!this.overlayer) { this.overlayer = cc.instantiate(pbove); this.overlayer.zIndex = 999; this.node.addChild(this.overlayer); SDKManage.logEvent('battle_over', battlenet.gamemode); // cc.gameMgr.playSound("gameover") } if (this.messageBox) { this.messageBox.destroy(); this.messageBox = null; } this.nd_emote.active = false; this.nd_fake.active = false; this.nd_setting.active = false; this.btn_watchback.active = false; //cc.gameMgr.game_over = res // if(this.ndrevive){ // this.ndrevive.active = false // } if (res.game_over) { this.closeSocketEmit(); } this.overlayer.active = true; if (this.floweMode == false) { this.clickMap(); } this.bugprotect = false; this.isfirstover = true; var teammemberarr = []; for (var i = 0; i < res.team_data.length; i++) { var onep = res.team_data[i]; if (SDKManage.ChannelId != 6000) { if ( onep.account_id != '' && onep.account_id.indexOf('6000_') == 0 ) { onep.account_id = ''; } } var tmp = { name: onep.name, hair: 0, cloth: 0, hat: 0, haircolot: 0, isdead: onep.dead, account_id: onep.account_id, vip_lv: onep.vip_lv, head: onep.head, avatar_url: onep.avatar_url, }; if (cc.gameMgr.objMap[onep.player_id]) { var sarr = cc.gameMgr.objMap[onep.player_id].pctrl.skinarr; tmp.hair = sarr[0]; tmp.cloth = sarr[1]; tmp.hat = sarr[2]; tmp.haircolot = sarr[3]; } teammemberarr.push(tmp); } this.overlayer .getComponent(scpname) .setdata( res, cc.gameMgr.player.pctrl.fakearr, teammemberarr, this.iskillself ); playerData.bannerflag = false; wxvoice.stopGameRecorder(); }, // callOver(){ // this.overlayer.active = true // }, startTeamTalk(res) { if (this.selfPlayer && this.selfPlayer.teamMembers.length == 0) { return; } this.nd_sound.active = true; window.voiceSDK.joinRoom( cc.gameMgr.playeruuid, cc.gameMgr.roomid + this.selfPlayer.teamid ); }, onclickvoice() { this.nd_jinyin.active = !this.nd_jinyin.active; if (this.nd_jinyin.active) { window.voiceSDK.closeSpeaker(); } else { window.voiceSDK.openSpeaker(); } }, closeallvoice() { this.nd_jinyin2.active = !this.nd_jinyin2.active; cc.Notifier.emit('closeallvoice', this.nd_jinyin2.active); }, changeTeamMode() { this.btn_voice.active = false; this.btn_voiceTeam.active = true; }, dostart() { this.canstart = true; if (cc.gameMgr.player) { this.selfPlayer = cc.gameMgr.player.getComponent('playerCtrl'); } for (var i = 0; i < this.btn_guns.length; i++) { this.btn_guns[i] .getComponent('btnEquip') .setdata(this.selfPlayer, i); } this.btn_boom.getComponent('btnEquipBoom').setdata(this.selfPlayer); this.refreshItem(); this.floweMode = true; if (cc.gameMgr.battlecount == 1) { // var newbiearr = cc.instantiate(this.pb_newbie1) // this.node.addChild(newbiearr) // newbiearr.getComponent("newbieposarr").setdata(249,3473) } }, cleanTeam() { for (var i = 0; i < this.teamMembers.length; i++) { this.teamMembers[i].removeFromParent(); } this.teamMembers = []; for (var i = 0; i < this.teamarrowarr.length; i++) { this.teamarrowarr[i].removeFromParent(); } this.teamarrowarr = []; this.teamMemberName = []; this.nd_team.destroyAllChildren(); }, createTeam(teamdata, i) { // for(var i=0;i i; } var self = this; cc.loader.loadRes( 'icons/' + data.model, cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { self.sp_hat.spriteFrame = res; } } ); }, onGeCloth(id) { var startnode = this.sp_cloth.node.getChildByName('nd_star'); if (id == 0) { startnode.active = false; this.sp_cloth.spriteFrame = null; return; } var data = gameConfig.dropItemConfig[id]; startnode.active = true; var starts = startnode.getChildren(); for (var i = 0; i < 3; i++) { starts[i].active = data.equip_lv > i; } var self = this; cc.loader.loadRes( 'icons/' + data.model, cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { self.sp_cloth.spriteFrame = res; } } ); }, onGetBag(id) { var startnode = this.sp_bag.node.getChildByName('nd_star'); if (id == 0) { startnode.active = false; this.sp_bag.spriteFrame = null; return; } var data = gameConfig.dropItemConfig[id]; startnode.active = true; var starts = startnode.getChildren(); for (var i = 0; i < 3; i++) { starts[i].active = data.equip_lv > i; } var self = this; cc.loader.loadRes( 'icons/' + data.model, cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { self.sp_bag.spriteFrame = res; } } ); }, showlb1(str) { this.lbdes = str; }, updateLeftTime(dt) { // if(cc.gameMgr.gasmode==3){ // this.lb_time.string = "" // return // } if (cc.gameMgr.gasmode != 0 && battlenet.gamemode == 1) { return; } if (this.leftTime > 0) { if (!this.inittime) { if (battlenet.timeNow) { var timdDelta = new Date().getTime() - battlenet.timeNow; this.leftTime = this.leftTime - timdDelta / 1000; } if (battlenet.needbox && this.leftTime > 10) { // var baoxiang = cc.instantiate(this.pb_fuckbox) // baoxiang.isbattle = true // this.node.addChild(baoxiang) } this.inittime = true; } this.leftTime -= dt; if (this.leftTime < 0) { this.leftTime = 0; } var lt = Math.ceil(this.leftTime); var m = Math.floor(lt / 60); var s = lt % 60; if (s < 10) { s = '0' + s; } this.lb_time.string = this.lbdes + m + ':' + s; } }, showTimeColor(c) { if (battlenet.gamemode == 1) { return; } if (c) { this.nd_warning.active = false; this.lb_time.node.color = cc.Color.WHITE; this.showlb1(cc.language.stringformat('anquanshijian')); this.nd_redwaring.active = false; } else { this.nd_warning.active = true; this.lb_time.node.color = cc.Color.RED; this.showlb1(cc.language.stringformat('duquanshijian')); this.nd_redwaring.active = true; cc.gameMgr.playSound('waring'); var cb = cc.callFunc(function () { cc.gameMgr.playSound('waring'); }); var cb1 = cc.callFunc(function () { cc.gameMgr.playSound('waring'); }); this.node.runAction( cc.sequence(cc.delayTime(1.5), cb, cc.delayTime(1.5), cb1) ); } }, update(dt) { if (playerData.bannerflag) { if (this.stime > 0) { this.stime -= dt; if (this.stime <= 0) { this.stime = 10; this.etime = 2; SDKManage.banner(6); } } if (this.etime > 0) { this.etime -= dt; if (this.etime <= 0) { this.etime = 0; SDKManage.closebanner(); this.flag = false; } } } else { this.stime = 0; this.etime = 0; } if (this.kongxitime > 0) { this.kongxitime -= dt; if (this.kongxitime <= 0) { this.nd_kongxi.active = false; } } if (!this.hasdodraw) { this.time2 += dt; if (this.time2 > 1) { this.dodrawCall(); this.hasdodraw = true; } } if (!this.canstart) { return; } if (this.voiceTime > 0) { this.voiceTime -= dt; if (this.voiceTime <= 0) { this.endVoice(); } } if (this.tipstime >= 0) { this.tipstime -= dt; this.lb_tips.node.opacity = 255; } else { this.lb_tips.node.opacity = 0; } if (!this.selfPlayer) { return; } if (!cc.gameMgr.watchPlayer) { return; } // this.nd_lowyao1.active = false // this.nd_lowyao2.active = false var hpbili = cc.gameMgr.watchPlayer.pctrl.getHpBar(); if (cc.gameMgr.watchPlayer.pctrl.isdown) { this.nd_lowhp.active = true; } else { this.nd_lowhp.active = false; // if (hpbili < this.safebili) { // this.nd_lowhp.active = true // } else { // this.nd_lowhp.active = false // } } this.mask_hp.width = hpbili * this.savemask; this.nd_mapMy.x = cc.gameMgr.watchPlayer.x * this.bili; this.nd_mapMy.y = cc.gameMgr.watchPlayer.y * this.bili; for (var i = 0; i < this.teamMembers.length; i++) { if (this.teamMembers[i].player.dead) { this.teamMembers[i].opacity = 0; } else { this.teamMembers[i].x = this.teamMembers[i].player.x * this.bili; this.teamMembers[i].y = this.teamMembers[i].player.y * this.bili; this.teamMembers[i].opacity = 255; } } this.nd_line.position = this.nd_mapMy.position; if (this.floweMode) { this.nd_map.x = -this.nd_mapMy.x + 150; this.nd_map.y = -this.nd_mapMy.y + 150; } else { this.nd_map.x = 150; this.nd_map.y = 150; } this.centerVec = cc.gameMgr.centerVec; this.nd_line.rotation = -Math.atan2( this.centerVec.y - cc.gameMgr.watchPlayer.y, this.centerVec.x - cc.gameMgr.watchPlayer.x ) * (180 / Math.PI); var dx = this.centerVec.x - cc.gameMgr.watchPlayer.x; var dy = this.centerVec.y - cc.gameMgr.watchPlayer.y; this.nd_line.width = Math.sqrt(dx * dx + dy * dy) * this.bili; this.nd_gas.rotation = this.nd_line.rotation + 90; if (cc.gameMgr.watchPlayer.pctrl.isSafe()) { this.nd_line.color = cc.Color.GREEN; this.nd_gas.opacity = 0; this.nd_gastip.opacity = 0; } else { this.nd_line.color = cc.Color.RED; if (this.selfPlayer.isdead() == false) { if (cc.gameMgr.duquantime <= 5) { this.nd_gastip.opacity = 255; this.nd_gas.opacity = 255; // if(this.nd_line.rotation>0){ // this.nd_gas.y=-80 // } // else{ // this.nd_gas.y=80 // } } else { this.nd_gastip.opacity = 0; this.nd_gas.opacity = 0; } } } var mscale = cc.gameMgr.nowSafe / cc.gameMgr.halfSize; this.nd_safeMak.width = this.nd_safeMak.height = mscale * this.nd_map.width; if (cc.gameMgr.centerVecTar) { mscale = this.nd_map.width / cc.gameMgr.mapSize; this.nd_safeMak.x = this.nd_map.width / 2 + (cc.gameMgr.centerVecTar.x - cc.gameMgr.halfSize) * mscale; this.nd_safeMak.y = this.nd_map.width / 2 + (cc.gameMgr.centerVecTar.y - cc.gameMgr.halfSize) * mscale; } this.nd_wait.opacity = 0; if (this.daojishi > 0) { this.nd_wait.opacity = 255; this.daojishi -= dt; if (this.nowdaojishi != Math.ceil(this.daojishi)) { this.nowdaojishi = Math.ceil(this.daojishi); this.lb_wait.string = this.daojishistr.replace( '%d', this.nowdaojishi ); } } this.lb_321.node.opacity = 0; var leftt = Math.ceil(this.leftTime); if (cc.gameMgr.gasmode == 0 && leftt > 3) { this.nd_wait.opacity = 255; this.lb_wait.string = cc.language.stringformat('julikaishi', [ leftt, ]); } else if (cc.gameMgr.gasmode == 0 && leftt <= 3) { this.lb_321.node.opacity = 255; if (leftt > 0) { this.lb_321.string = leftt; if (this.soundTime != leftt) { this.soundTime = leftt; if (leftt == 3) { cc.gameMgr.stopbgm(); } cc.gameMgr.playSound('321'); } } else { this.lb_321.node.opacity = 0; } } // if(this.btn_watchback.active==true&&cc.gameMgr.watchPlayer.pctrl.isdead()){ // battlenet.sendWatch() // this.btn_watchback.active==false // } if (this.bugprotect && !this.overlayer) { this.bugtime += dt; if (this.bugtime > 8) { jcgamelog.logdebug('gameover err', battlenet.roomid); cc.gameMgr.huishou(); cc.uiHelper.showLoading(); setTimeout(() => { cc.director.loadScene(gotoScene); }, 1000); this.bugprotect = false; } } //this.ndmaxskill.active = false if (this.selfPlayer.skillcdarr.length > 0) { this.pr_skill.progress = this.selfPlayer.skillcdarr[0].left_time / this.selfPlayer.skillcdarr[0].cd_time; this.pr_skill2.progress = this.selfPlayer.skillcdarr[1].left_time / this.selfPlayer.skillcdarr[1].cd_time; if (this.selfPlayer.skillcdarr[1].curr_times > 0) { this.skilljoy.active = !this.btn_skill.active; } else { this.skilljoy.active = false; } if (this.selfPlayer.skillcdarr[0].left_time > 0) { this.lb_cd1.string = ( this.selfPlayer.skillcdarr[0].left_time / 1000 ).toFixed(1); } else { this.lb_cd1.string = ''; } if (this.selfPlayer.skillcdarr[1].left_time > 0) { this.lb_cd2.string = ( this.selfPlayer.skillcdarr[1].left_time / 1000 ).toFixed(1); } else { this.lb_cd2.string = ''; } } //this.pr_skill.progress = this.selfPlayer.skill_left_time / this.selfPlayer.cd_time }, lateUpdate(dt) { this.updateLeftTime(dt); }, refreshJoy() { var isshow = this.movejoy.getComponent('Joystick').mode; this.nd_lock1.active = isshow; this.nd_lock2.active = !isshow; if (cc.notSound) { this.tg_sound.isChecked = false; } else { this.tg_sound.isChecked = true; } // if (cc.notShake) { // this.tg_shake.isChecked = false // } else { // this.tg_shake.isChecked = true // } // if (cc.notheal) { // this.tg_heal.isChecked = false // } else { // this.tg_heal.isChecked = true // } }, callsetting() { this.nd_setting.active = true; this.refreshJoy(); }, callcontinue() { this.nd_setting.active = false; }, gotohome() { if (this.backing == true) { return; } cc.gameMgr.huishou(); // cc.uiHelper.showLoading(); setTimeout(() => { cc.director.loadScene(gotoScene); }, 1000); //playerData.bee = true this.backing = true; }, callbacktoHome() { if (battlenet.gamemode == 1) { //NetManage.getEquipInfo() battlenet.sendLeave(); return; } if (battlenet.newbiemode) { this.gotohome(); return; } if (!this.overlayer) { if (cc.gameMgr.gameStart) { if (!this.selfPlayer.isdead()) { this.selfPlayer.killSelf(); this.iskillself = true; } else { battlenet.sendGameOver(); } } else { if (Number(playerData.game_times) < cc.newgames) { return; } SDKManage.logEvent( 'ready_gameset_battle_left', 'leave game' ); battlenet.sendLeave(); } } else { this.gotohome(); } this.nd_setting.active = false; }, calljoy() { var scp = this.movejoy.getComponent('Joystick'); scp.mode = !scp.mode; cc.joyMode = scp.mode; this.refreshJoy(); }, callshake(res) { // cc.notShake = !res.isChecked // if (this.selfPlayer) { // this.selfPlayer.changeshotmode() // } }, callsound(res) { cc.notSound = !res.isChecked; wxvoice.xiuzhengbgm(); }, callautoheal(res) { // cc.notheal = !res.isChecked }, // clickemote() { // this.nd_emote.active = false // }, clickfake() { this.nd_fake.active = false; }, emotestart(event) { this._touchLocation = event.getLocation(); this.callemote(); this.showemotechose(0); }, emoteend() { if (!this.nd_emote.active) { return; } this.nd_emote.active = false; this.onclickEmote(null, this.nowemotidx); }, emotemove(event) { if (!this.nd_emote.active) { return; } var nowpos = event.getLocation(); var _angle = Math.atan2( this._touchLocation.y - nowpos.y, this._touchLocation.x - nowpos.x ) * (180 / Math.PI) + 180; _angle = _angle - 90; if (_angle < 0) { _angle += 360; } var nowaidx = Math.floor(_angle / 30); if (nowaidx != this.nowemotidx) { this.showemotechose(nowaidx); } //270-210 0 }, showemotechose(idx) { if (idx > this.maxidx) { idx = this.preidx; } this.nowemotidx = idx; this.preidx = idx; for (var i = 0; i < this.emotendarr.length; i++) { this.emotendarr[i].active = false; } this.emotendarr[idx].active = true; }, callemote() { if (!this.selfPlayer) { return; } if (this.selfPlayer.isdead()) { return; } if (this.selfPlayer.emote.length == 0) { return; } var self = this; if (!this.initemote) { this.emotendarr = []; this.initemote = true; this.maxidx = 0; var childs = this.nd_emote.getChildren(); for (var i = 0; i < 6; i++) { this.emotendarr.push(childs[i].getChildByName('chose_fan30')); if (i >= this.selfPlayer.emote.length) { // childs[i].active = false continue; } this.maxidx = i; let tex = baseconfig.emoteConfig[this.selfPlayer.emote[i]]; let nd = new cc.Node(); let sprite = nd.addComponent(cc.Sprite); cc.loader.loadRes( 'textures/emote/' + tex, cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { sprite.spriteFrame = res; sprite.sizeMode = 2; sprite.trim = false; } } ); // nd.position = childs[i].position nd.rotation = -childs[i].rotation; nd.scale = 0.7; childs[i].addChild(nd); } } this.nd_emote.active = true; }, onclickEmote(a, b) { if (this.selfPlayer.isdead()) { return; } this.nd_emote.active = false; this.selfPlayer.showEmoteNet(Number(b)); //cc.gameMgr.aridorp() }, aridorp() { this.nd_mapdrop.x = cc.gameMgr.aripos.x * this.bili; this.nd_mapdrop.y = cc.gameMgr.aripos.y * this.bili; this.nd_mapdrop.active = true; this.planefly(); if (!battlenet.newbiemode) { if (!this.airuiarrow) { var nd = cc.instantiate(this.pbitemarrow); nd.zIndex = -1; this.teamarrnode.addChild(nd); this.airuiarrow = nd; } this.airuiarrow .getComponent('itemarrow') .setdata(cc.gameMgr.aripos.x, cc.gameMgr.aripos.y, true); } }, planefly() { this.nd_plane.active = true; this.nd_plane.position = cc.v2(705, -531); var self = this; var cb = cc.callFunc(function () { self.nd_plane.active = false; }); this.nd_plane.stopAllActions(); this.nd_plane.runAction( cc.sequence(cc.moveTo(3, cc.v2(-780, 588)), cb) ); }, planeflytiaosan() { this.nd_planesan = cc.find('Canvas/planefly'); this.nd_planesan.zIndex = 2; this.nd_planesan.active = true; this.nd_planesan.position = cc.v2(-550, -508); // var self = this; var cb = cc.callFunc(function () { self.nd_planesan.active = false; }); this.nd_planesan.stopAllActions(); this.nd_planesan.runAction( cc.sequence(cc.moveTo(4, cc.v2(903, 720)), cb) ); // }, netClose() { this.showtips(cc.language.stringformat('duankailianjie')); var cb = cc.callFunc(function () { cc.gameMgr.huishou(); cc.uiHelper.showLoading(); setTimeout(() => { cc.director.loadScene(gotoScene); }, 1000); }); this.node.runAction(cc.sequence(cc.delayTime(2), cb)); }, onClickSan() { this.selfPlayer.onClickTiaoSan(); }, drawPlaneLine(v) { this.hasPalneLine = true; var sp = cc.v2(v.start_point.x, v.start_point.y); var ep = cc.v2(v.end_point.x, v.end_point.y); // var sp = cc.v2(7000,7000) // var ep = cc.v2(700,800) var dir = cc.v2(ep.x - sp.x, ep.y - sp.y); this.nd_hangxian.x = ((sp.x + ep.x) / 2) * this.bili; this.nd_hangxian.y = ((sp.y + ep.y) / 2) * this.bili; this.nd_hangxian.width = Math.sqrt(Math.pow(sp.x - ep.x, 2) + Math.pow(sp.y - ep.y, 2)) * this.bili; this.nd_hangxian.active = true; this.nd_hangxian.rotation = -Math.atan2(dir.y, dir.x) * (180 / Math.PI); return this.nd_hangxian.rotation; }, watchBack() { if (!this.overlayer) { battlenet.sendGameOver(); } else { this.gotohome(); } this.btn_watchback.active = false; }, showbattletip(msg) { let nd; if (battletiparr.length > 0) { nd = battletiparr.pop(); } else { nd = cc.instantiate(this.pb_tip); } // let nd = cc.instantiate(this.pb_tip) nd.getComponent('battletip').setdata(msg); this.nd_tips.addChild(nd); }, huishoubattip(nd) { nd.removeFromParent(false); battletiparr.push(nd); }, createtankPont() { let ppn = new cc.Node(); ppn.zIndex = -2; let sprite = ppn.addComponent(cc.Sprite); var self = this; cc.loader.loadRes( 'textures/uires/maptank', cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { sprite.spriteFrame = res; } } ); ppn.scale = 1.5; this.nd_map.addChild(ppn); this.tankarr.push(ppn); }, createtankui() { var nd = cc.instantiate(this.pbitemarrow); nd.zIndex = -1; this.teamarrnode.addChild(nd); this.tankuiarr.push(nd); }, refreshTank(posarr) { if (!posarr) { return; } if (!this.tankarr) { this.tankarr = []; this.tankuiarr = []; } var delta = posarr.length - this.tankarr.length; for (var i = 0; i < delta; i++) { this.createtankPont(); this.createtankui(); } for (var i = 0; i < this.tankarr.length; i++) { if (i < posarr.length) { this.tankarr[i].active = true; this.tankarr[i].x = posarr[i].pos.x * this.bili; this.tankarr[i].y = posarr[i].pos.y * this.bili; this.tankuiarr[i].active = true; this.tankuiarr[i] .getComponent('itemarrow') .setdata(posarr[i].pos.x, posarr[i].pos.y, false); } else { this.tankarr[i].active = false; this.tankuiarr[i].active = false; } } }, onclickdash() { if (this.selfPlayer) { this.selfPlayer.onClickSkill(0); } }, onclickskill() { if (this.selfPlayer) { this.selfPlayer.onClickSkill(1); } }, onclicksave() { if (this.selfPlayer) { this.selfPlayer.onClickSave(); } }, onclickgetItem() { if (this.selfPlayer) { this.selfPlayer.getItem(); } }, onclickstopitem() { if (this.selfPlayer) { this.selfPlayer.stopItem(); } }, onclickofftank() { if (this.selfPlayer) { this.selfPlayer.offtank(); } }, onclickFake(a, b) { if (this.selfPlayer.isdead()) { return; } this.nd_fake.active = false; this.selfPlayer.showFake(Number(b)); //cc.gameMgr.aridorp() }, callefake() { if (!this.selfPlayer) { return; } if (this.selfPlayer.isdead()) { return; } if (!cc.gameMgr.gameStart) { return; } var self = this; if (!this.initfake) { this.initfake = true; this.fakelabelarr = []; this.fakesparr = []; var childs = this.nd_fake.getChildren(); for (let i = 0; i < 6; i++) { // if (i >= this.selfPlayer.fakearr.length) { // break // } // let tex = gameConfig.dropItemConfig[this.selfPlayer.fakearr[i].id].model let nd = new cc.Node(); let sprite = nd.addComponent(cc.Sprite); // cc.loader.loadRes("icons/" + tex, cc.SpriteFrame, function(err, res) { // if (!err && self.isValid) { // sprite.spriteFrame = res; // sprite.sizeMode = 2 // sprite.trim = false // } // }); nd.rotation = -childs[i].rotation; nd.scale = 0.9 * cc.hdscale; childs[i].addChild(nd); this.fakesparr.push(nd); let bg = new cc.Node(); bg.color = cc.Color.BLACK; bg.opacity = 150; let sprite1 = bg.addComponent(cc.Sprite); cc.loader.loadRes( 'textures/uires/pixi32', cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { sprite1.spriteFrame = res; bg.width = 50; bg.height = 68; } } ); bg.scale = 1 / nd.scale; bg.y = -15 * bg.scale; bg.x = 5 * bg.scale; nd.addChild(bg); let nd2 = new cc.Node(); nd2.scale = 0.4 / nd.scale; nd2.y = -16 * bg.scale; nd2.x = 5 * bg.scale; let lb = nd2.addComponent(cc.Label); this.fakelabelarr.push(lb); nd.addChild(nd2); } } for (let i = 0; i < 6; i++) { if (i < this.selfPlayer.fakearr.length) { this.fakesparr[i].active = true; this.fakelabelarr[i].string = this.selfPlayer.fakearr[i].count; let sprite = this.fakesparr[i].getComponent(cc.Sprite); let tex = gameConfig.dropItemConfig[this.selfPlayer.fakearr[i].id] .model; cc.loader.loadRes( 'icons/' + tex, cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { sprite.spriteFrame = res; sprite.sizeMode = 2; sprite.trim = false; } } ); } else { this.fakesparr[i].active = false; } } this.nd_fake.active = !this.nd_fake.active; }, hidezombienode() { for (var i = this.nds_zombiehide.length - 1; i >= 0; i--) { this.nds_zombiehide[i].active = false; } }, showzombienode() { for (var i = this.nds_zombiehide.length - 1; i >= 0; i--) { this.nds_zombiehide[i].active = true; } }, updateonepos(posdata, needcreate) { var uuid = posdata.obj_uniid; if (!this.zombieposmap[uuid]) { if (!needcreate) { return; } var self = this; let ppn = new cc.Node(); ppn.zIndex = -1; let sprite = ppn.addComponent(cc.Sprite); cc.loader.loadRes( 'textures/uires/mini-player1', cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { sprite.spriteFrame = res; } } ); this.nd_map.addChild(ppn); this.zombieposmap[uuid] = ppn; } var nd = this.zombieposmap[uuid]; nd.x = posdata.pos.x * this.bili; nd.y = posdata.pos.y * this.bili; if (posdata.race == 1) { // nd.color = cc.Color.WHITE; } else { nd.color = cc.Color.RED; } }, zombie_positions(poss) { for (var i = poss.length - 1; i >= 0; i--) { this.updateonepos(poss[i], true); } }, onSMSysPiaoMsg(msg) { cc.uiHelper.showTips(msg.msg, msg.color); }, onSMShowCountdown(msg) { this.nowdaojishi = 0; this.daojishi = msg.countdown; this.daojishistr = msg.msg; }, onchangeskill(res) { this.nd_fenduan; var self = this; var icon1 = skillConfig[res[0].skill_id].skill_icon; var icon2 = skillConfig[res[1].skill_id].skill_icon; var times = skillConfig[res[0].skill_id].max_times; var fnd = this.nd_fenduan.getChildByName('fenduan' + times); if (fnd) { fnd.active = true; } cc.loader.loadRes( 'icons/' + icon1, cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { self.sp_skill.spriteFrame = res; } } ); cc.loader.loadRes( 'icons/' + icon2, cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { self.sp_skill2.spriteFrame = res; } } ); this.use_method = skillConfig[res[1].skill_id].use_method; if (this.use_method >= 2) { this.skilljoy.active = true; } else { this.btn_skill.active = false; } }, touchraceiconstart() { if (!this.sp_raceicon.spriteFrame) { return; } this.nd_racetip.active = true; }, touchraceiconend() { this.nd_racetip.active = false; }, onsp_raceicon(res) { if (!res || !res.skill_icon) { this.sp_raceicon.spriteFrame = null; return; } if (res.des) { this.lb_racetip.string = res.des; } var self = this; cc.loader.loadRes( 'icons/' + res.skill_icon, cc.SpriteFrame, function (err, res) { if (!err && self.isValid) { self.sp_raceicon.spriteFrame = res; } } ); cc.Notifier.emit('jiantingbeidong'); }, newbiewin() { this.overlayer = cc.instantiate(this.pbover3); this.overlayer.zIndex = 999; this.node.addChild(this.overlayer); }, refrehskill(player) { if ( player.skillcdarr[1].curr_times && player.skillcdarr[1].curr_times > 0 ) { this.ndmaxskill.active = true; if ( player.skillcdarr[1].max_times > 1 && player.skillcdarr[1].curr_times > 0 ) { this.lb_skill2.string = player.skillcdarr[1].curr_times; } else { this.lb_skill2.string = ''; } } else { this.ndmaxskill.active = false; this.lb_skill2.string = ''; } if (player.skillcdarr[0].max_times > 1) { if (player.skillcdarr[0].curr_times > 0) { this.lb_skill1.string = player.skillcdarr[0].curr_times; } else { this.lb_skill1.string = ''; } // var nowv = this.pr_skillcount.progress // var tov = player.skillcdarr[0].curr_times / player.skillcdarr[0].max_times // var paction = new cc.ProgressTo() // paction.initWithDuration(0.2,nowv,tov) // this.pr_skillcount.node.runAction(paction) this.pr_skillcount.progress = player.skillcdarr[0].curr_times / player.skillcdarr[0].max_times; } else { this.lb_skill1.string = ''; } }, closeallicon() { this.nd_closeall.active = false; if (!cc.pcmode) { this.nd_choseyao.active = false; this.nd_boomlist.active = false; } }, doofftank() { this.nd_offtank.active = false; for (var i = 0; i < this.nd_tankhidenodes.length; i++) { this.nd_tankhidenodes[i].active = true; } // for (var i = 0; i < 4; i++) { // cc.gameMgr.uic.btn_driver[i].active = false // } this.nd_label.active = true; this.skilljoy.scale = this.btn_skill.scale = 1; this.ndmaxskill.opacity = 255; this.nd_you.active = false; }, doontank() { this.nd_offtank.active = true; for (var i = 0; i < this.nd_tankhidenodes.length; i++) { this.nd_tankhidenodes[i].active = false; } this.nd_label.active = false; this.skilljoy.scale = this.btn_skill.scale = 0; this.ndmaxskill.opacity = 0; this.nd_you.active = true; }, dokongxi(v) { this.nd_kongxi.x = v.pos.x * this.bili; this.nd_kongxi.y = v.pos.y * this.bili; this.nd_kongxi.active = true; this.kongxitime = v.appear_time; }, onclickyinni() { cc.gameMgr.doyinni(); }, onSMGetItemNotify(res) { for (var i = 0; i < res.items.length; i++) { var itemid = res.items[i].key; var eqtype = gameConfig.dropItemConfig[itemid].equip_type; cc.Notifier.emit('uigetitem', { id: itemid, tp: eqtype, }); } }, domove() { var rotarr = [90, 180, 270, 0]; //wasd var temp = []; for (var i = 0; i < 4; i++) { temp[i] = this.keyarr[i]; } if (temp[0] && temp[2]) { temp[0] = false; temp[2] = false; } if (temp[1] && temp[3]) { temp[1] = false; temp[3] = false; } var rot = 0; var count = 0; var canmove = false; for (var i = 0; i < 4; i++) { if (temp[i]) { canmove = true; count++; rot += rotarr[i]; } } if (canmove) { rot /= count; if (temp[2] && temp[3]) { rot = rot + 180; } this.joyMoveBegin(); this.joyMove(rot, 100); } else { this.joyMoveEnd(); } }, onKeyup(event) { switch (event.keyCode) { case cc.macro.KEY.w: this.keyarr[0] = false; break; case cc.macro.KEY.a: this.keyarr[1] = false; break; case cc.macro.KEY.s: this.keyarr[2] = false; break; case cc.macro.KEY.d: this.keyarr[3] = false; break; default: break; } this.domove(); }, onClick56() { this.eatYao({ target: { yaoId: 0, }, }); this.reatYao(); }, onClick57() { this.eatYao({ target: { yaoId: 1, }, }); this.reatYao(); }, onClick48() { this.eatYao({ target: { yaoId: 2, }, }); this.reatYao(); }, onKeydown(event) { console.log(event.keyCode); if (event.keyCode >= 48 && event.keyCode <= 57) { if (event.keyCode >= 49 && event.keyCode <= 55) { var scp = this.btn_guns[event.keyCode - 48].getComponent('btnEquip'); scp._touchStartEvent(); scp._touchEndEvent(); } else if (event.keyCode == 56) { this.eatYao({ target: { yaoId: 0, }, }); this.reatYao(); } else if (event.keyCode == 57) { this.eatYao({ target: { yaoId: 1, }, }); this.reatYao(); } else if (event.keyCode == 48) { this.eatYao({ target: { yaoId: 2, }, }); this.reatYao(); } return; } switch (event.keyCode) { case cc.macro.KEY.w: this.keyarr[0] = true; break; case cc.macro.KEY.a: this.keyarr[1] = true; break; case cc.macro.KEY.s: this.keyarr[2] = true; break; case cc.macro.KEY.d: this.keyarr[3] = true; break; case cc.macro.KEY.q: this.skilldown(); break; case cc.macro.KEY.r: if (this.selfPlayer) { this.selfPlayer.pushBullet(); } break; case cc.macro.KEY.t: break; case cc.macro.KEY.e: if (!this.nd_offtank.active) { this.onclickdash(); } else { this.onclickofftank(); } break; default: break; } this.domove(); }, skilldown() { if (this.use_method >= 2) { if (this.skilljoy.active && !this.selfPlayer.skilling) { this.joySkillMoveBegin({ x: 0, y: 0, }); } } else { this.onclickskill(); } }, _getDistance: function (pos1, pos2) { return Math.sqrt( Math.pow(pos1.x - pos2.x, 2) + Math.pow(pos1.y - pos2.y, 2) ); }, _getAngle: function (point) { this._angle = Math.atan2(point.y, point.x) * (180 / Math.PI); return this._angle; }, mousemove(event) { if (!this.skilljoy.active) { return; } if (this.selfPlayer && this.selfPlayer.skilling) { var pos1 = event.getLocation(); var pos = this.node.convertToNodeSpaceAR(pos1); this.selfPlayer && this.selfPlayer.joySkillMove( this._getAngle(pos), this._getDistance(pos, { x: 0, y: 0, }), this.use_method, pos1 ); } }, touchcancel() { this.selfPlayer && this.selfPlayer.cleanskilltouch(); }, });