2163 lines
56 KiB
JavaScript
2163 lines
56 KiB
JavaScript
// 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 BulletManager = require('bulletManage');
|
|
var EffectManager = require('effectManage');
|
|
var plusresManager = require('plusResManage');
|
|
|
|
var DropManager = require('dropManage');
|
|
var GameLoot = require('gameloot');
|
|
var Utils = require('Utils');
|
|
var gameConfig = require('gameConfig');
|
|
var battlenet = require('battlenetmanage');
|
|
var SDKManage = require('SDKManage');
|
|
var wxVoice = require('wxVoice');
|
|
var quadtree = require('quadtree');
|
|
var Main = require('Main');
|
|
var playerData = require('playerData');
|
|
|
|
var mapconfig = gameConfig.mapConfig;
|
|
var ItemConfig = gameConfig.itemConfig;
|
|
var tileConfig = require('tileConfig');
|
|
|
|
var parpbs = {};
|
|
var breadyFrame = {};
|
|
|
|
var playerpool = [];
|
|
|
|
var tiaosanview = 0.4;
|
|
cc.shadowpy = 80;
|
|
var planedelaytime = 1200;
|
|
var jintou = 1.3;
|
|
var cloudxiaoshitime = 5000;
|
|
cc.budongbili = 2;
|
|
|
|
var btnyinshe = {
|
|
1: {
|
|
name: 'open',
|
|
pic: 'pic_btn1',
|
|
},
|
|
2: {
|
|
name: 'hide',
|
|
pic: 'pic_btn2',
|
|
},
|
|
3: {
|
|
name: 'get out',
|
|
pic: 'pic_btn2',
|
|
},
|
|
};
|
|
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
pbplayer: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
pbmask: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
pbsmoke: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
pbboom: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
pbbreak: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
pbbullet: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
// pbtank: {
|
|
// default: null,
|
|
// type: cc.Prefab,
|
|
// },
|
|
pbui: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
pbuipc: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
// grasspb:{
|
|
// default: null,
|
|
// type: cc.Prefab,
|
|
// },
|
|
|
|
pbbullethit: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
|
|
pbfire: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
|
|
nd_plane: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
pbcar: {
|
|
default: null,
|
|
type: cc.Prefab,
|
|
},
|
|
|
|
shijiao: 1,
|
|
},
|
|
sendVoice(url) {
|
|
battlenet.sendVoice(url);
|
|
},
|
|
playbgm(url) {
|
|
wxVoice.playbgm(url);
|
|
},
|
|
stopbgm() {
|
|
wxVoice.stopbgm();
|
|
},
|
|
playSound: function (url, pos) {
|
|
if (url == null) {
|
|
return;
|
|
}
|
|
if (cc.notSound) {
|
|
return;
|
|
}
|
|
var soundVolume = 1;
|
|
if (this.watchPlayer && pos) {
|
|
var dis =
|
|
Math.pow(this.watchPlayer.x - pos.x, 2) +
|
|
Math.pow(this.watchPlayer.y - pos.y, 2);
|
|
var soundMax = Math.pow(512, 2);
|
|
if (dis > soundMax) {
|
|
return;
|
|
} else {
|
|
soundVolume = 1 - dis / soundMax;
|
|
}
|
|
}
|
|
|
|
wxVoice.playSound(url, soundVolume);
|
|
},
|
|
|
|
huishou() {
|
|
for (let i = this.lootarr.length - 1; i >= 0; i--) {
|
|
let nowloot = this.lootarr[i];
|
|
nowloot.isout = false;
|
|
nowloot.removeFromParent(false);
|
|
this.lootpool.push(nowloot);
|
|
// if (nowloot.istree != 2) {
|
|
// this.lootpool.push(nowloot)
|
|
// } else {
|
|
// this.loottreepool.push(nowloot)
|
|
// }
|
|
}
|
|
},
|
|
|
|
onDestroy() {
|
|
cc.mytimescale = 1;
|
|
this.myTree.clear();
|
|
battlenet.clean();
|
|
cc.gameMgr = null;
|
|
var soundsave = cc.notSound ? 1 : 0;
|
|
try {
|
|
cc.sys.localStorage.setItem('soundsave', soundsave);
|
|
} catch (e) {}
|
|
|
|
// var shakesave = cc.notShake ? 1 : 0
|
|
// try {
|
|
// cc.sys.localStorage.setItem('shakesave2', shakesave);
|
|
// } catch (e) {}
|
|
|
|
var joyMode = cc.joyMode ? '1' : '0';
|
|
try {
|
|
cc.sys.localStorage.setItem('joyMode1', joyMode);
|
|
} catch (e) {}
|
|
|
|
// var heal = cc.notheal ? "1" : "0"
|
|
// try {
|
|
// cc.sys.localStorage.setItem('healsave', heal);
|
|
// } catch (e) {}
|
|
|
|
for (var i = this.housearr.length - 1; i >= 0; i--) {
|
|
this.housearr[i].cell = null;
|
|
this.housearr[i].objChildren.length = 0;
|
|
this.housearr[i].doorChildren.length = 0;
|
|
this.housearr[i].eventChildren.length = 0;
|
|
}
|
|
|
|
this.bulletManager.clean();
|
|
this.effectManager.clean();
|
|
this.dropManager.clean();
|
|
this.objMap = null;
|
|
this.housearr.length = 0;
|
|
this.playerarr.length = 0;
|
|
this.lootarr.length = 0;
|
|
this.doorarr.length = 0;
|
|
|
|
playerpool.length = 0;
|
|
breadyFrame = {};
|
|
|
|
//lootpool.length = 0
|
|
// this.treearr.length=0
|
|
|
|
cc.sys.garbageCollect();
|
|
cc.view.enableRetina(true);
|
|
|
|
cc.Notifier.off('gameshake', this);
|
|
},
|
|
doshake() {
|
|
if (cc.notSound) {
|
|
return;
|
|
}
|
|
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
|
|
wx.vibrateShort();
|
|
}
|
|
},
|
|
commonSet() {
|
|
this.ndhouse.destroyAllChildren();
|
|
this.lootnode.destroyAllChildren();
|
|
this.nditem.destroyAllChildren();
|
|
this.ndplayer.destroyAllChildren();
|
|
this.ndbullet.destroyAllChildren();
|
|
this.ndtree.destroyAllChildren();
|
|
this.ndeff.destroyAllChildren();
|
|
this.ndhouseCell.destroyAllChildren();
|
|
this.tree3node.destroyAllChildren();
|
|
this.targetView = this.viewScale = gameConfig.viewScale[0];
|
|
this.mapview = this.targetView;
|
|
this.map.scale = this.viewScale;
|
|
|
|
this.bulletManager.reset();
|
|
this.effectManager.init();
|
|
this.dropManager.reset();
|
|
|
|
this.housearr = [];
|
|
this.playerarr = [];
|
|
this.cararr = [];
|
|
this.npcarr = [];
|
|
this.lootarr = [];
|
|
this.doorarr = [];
|
|
// this.treearr=[];
|
|
this.canOpendoor = false;
|
|
this.effectManager.effNode = this.ndeff;
|
|
this.bulletManager.bulletNode = this.ndbullet;
|
|
this.dropManager.itemNode = this.ndplayer;
|
|
this.halfSize = this.mapSize / 2;
|
|
this.safeLength = this.halfSize * 2.5;
|
|
this.nowSafe = this.safeLength * 1.5;
|
|
this.centerVec = cc.v2(cc.gameMgr.mapSize / 2, cc.gameMgr.mapSize / 2);
|
|
this.time = 0;
|
|
},
|
|
|
|
resetGameNet() {
|
|
this.commonSet();
|
|
this.objMap = {};
|
|
this.objMap2 = {};
|
|
this.maps = gameConfig.houseConfig;
|
|
},
|
|
|
|
onLoad() {
|
|
this.viewspeed = 2;
|
|
gameConfig.viewScale[0] = jintou;
|
|
this.nd_plane.active = false;
|
|
this.planetime = 0;
|
|
this.nowframe = 0;
|
|
this.lootpool = cc.battleCache.lootpool;
|
|
this.loottreepool = cc.battleCache.loottreepool;
|
|
this.fireag = 4;
|
|
|
|
cc.uiHelper.hideLoading();
|
|
var coul1 = cc.find('Canvas/uicloud1');
|
|
var coul2 = cc.find('Canvas/uicloud2');
|
|
coul1.zIndex = 1;
|
|
coul2.zIndex = 1;
|
|
|
|
coul1.active = false;
|
|
coul2.active = false;
|
|
this.sans = 0;
|
|
this.sanoffy = 0;
|
|
this.fpscount = 0;
|
|
this.tanviewchange = 0;
|
|
this.tiaosantime2 = 0;
|
|
this.fpstotal = 0;
|
|
this.lowcount = 0;
|
|
this.lowfpscount = 0;
|
|
this.lootmap = {};
|
|
|
|
this.viewcd = 0;
|
|
cc.gameMgr = this;
|
|
this.battlecount = battlenet.battlecount;
|
|
this.firstzombie = battlenet.firstzombie;
|
|
this.gamemode = battlenet.gamemode;
|
|
this.roomid = battlenet.roomid;
|
|
if (!this.gamemode) {
|
|
this.gamemode = 0;
|
|
}
|
|
if (this.gamemode == 1) {
|
|
cc.find('Canvas/sky').active = true;
|
|
} else {
|
|
cc.find('Canvas/sky').active = false;
|
|
}
|
|
// this.deltaY = cc.winSize.height / 512 * jizhundy / this.shijiao
|
|
// this.deltaX = jizhundx
|
|
|
|
SDKManage.logEvent('battle_join', this.gamemode);
|
|
|
|
this.huaweiopt = 0;
|
|
var uind;
|
|
|
|
if (cc.pcmode) {
|
|
uind = cc.instantiate(this.pbuipc);
|
|
} else {
|
|
uind = cc.instantiate(this.pbui);
|
|
}
|
|
|
|
this.uic = uind.getComponent('GameUI');
|
|
this.duquantime = 0;
|
|
//cc.view.enableRetina(false)
|
|
//this.nd_gas.active = false
|
|
|
|
this.dostart();
|
|
battlenet.initIng = false;
|
|
var sound = cc.sys.localStorage.getItem('soundsave');
|
|
if (sound == null || sound == '' || sound == 0) {
|
|
cc.notSound = false;
|
|
} else {
|
|
cc.notSound = true;
|
|
}
|
|
|
|
// var shake = cc.sys.localStorage.getItem('shakesave2');
|
|
// if (shake == null || shake == "" || shake == 0) {
|
|
// cc.notShake = false
|
|
// } else {
|
|
// cc.notShake = true
|
|
// }
|
|
cc.notShake = true;
|
|
cc.notheal = true;
|
|
|
|
// var heal = cc.sys.localStorage.getItem('healsave');
|
|
// if (heal == null || heal == "" || heal == "1") {
|
|
// cc.notheal = true
|
|
// } else {
|
|
// cc.notheal = false
|
|
// }
|
|
|
|
this.canStart = false;
|
|
this.gameStart = false;
|
|
|
|
if (battlenet.newbiemode) {
|
|
this.gameStart = true;
|
|
}
|
|
|
|
// if(cc.sys.platform == cc.sys.WECHAT_GAME){
|
|
// wx.getOpenDataContext().postMessage({
|
|
// message: {
|
|
// method :'offsub'
|
|
// }
|
|
// })
|
|
// }
|
|
this.myTree = new quadtree(
|
|
{
|
|
x: 0,
|
|
y: 0,
|
|
width: this.mapSize,
|
|
height: this.mapSize,
|
|
},
|
|
6
|
|
);
|
|
|
|
this.displayercount = 0;
|
|
this.objdatamap = {};
|
|
|
|
this.node.parent.addChild(uind);
|
|
|
|
cc.Notifier.on('gameshake', this, this.gameshake.bind(this));
|
|
},
|
|
gameshake(v) {
|
|
if (this.shakethisframe) {
|
|
return;
|
|
}
|
|
var ac = new cc.ShakeAction();
|
|
ac.initWithDuration(v.time, v.strengthx, v.strengthy);
|
|
this.node.stopAllActions();
|
|
this.node.runAction(ac);
|
|
this.shakethisframe = true;
|
|
},
|
|
doplane() {
|
|
this.nd_plane.active = true;
|
|
this.planeing = true;
|
|
this.nditem.active = true;
|
|
setTimeout(() => {
|
|
this.uic.btn_san.active = true;
|
|
}, planedelaytime);
|
|
|
|
// this.uic.btn_san.active = true
|
|
|
|
this.tanviewchange = 0;
|
|
cc.find('Canvas/uicloud3').active = true;
|
|
cc.gameMgr.playbgm('game_airplane01');
|
|
|
|
this.targetView = tiaosanview;
|
|
this.viewScale = this.targetView;
|
|
this.map.scale = this.viewScale;
|
|
|
|
this.uic.hidenode.active = false;
|
|
this.uic.shownode.active = false;
|
|
this.uic.teamarrnode.active = false;
|
|
// var cloud1 = cc.find("Canvas/uicloud1")
|
|
// var cloud2 = cc.find("Canvas/uicloud2")
|
|
// cloud1.active = true
|
|
// cloud2.active = true
|
|
// cloud1.getComponent(cc.ParticleSystem).resetSystem()
|
|
// cloud2.getComponent(cc.ParticleSystem).resetSystem()
|
|
|
|
// this.scheduleOnce(function() {
|
|
// cloud1.active = false
|
|
// cloud2.active = false
|
|
// }, 3);
|
|
this.uic.startTeamTalk();
|
|
},
|
|
|
|
dotiaosan(v) {
|
|
this.planeing = false;
|
|
this.uic.hidenode.active = true;
|
|
this.uic.shownode.active = true;
|
|
|
|
this.tiaosaning = true;
|
|
|
|
this.mapview =
|
|
gameConfig.viewScale[0] - this.watchPlayer.pctrl.getview() / 1000;
|
|
this._deltabili = this.mapview - tiaosanview;
|
|
this._startbili = tiaosanview;
|
|
this._duration = v;
|
|
this._elapsed = 0;
|
|
|
|
// var time = v*(1-cc.budongbili)
|
|
// this.tanviewchange = (this.mapview - tiaosanview) / time
|
|
// this.tanviewchange *= 0.95
|
|
// this.tiaosantime2 = v*cc.budongbili
|
|
|
|
// this.sans = 0.35 / v
|
|
// this.sans *= 0.95
|
|
// this.sanoffy = cc.shadowpy / v
|
|
//this.sanoffy *= 0.95
|
|
|
|
// for (var i = 0; i < this.playerarr.length; i++) {
|
|
// this.playerarr[i].removeFromParent(false)
|
|
// this.ndplayersan.addChild(this.playerarr[i])
|
|
// }
|
|
cc.gameMgr.playSound('game_parachute');
|
|
cc.gameMgr.playbgm('game_parachute02');
|
|
|
|
this.uic.nd_efftioasna.active = true;
|
|
|
|
var self = this;
|
|
var cb = cc.callFunc(function () {
|
|
self.nd_plane.active = false;
|
|
});
|
|
|
|
this.nd_plane.runAction(cc.sequence(cc.moveTo(2, this.planepos2), cb));
|
|
|
|
setTimeout(() => {
|
|
cc.find('Canvas/uicloud3').active = false;
|
|
}, cloudxiaoshitime);
|
|
|
|
cc.Notifier.emit('dotiaosan');
|
|
},
|
|
endtiaosan() {
|
|
this.uic.nd_efftioasna.active = false;
|
|
this.uic.teamarrnode.active = true;
|
|
this.tiaosaning = false;
|
|
// for (var i = 0; i < this.playerarr.length; i++) {//
|
|
// this.playerarr[i].removeFromParent(false)
|
|
// this.ndplayer.addChild(this.playerarr[i])
|
|
// }
|
|
|
|
cc.gameMgr.playSound('game_parachute03');
|
|
cc.gameMgr.stopbgm();
|
|
},
|
|
|
|
start() {
|
|
//this.timdDelta = new Date().getTime() - battlenet.timeNow
|
|
// this.updateNet(0);
|
|
// this.uic.dostart();
|
|
},
|
|
createBoom(pos, effect) {
|
|
this.effectManager.createBoom(pos, effect);
|
|
},
|
|
|
|
createItemNoCheck(id, pos, data) {
|
|
var item;
|
|
var lootpool;
|
|
var cfgdata = ItemConfig[id];
|
|
// if (cfgdata.is_tree != 2) {
|
|
// lootpool = this.lootpool
|
|
// } else {
|
|
// lootpool = this.loottreepool
|
|
// }
|
|
lootpool = this.lootpool;
|
|
if (lootpool.length > 0) {
|
|
item = lootpool.pop();
|
|
} else {
|
|
item = new GameLoot();
|
|
}
|
|
item.initdata(cfgdata, data, pos);
|
|
item.position = pos;
|
|
if (item.istree == 4) {
|
|
this.ndhouseCell.addChild(item);
|
|
} else if (item.istree == 3) {
|
|
this.tree3node.addChild(item);
|
|
} else if (item.istree != 999) {
|
|
this.lootnode.addChild(item);
|
|
} else {
|
|
this.ndplayersan.addChild(item);
|
|
}
|
|
|
|
this.lootarr.push(item);
|
|
if (item.isdead == false) {
|
|
item.zIndex = -item.y / cc.zscale + item.zplus;
|
|
}
|
|
// if (item.istree == 3) {
|
|
// item.zIndex = -32768
|
|
// }
|
|
|
|
return item;
|
|
|
|
// var item = new GameLoot();
|
|
// if(data.is_door){
|
|
// item.initdoor(id,data);
|
|
// }
|
|
// else{
|
|
// item.initdata(id,data);
|
|
// }
|
|
// item.position = pos;
|
|
|
|
// this.lootnode.addChild(item)
|
|
// if(item.is_door){
|
|
// this.doorarr.push(item)
|
|
// }
|
|
// this.lootarr.push(item);
|
|
// item.zIndex = item.x - item.y
|
|
// return item
|
|
},
|
|
|
|
finddoorObj() {
|
|
if (this.nearDoor.doorObj == null) {
|
|
for (var i = this.doorarr.length - 1; i >= 0; i--) {
|
|
if (
|
|
this.doorarr[i].door_id == this.nearDoor.doorid &&
|
|
this.doorarr[i].door_house_uniid ==
|
|
this.nearDoor.door_house_uniid
|
|
) {
|
|
this.nearDoor.doorObj = this.doorarr[i];
|
|
if (this.doorarr[i].doorOpentime == 0) {
|
|
this.doorarr[i].doorOpentime = 1;
|
|
this.openclose();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
openclose() {
|
|
if (!this.nearDoor) {
|
|
return;
|
|
}
|
|
this.finddoorObj();
|
|
this.nearDoor.doorObj &&
|
|
this.nearDoor.doorObj.isdead == false &&
|
|
this.player.pctrl.pushObj(this.nearDoor.doorObj.objuuid);
|
|
|
|
// this.nearDoor.door1.active = !this.nearDoor.door1.active
|
|
// this.nearDoor.door2.active = !this.nearDoor.door2.active
|
|
// this.nearDoor.door1.img.active = this.nearDoor.door1.active
|
|
// this.nearDoor.door2.img.active = this.nearDoor.door2.active
|
|
},
|
|
createNode() {
|
|
this.ndupmap = new cc.Node();
|
|
this.ndupmap.name = 'ndupmap';
|
|
this.map.addChild(this.ndupmap);
|
|
|
|
this.ndhouse = new cc.Node();
|
|
this.map.addChild(this.ndhouse, 1);
|
|
|
|
this.tree3node = new cc.Node();
|
|
this.map.addChild(this.tree3node, 2);
|
|
|
|
this.nditem = new cc.Node();
|
|
this.map.addChild(this.nditem, 5);
|
|
|
|
this.nditem.active = false;
|
|
|
|
this.ndplayer = new cc.Node();
|
|
this.map.addChild(this.ndplayer, 4);
|
|
|
|
this.ndbullet = new cc.Node();
|
|
this.map.addChild(this.ndbullet, 3);
|
|
|
|
this.ndtree = new cc.Node();
|
|
this.map.addChild(this.ndtree, 6);
|
|
|
|
// var grassnd = cc.instantiate(this.grasspb)
|
|
// grassnd.anchorX = grassnd.anchorY = 0
|
|
// grassnd.x = grassnd.y=this.mapSize/2
|
|
// this.map.addChild(grassnd,7)
|
|
|
|
this.ndeff = new cc.Node();
|
|
this.map.addChild(this.ndeff, 8);
|
|
|
|
this.ndhouseCell = new cc.Node();
|
|
this.map.addChild(this.ndhouseCell, 9);
|
|
|
|
this.ndplayersan = new cc.Node();
|
|
this.map.addChild(this.ndplayersan, 10);
|
|
|
|
// this.newmask = cc.find("Canvas/gasareahack/gasarea")
|
|
// this.maskNode = cc.instantiate(this.pbmask)
|
|
// //this.map.addChild(this.maskNode,9);
|
|
// this.newmask.addChild(this.maskNode,9);
|
|
// this.maskNode.x = this.maskNode.y=this.mapSize/2
|
|
|
|
this.maskNode = cc.instantiate(this.pbmask);
|
|
this.map.addChild(this.maskNode, 11);
|
|
this.maskNode.x = this.maskNode.y = this.mapSize / 2;
|
|
this.maskNode.active = false;
|
|
this.maskNode.getComponent('maskshader').initdata();
|
|
|
|
this.firearr = [];
|
|
for (var i = 0; i < 10; i++) {
|
|
let nd = cc.instantiate(this.pbfire);
|
|
this.maskNode.addChild(nd);
|
|
this.firearr[i] = nd;
|
|
}
|
|
|
|
this.lootnode = this.ndplayer;
|
|
},
|
|
dostart() {
|
|
//cc.macro.ENABLE_TILEDMAP_CULLING= false
|
|
|
|
this.mapId = mapconfig[cc.mapid].map_pic;
|
|
this.mapSize = mapconfig[cc.mapid].map_width;
|
|
this.mapheight = this.mapSize / 32;
|
|
this.map = new cc.Node();
|
|
this.map.zIndex = -1;
|
|
|
|
var colorv = mapconfig[cc.mapid].color;
|
|
if (!colorv) {
|
|
colorv = '#4BCEDF';
|
|
}
|
|
cc.find('Canvas/Main Camera').getComponent(cc.Camera).backgroundColor =
|
|
new cc.color().fromHEX(colorv);
|
|
|
|
//this.map.anchorX = this.map.anchorY=0
|
|
|
|
this.plusMgr = new plusresManager();
|
|
this.plusMgr.init(this.mapId, this.mapSize);
|
|
|
|
this.mapnode = new cc.Node();
|
|
this.mapnode.width = this.mapnode.height = this.mapSize;
|
|
this.mapnode.anchorX = this.mapnode.anchorY = 0;
|
|
this.map.addChild(this.mapnode);
|
|
|
|
//var mapTiled = this.mapnode.addComponent(cc.TiledMap);
|
|
var self = this;
|
|
cc.loader.loadRes(
|
|
'map/map' + this.mapId,
|
|
cc.Prefab,
|
|
function (err, map) {
|
|
if (!err && self.isValid) {
|
|
var mnd = cc.instantiate(map);
|
|
var mapt = mnd.getChildByName('map');
|
|
if (mapt) {
|
|
self.maptile = mapt.getComponent(cc.TiledMap);
|
|
var tilepng = self.maptile.tmxAsset.textureNames[0];
|
|
tilepng = tilepng.slice(0, tilepng.length - 4);
|
|
self.tiledata = tileConfig.maps[tilepng];
|
|
}
|
|
|
|
mnd.rotation = 0;
|
|
self.mapnode.addChild(mnd);
|
|
}
|
|
}
|
|
);
|
|
|
|
this.createNode();
|
|
this.bulletManager = new BulletManager();
|
|
this.effectManager = new EffectManager();
|
|
this.dropManager = new DropManager();
|
|
|
|
this.resetGameNet();
|
|
|
|
this.node.scaleY = this.shijiao;
|
|
this.node2 = new cc.Node();
|
|
// this.node2.rotation = 45
|
|
this.node.addChild(this.node2);
|
|
this.node2.addChild(this.map);
|
|
|
|
if (battlenet.newbiemode) {
|
|
this.nditem.active = true;
|
|
}
|
|
// this.dropManager.createItem(2,cc.v2(100,100))
|
|
// this.dropManager.createItem(1001,cc.v2(300,300))
|
|
},
|
|
getSelfPlayer() {
|
|
return this.player;
|
|
},
|
|
setWatchPlayer(player) {
|
|
// if(battlenet.newbiemode){
|
|
// player.isSelf = true
|
|
// this.player = player
|
|
// }
|
|
if (this.watchPlayer) {
|
|
this.watchPlayer.pctrl.iswatching = false;
|
|
}
|
|
this.watchPlayer = player;
|
|
this.watchPlayer.pctrl.iswatching = true;
|
|
this.watchPlayer.pctrl.refreshHpbar();
|
|
// this.watchPlayer.zIndex =9999;
|
|
},
|
|
loadprefab(dir, name, cb) {
|
|
var self = this;
|
|
if (parpbs[name]) {
|
|
let nd = cc.instantiate(parpbs[name]);
|
|
nd.parname = name;
|
|
cb(nd);
|
|
} else {
|
|
if (breadyFrame[name] == undefined) {
|
|
breadyFrame[name] = [];
|
|
cc.loader.loadRes(dir + name, cc.Prefab, function (err, res) {
|
|
if (!err && self.isValid) {
|
|
parpbs[name] = res;
|
|
let tttt = breadyFrame[name];
|
|
for (let i = tttt.length - 1; i >= 0; i--) {
|
|
let nd = cc.instantiate(res);
|
|
nd.parname = name;
|
|
tttt[i](nd);
|
|
}
|
|
breadyFrame[name] = null;
|
|
}
|
|
});
|
|
}
|
|
|
|
breadyFrame[name].push(cb);
|
|
}
|
|
},
|
|
createHouse(data, x, y, netdata) {
|
|
var node = new cc.Node();
|
|
//var sprite = node.addComponent('cc.Sprite')
|
|
node.x = x;
|
|
node.y = y;
|
|
node.width = data.tilewidth;
|
|
node.height = data.tileheight;
|
|
// node.scale = 2
|
|
this.ndhouse.addChild(node);
|
|
this.housearr.push(node);
|
|
node.objChildren = [];
|
|
node.doorChildren = [];
|
|
node.eventChildren = [];
|
|
node.sizeForView = {
|
|
x: x,
|
|
y: y,
|
|
width: data.tilewidth + 50,
|
|
height: data.tileheight + 50,
|
|
};
|
|
var temp = {};
|
|
for (var i = data.doorObj.length - 1; i >= 0; i--) {
|
|
var p = data.doorObj[i];
|
|
if (!temp[p.id]) {
|
|
temp[p.id] = [];
|
|
}
|
|
temp[p.id][p.type - 1] = data.doorObj[i];
|
|
}
|
|
|
|
for (var k in temp) {
|
|
var p = temp[k][2];
|
|
var child3 = {
|
|
x: p.x - data.tilewidth / 2 + x,
|
|
y: p.y - data.tileheight / 2 + y,
|
|
width: p.width,
|
|
height: p.height,
|
|
building_id: netdata.building_id,
|
|
door_house_uniid: netdata.obj_uniid,
|
|
doorid: Number(k),
|
|
};
|
|
node.eventChildren.push(child3);
|
|
}
|
|
|
|
for (var i = data.staticObj.length - 1; i >= 0; i--) {
|
|
var p = data.staticObj[i];
|
|
var child = {
|
|
x: p.x - data.tilewidth / 2 + x - p.width / 2,
|
|
y: p.y - data.tileheight / 2 + y - p.height / 2,
|
|
width: p.width,
|
|
height: p.height,
|
|
xx: p.x - data.tilewidth / 2 + x,
|
|
yy: p.y - data.tileheight / 2 + y,
|
|
};
|
|
//node.objChildren.push(child)
|
|
|
|
this.myTree.insert(child);
|
|
}
|
|
// sprite.spriteFrame = cc.atlMgr.maphouseatlas.getSpriteFrame(data.picture)
|
|
// sprite.sizeMode =2
|
|
// sprite.trim = false
|
|
|
|
var self = this;
|
|
var cb = function (nd) {
|
|
// nd.rotation = -45
|
|
// nd.scale = 0.5
|
|
node.addChild(nd);
|
|
};
|
|
|
|
var cb2 = function (nd2) {
|
|
// nd2.rotation = -45
|
|
nd2.zIndex = -1;
|
|
nd2.position = node.position;
|
|
nd2.opacity = 100;
|
|
self.ndhouseCell.addChild(nd2);
|
|
node.layer2 = nd2;
|
|
var floor = nd2.getChildByName('floor');
|
|
if (floor) {
|
|
floor.active = false;
|
|
}
|
|
};
|
|
|
|
this.loadprefab('prefabs/mapprefab/', data.picture + '-1', cb);
|
|
this.loadprefab('prefabs/mapprefab/', data.picture + '-1', cb2);
|
|
|
|
var node2 = new cc.Node();
|
|
node2.position = node.position;
|
|
this.ndhouseCell.addChild(node2);
|
|
|
|
var cb3 = function (nd2) {
|
|
// nd2.rotation = -45
|
|
nd2.zIndex = node.width;
|
|
node2.addChild(nd2);
|
|
};
|
|
|
|
this.loadprefab('prefabs/mapprefab/', data.picture + '-2', cb3);
|
|
|
|
// node2.scale = 2
|
|
// var sprite2 = node2.addComponent('cc.Sprite')
|
|
|
|
// sprite2.sizeMode =2
|
|
// sprite2.trim = false
|
|
// sprite2.spriteFrame =cc.atlMgr.maphouseatlas.getSpriteFrame(data.picture+"-2")
|
|
// node2.position = node.position;
|
|
// this.ndhouseCell.addChild(node2);
|
|
|
|
node.cell = node2;
|
|
node.zIndex = -node.width;
|
|
|
|
node.building_id = netdata.building_id;
|
|
node.obj_uniid = netdata.obj_uniid;
|
|
return node;
|
|
},
|
|
checkDoorEvent(player, house) {
|
|
if (player.isSelf == false) {
|
|
return;
|
|
}
|
|
// if(player.pctrl.stateSan>0){
|
|
// return
|
|
// }
|
|
// this.canOpendoor = false;
|
|
for (var i = house.eventChildren.length - 1; i >= 0; i--) {
|
|
if (Utils.hitTestRectangle(player, house.eventChildren[i])) {
|
|
this.nearDoor = house.eventChildren[i];
|
|
this.finddoorObj();
|
|
if (this.nearDoor.doorObj && this.nearDoor.doorObj.isdead) {
|
|
return;
|
|
}
|
|
this.canOpendoor = true;
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
|
|
updateView(dt) {
|
|
// this.targetView = gameConfig.viewScale[0] - this.watchPlayer.pctrl.getview() / 1000
|
|
if (this.planeing) {
|
|
this.targetView = tiaosanview;
|
|
} else if (this.tiaosaning) {
|
|
this._elapsed += dt;
|
|
var newdt = this._elapsed / this._duration;
|
|
newdt = Math.pow(newdt, cc.budongbili);
|
|
newdt = Math.max(0, Math.min(newdt, 1));
|
|
this.targetView = this._startbili + this._deltabili * newdt;
|
|
} else {
|
|
this.targetView =
|
|
gameConfig.viewScale[0] -
|
|
this.watchPlayer.pctrl.getview() / 1000;
|
|
}
|
|
|
|
if (this.viewScale < this.targetView) {
|
|
this.viewcd = 10;
|
|
this.viewScale += dt * this.viewspeed;
|
|
if (this.viewScale > this.targetView) {
|
|
this.viewScale = this.targetView;
|
|
}
|
|
this.map.scale = this.viewScale;
|
|
} else if (this.viewScale > this.targetView) {
|
|
this.viewcd = 10;
|
|
this.viewScale -= dt * this.viewspeed;
|
|
if (this.viewScale < this.targetView) {
|
|
this.viewScale = this.targetView;
|
|
}
|
|
this.map.scale = this.viewScale;
|
|
}
|
|
},
|
|
updateSafe(dt) {
|
|
if (this.gasmode == 2) {
|
|
this.maskNode.position = this.maskNode.position.lerp(
|
|
this.centerVecTar,
|
|
dt * 5
|
|
);
|
|
this.nowSafe =
|
|
this.nowSafe + (this.nowSafeTar - this.nowSafe) * dt * 5;
|
|
return;
|
|
}
|
|
},
|
|
createNetObj(type, uuid, data) {
|
|
var obj;
|
|
switch (type) {
|
|
case 1:
|
|
if (playerpool.length > 0) {
|
|
obj = playerpool.pop();
|
|
} else {
|
|
obj = cc.instantiate(this.pbplayer);
|
|
}
|
|
|
|
// obj = cc.instantiate(this.pbplayer)
|
|
obj.pctrl = obj.getComponent('playerCtrl');
|
|
if (uuid == battlenet.uuid) {
|
|
this.playeruuid = uuid;
|
|
obj.isSelf = true;
|
|
this.player = obj;
|
|
this.setWatchPlayer(obj);
|
|
}
|
|
|
|
obj.x = data.pos.x;
|
|
obj.y = data.pos.y;
|
|
obj.pctrl.netuuid = uuid;
|
|
obj.pctrl.initdata();
|
|
|
|
this.refreshNetData(type, obj, data, true);
|
|
|
|
if (!obj.pctrl.sanmode) {
|
|
this.ndplayer.addChild(obj);
|
|
} else {
|
|
this.ndplayersan.addChild(obj);
|
|
}
|
|
|
|
this.playerarr.push(obj);
|
|
break;
|
|
case 2:
|
|
obj = this.createItemNoCheck(
|
|
data.obstacle_id,
|
|
cc.v2(data.pos.x, data.pos.y),
|
|
data
|
|
);
|
|
obj.sonobj = null;
|
|
obj.isson = false;
|
|
if (obj.build_transparent) {
|
|
var obj2 = this.createItemNoCheck(
|
|
data.obstacle_id,
|
|
cc.v2(data.pos.x, data.pos.y),
|
|
data
|
|
);
|
|
obj2.zIndex = obj.zIndex;
|
|
obj.zIndex = -32767;
|
|
obj2.opacity = 150;
|
|
obj2.objuuid = null;
|
|
obj2.button_name = undefined;
|
|
obj.sonobj = obj2;
|
|
obj2.isson = true;
|
|
}
|
|
|
|
break;
|
|
case 3:
|
|
obj = this.createHouse(
|
|
this.maps[data.building_id + ''],
|
|
data.pos.x,
|
|
data.pos.y,
|
|
data
|
|
);
|
|
break;
|
|
case 5:
|
|
obj = this.dropManager.createItem(
|
|
data.item_id,
|
|
cc.v2(data.pos.x, data.pos.y),
|
|
data
|
|
);
|
|
break;
|
|
case 10:
|
|
obj = cc.instantiate(this.pbcar);
|
|
obj.width = obj.height = 40;
|
|
obj.pctrl = obj.getComponent('npcctrl');
|
|
obj.pctrl.initdata();
|
|
this.ndplayer.addChild(obj);
|
|
this.npcarr.push(obj);
|
|
|
|
break;
|
|
case 11:
|
|
obj = cc.instantiate(this.pbcar);
|
|
obj.pctrl = obj.getComponent('npcctrl');
|
|
obj.pctrl.initdata(true);
|
|
this.ndplayer.addChild(obj);
|
|
this.cararr.push(obj);
|
|
break;
|
|
}
|
|
obj.otype = type;
|
|
obj.objuuid = uuid;
|
|
this.objMap[uuid] = obj;
|
|
return obj;
|
|
},
|
|
|
|
updateHouseView() {
|
|
if (cc.jietumode) {
|
|
return;
|
|
}
|
|
var player = this.watchPlayer;
|
|
player.pctrl.inhouse = false;
|
|
var temphouse = [];
|
|
for (var i = this.housearr.length - 1; i >= 0; i--) {
|
|
if (this.housearr[i].opacity == 0) {
|
|
this.housearr[i].cell.opacity = 0;
|
|
if (this.housearr[i].layer2) {
|
|
this.housearr[i].layer2.active = false;
|
|
}
|
|
continue;
|
|
}
|
|
this.housearr[i].cell.opacity = 255;
|
|
if (this.housearr[i].layer2) {
|
|
this.housearr[i].layer2.active = true;
|
|
}
|
|
if (this.nd_plane.active) {
|
|
continue;
|
|
}
|
|
temphouse.push(this.housearr[i]);
|
|
|
|
if (Utils.hitTestRectangle(player, this.housearr[i].sizeForView)) {
|
|
if (!this.tiaosaning) {
|
|
this.targetView = gameConfig.viewScale[0];
|
|
}
|
|
this.housearr[i].cell.opacity = 0;
|
|
this.checkDoorEvent(player, this.housearr[i]);
|
|
|
|
player.pctrl.inhouse = true;
|
|
//break
|
|
}
|
|
}
|
|
|
|
for (var i = this.playerarr.length - 1; i >= 0; i--) {
|
|
if (
|
|
this.playerarr[i].opacity == 255 &&
|
|
this.playerarr[i] != player
|
|
) {
|
|
this.playerarr[i].pctrl.inhouse = false;
|
|
for (var j = temphouse.length - 1; j >= 0; j--) {
|
|
if (
|
|
Utils.hitTestRectangle(
|
|
this.playerarr[i],
|
|
temphouse[j].sizeForView
|
|
)
|
|
) {
|
|
this.playerarr[i].pctrl.inhouse = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
refreshNetData(type, obj, netdata, isquanliang) {
|
|
if (obj == undefined) {
|
|
return;
|
|
}
|
|
if (type == 1 || type == 10) {
|
|
obj.pctrl.refreshNetData(netdata, isquanliang);
|
|
} else if (type == 2) {
|
|
obj.refreshNetData(netdata, isquanliang);
|
|
} else if (type == 11 && obj.pctrl) {
|
|
obj.pctrl.refreshNetData(netdata, isquanliang);
|
|
}
|
|
},
|
|
dohuawei() {},
|
|
beforehuawei() {},
|
|
dogamestart() {
|
|
this.gameStart = true;
|
|
|
|
// if (this.gameStart == false) {
|
|
// SDKManage.logEvent("battle_start", this.gamemode)
|
|
|
|
// }
|
|
|
|
// this.gameStart = true
|
|
// //playerData.bannerflag = false
|
|
// this.stopbgm()
|
|
|
|
// cc.gameMgr.playSound("gamestart_cloud")
|
|
// cc.gameMgr.playSound("game_airplane02")
|
|
|
|
// var cloud1 = cc.find("Canvas/uicloud1")
|
|
// var cloud2 = cc.find("Canvas/uicloud2")
|
|
// cloud1.active = true
|
|
// cloud2.active = true
|
|
// cloud1.getComponent(cc.ParticleSystem).resetSystem()
|
|
// cloud2.getComponent(cc.ParticleSystem).resetSystem()
|
|
// //this.uic.planeflytiaosan()
|
|
|
|
// this.scheduleOnce(function() {
|
|
// cloud1.active = false
|
|
// cloud2.active = false
|
|
// }, 3);
|
|
},
|
|
updateNet(dt) {
|
|
this.time += dt;
|
|
|
|
var uti = 3;
|
|
var needrefresh = true;
|
|
while (battlenet.frames.length > 0 && uti > 0) {
|
|
uti--;
|
|
var frame = battlenet.frames.shift();
|
|
this.nowframe = frame.frameno;
|
|
|
|
if (frame.alive_count) {
|
|
this.alive_count = frame.alive_count;
|
|
}
|
|
// var uuidtest = {}
|
|
for (var i = frame.full_objects.length - 1; i >= 0; i--) {
|
|
var type = frame.full_objects[i].object_type;
|
|
|
|
var uuid = frame.full_objects[i].obj_uniid;
|
|
// if(uuidtest[uuid]){
|
|
// console.log("9999999999999999999999")
|
|
// }
|
|
// uuidtest[uuid] = true
|
|
var flag = frame.full_objects[i].object_flags;
|
|
|
|
var choseObj = frame.full_objects[i]['union_obj_' + type];
|
|
if (!uuid && choseObj) {
|
|
uuid = choseObj.obj_uniid;
|
|
}
|
|
var needtotree = false;
|
|
// var uuid = choseObj.obj_uniid
|
|
if (type == 2 && !this.objMap2[uuid]) {
|
|
needtotree = true;
|
|
}
|
|
if (flag) {
|
|
if (flag & (1 << 1)) {
|
|
choseObj = this.objMap2[uuid];
|
|
} else if (flag & (1 << 0)) {
|
|
this.objMap2[uuid] = choseObj;
|
|
}
|
|
}
|
|
|
|
needrefresh = true;
|
|
if (!this.objMap[uuid]) {
|
|
var nnobj = this.createNetObj(type, uuid, choseObj);
|
|
if (
|
|
needtotree &&
|
|
nnobj.istree != 2 &&
|
|
nnobj.istree != 3 &&
|
|
nnobj.istree != 4
|
|
) {
|
|
this.lootmap[uuid] = nnobj;
|
|
this.myTree.insert({
|
|
x: nnobj.x - nnobj.width / 2,
|
|
y: nnobj.y - nnobj.height / 2,
|
|
width: nnobj.width,
|
|
height: nnobj.height,
|
|
uuid: uuid,
|
|
});
|
|
}
|
|
if (type == 1) {
|
|
needrefresh = false;
|
|
}
|
|
}
|
|
if (needrefresh) {
|
|
this.refreshNetData(
|
|
type,
|
|
this.objMap[uuid],
|
|
choseObj,
|
|
true
|
|
);
|
|
}
|
|
|
|
if (this.objMap[uuid].isout && this.objMap[uuid].pctrl) {
|
|
this.objMap[uuid].position =
|
|
this.objMap[uuid].pctrl.targetGo;
|
|
}
|
|
this.objMap[uuid].isout = false;
|
|
this.objMap[uuid].lifeTime = 9999;
|
|
if (this.objMap[uuid].sonobj) {
|
|
this.objMap[uuid].sonobj.isout = this.objMap[uuid].isout;
|
|
this.objMap[uuid].sonobj.lifeTime =
|
|
this.objMap[uuid].lifeTime;
|
|
}
|
|
// if (cc.battledebug) {
|
|
// this.objMap[uuid].last_sync_frameno = frame.frameno
|
|
// console.log("view_debug " + (new Date()).toLocaleTimeString() + " fullobj uuid:" + uuid +
|
|
// " type:" + type + " pos:" + this.objMap[uuid].position + ' frameno:' + frame.frameno + ' server_pos:' + choseObj.pos.x + ',' + choseObj.pos.x);
|
|
// }
|
|
}
|
|
|
|
for (var i = frame.shots.length - 1; i >= 0; i--) {
|
|
if (this.objMap[frame.shots[i].player_id]) {
|
|
this.objMap[
|
|
frame.shots[i].player_id
|
|
].pctrl.anishoting = true;
|
|
this.objMap[
|
|
frame.shots[i].player_id
|
|
].pctrl.shootingtime = 0.5;
|
|
|
|
this.objMap[frame.shots[i].player_id].pctrl.doshotevent(
|
|
frame.shots[i]
|
|
);
|
|
}
|
|
}
|
|
for (var i = frame.part_objects.length - 1; i >= 0; i--) {
|
|
var type = frame.part_objects[i].object_type;
|
|
var choseObj = frame.part_objects[i]['union_obj_' + type];
|
|
var uuid = choseObj.obj_uniid;
|
|
if (!this.objMap[uuid]) {
|
|
this.createNetObj(type, uuid, choseObj);
|
|
}
|
|
this.refreshNetData(type, this.objMap[uuid], choseObj, false);
|
|
if (
|
|
this.objMap[uuid] &&
|
|
this.objMap[uuid].isout &&
|
|
this.objMap[uuid].pctrl
|
|
) {
|
|
this.objMap[uuid].position =
|
|
this.objMap[uuid].pctrl.targetGo;
|
|
}
|
|
this.objMap[uuid].isout = false;
|
|
this.objMap[uuid].lifeTime = 9999;
|
|
if (this.objMap[uuid].sonobj) {
|
|
this.objMap[uuid].sonobj.isout = this.objMap[uuid].isout;
|
|
this.objMap[uuid].sonobj.lifeTime =
|
|
this.objMap[uuid].lifeTime;
|
|
}
|
|
|
|
if (cc.battledebug) {
|
|
this.objMap[uuid].last_sync_frameno = frame.frameno;
|
|
this.objMap[uuid].last_part_sync_frameno = frame.frameno;
|
|
}
|
|
}
|
|
// if (cc.battledebug) {
|
|
// console.log(frame.bullets);
|
|
// }
|
|
for (var i = frame.bullets.length - 1; i >= 0; i--) {
|
|
var bdata = frame.bullets[i];
|
|
if (this.objMap[bdata.player_id]) {
|
|
if (cc.battledebug) {
|
|
let isTooFar = false;
|
|
if (
|
|
Math.abs(
|
|
bdata.pos.x - this.objMap[bdata.player_id].x
|
|
) > 200 ||
|
|
Math.abs(
|
|
bdata.pos.y - this.objMap[bdata.player_id].y
|
|
) > 200
|
|
) {
|
|
isTooFar = true;
|
|
}
|
|
let gunner = this.objMap[bdata.player_id];
|
|
let hasBuff24 = gunner.pctrl.getBuffByEffectId(24);
|
|
let hasBuff32 = gunner.pctrl.getBuffByEffectId(32);
|
|
if (isTooFar || hasBuff24 || hasBuff32) {
|
|
console.log(
|
|
'22222222',
|
|
gunner,
|
|
gunner.last_sync_frameno,
|
|
gunner.last_part_sync_frameno,
|
|
frame.frameno,
|
|
isTooFar,
|
|
hasBuff24,
|
|
hasBuff32
|
|
);
|
|
}
|
|
if (gunner.opacity == 0) {
|
|
console.log(
|
|
'33333333',
|
|
gunner,
|
|
gunner.last_sync_frameno,
|
|
gunner.last_part_sync_frameno,
|
|
frame.frameno,
|
|
isTooFar,
|
|
hasBuff24,
|
|
hasBuff32
|
|
);
|
|
}
|
|
if (gunner.isout) {
|
|
console.log('444444');
|
|
}
|
|
}
|
|
this.bulletManager.createBullet(
|
|
bdata.gun_lv,
|
|
gameConfig.dropItemConfig[bdata.gun_id],
|
|
cc.v2(bdata.dir.x, bdata.dir.y),
|
|
cc.v2(bdata.pos.x, bdata.pos.y),
|
|
this.objMap[bdata.player_id].pctrl,
|
|
bdata.fly_distance,
|
|
bdata.player_id,
|
|
bdata
|
|
);
|
|
}
|
|
}
|
|
if (frame.gas_data) {
|
|
//gas_progress
|
|
var gasdata = frame.gas_data;
|
|
this.gasmode = gasdata.mode;
|
|
if (this.gasmode == 0) {
|
|
this.maskNode.active = false;
|
|
var ctime = gasdata.duration; //-this.timdDelta/1000
|
|
|
|
this.uic.leftTime = ctime;
|
|
this.uic.showlb1(cc.language.stringformat('jijiangkaishi'));
|
|
this.uic.showtips(
|
|
cc.language.stringformat('jinrufangjian')
|
|
);
|
|
} else if (this.gasmode == 3) {
|
|
//todo
|
|
//this.uic.leftTime = 0.1
|
|
// this.lootnode.active = false
|
|
// this.ndtree.active = false
|
|
// this.gameStart=true
|
|
this.gameStart = true;
|
|
this.uic.showtips(cc.language.stringformat('youxikaishi'));
|
|
//this.beforehuawei()
|
|
} else {
|
|
var str = '';
|
|
if (this.gasmode == 1) {
|
|
if (this.gameStart == false) {
|
|
SDKManage.logEvent('battle_start', this.gamemode);
|
|
}
|
|
SDKManage.logEvent(
|
|
'circle_' + this.duquantime,
|
|
this.gamemode
|
|
);
|
|
this.gameStart = true;
|
|
this.duquantime++;
|
|
if (battlenet.gamemode != 1) {
|
|
str = cc.language.stringformat('duquankuosan1', [
|
|
gasdata.duration,
|
|
]);
|
|
this.uic.leftTime = gasdata.duration;
|
|
this.uic.showTimeColor(true);
|
|
}
|
|
this.maskNode.active = true;
|
|
this.maskNode.getComponent('maskshader').update(0);
|
|
} else {
|
|
cc.gameMgr.suoquanstart = true;
|
|
str = cc.language.stringformat('duquankuosan2');
|
|
this.uic.leftTime = gasdata.duration;
|
|
this.uic.showTimeColor(false);
|
|
}
|
|
if (battlenet.gamemode != 1) {
|
|
this.uic.showtips(str);
|
|
this.maskNode.active = true;
|
|
var rad = gasdata.rad_new;
|
|
this.centerVec = cc.v2(
|
|
gasdata.pos_new.x,
|
|
gasdata.pos_new.y
|
|
);
|
|
this.centerVecTar = cc.v2(
|
|
gasdata.pos_old.x,
|
|
gasdata.pos_old.y
|
|
);
|
|
this.setSafe(rad / this.halfSize);
|
|
|
|
this.nowSafeTar = this.nowSafe = gasdata.rad_old;
|
|
this.maskNode.x = gasdata.pos_old.x;
|
|
this.maskNode.y = gasdata.pos_old.y;
|
|
}
|
|
}
|
|
}
|
|
if (frame.gas_progress) {
|
|
this.nowSafeTar = frame.gas_progress;
|
|
}
|
|
if (frame.gas_pos_old) {
|
|
this.centerVecTar = cc.v2(
|
|
frame.gas_pos_old.x,
|
|
frame.gas_pos_old.y
|
|
);
|
|
}
|
|
if (
|
|
frame.active_player_id &&
|
|
this.currentWatchid != frame.active_player_id
|
|
) {
|
|
for (var i = this.playerarr.length - 1; i >= 0; i--) {
|
|
if (this.playerarr[i].objuuid == frame.active_player_id) {
|
|
this.setWatchPlayer(this.playerarr[i]);
|
|
break;
|
|
}
|
|
}
|
|
this.currentWatchid = frame.active_player_id;
|
|
}
|
|
|
|
if (frame.active_player_data) {
|
|
this.watchPlayer.pctrl.updateActive(frame.active_player_data);
|
|
}
|
|
|
|
for (var i = frame.explosions.length - 1; i >= 0; i--) {
|
|
this.createBoom(
|
|
cc.v2(frame.explosions[i].pos.x, frame.explosions[i].pos.y),
|
|
frame.explosions[i].effect
|
|
);
|
|
//this.effectManager.createSmoke(cc.v2(frame.explosions[i].pos.x,frame.explosions[i].pos.y))
|
|
}
|
|
for (var i = frame.smokes.length - 1; i >= 0; i--) {
|
|
this.effectManager.createSmoke(
|
|
cc.v2(frame.smokes[i].pos.x, frame.smokes[i].pos.y),
|
|
frame.smokes[i].time_addition / 1000
|
|
);
|
|
}
|
|
|
|
for (var i = frame.emotes.length - 1; i >= 0; i--) {
|
|
this.objMap[frame.emotes[i].player_id].pctrl.showEmote(
|
|
frame.emotes[i].emote_id
|
|
);
|
|
}
|
|
|
|
for (var i = frame.out_objids.length - 1; i >= 0; i--) {
|
|
if (this.objMap[frame.out_objids[i]]) {
|
|
//&&this.objMap[frame.out_objids[i]].pctrl){
|
|
this.objMap[frame.out_objids[i]].lifeTime = 2;
|
|
// this.objMap[frame.out_objids[i]].opacity = 0
|
|
this.objMap[frame.out_objids[i]].isout = true;
|
|
|
|
if (this.objMap[frame.out_objids[i]].sonobj) {
|
|
this.objMap[frame.out_objids[i]].sonobj.isout =
|
|
this.objMap[frame.out_objids[i]].isout;
|
|
this.objMap[frame.out_objids[i]].sonobj.lifeTime =
|
|
this.objMap[frame.out_objids[i]].lifeTime;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (cc.battledebug) {
|
|
// if (frame.out_objids.length > 0) {
|
|
// let out_data = []
|
|
// for (let i = 0; i < frame.out_objids.length; ++i) {
|
|
// let out_obj = {
|
|
// 'uniid': frame.out_objids[i],
|
|
// 'last_sync_frameno': 0,
|
|
// 'last_part_sync_frameno': 0,
|
|
// 'pos': [0, 0],
|
|
// 'matched': false
|
|
// }
|
|
// if (this.objMap[frame.out_objids[i]]) {
|
|
// out_obj['matched'] = true
|
|
// out_obj['last_sync_frameno'] = this.objMap[frame.out_objids[i]].last_sync_frameno
|
|
// out_obj['last_part_sync_frameno'] = this.objMap[frame.out_objids[i]].last_part_sync_frameno
|
|
// out_obj['pos'][0] = this.objMap[frame.out_objids[i]].position.x
|
|
// out_obj['pos'][1] = this.objMap[frame.out_objids[i]].position.y
|
|
// }
|
|
// out_data.push(out_obj);
|
|
// }
|
|
// console.log("view_debug " + (new Date()).toLocaleTimeString() + " out_objs:" + JSON.stringify(out_data))
|
|
// }
|
|
// if (frame.del_objids.length > 0) {
|
|
// console.log("view_debug " + (new Date()).toLocaleTimeString() + " del_objids:" + frame.del_objids)
|
|
// }
|
|
}
|
|
|
|
for (var i = frame.del_objids.length - 1; i >= 0; i--) {
|
|
var did = frame.del_objids[i];
|
|
if (this.objMap[did]) {
|
|
this.objMap[did].needDelete = true;
|
|
if (this.objMap[did].sonobj) {
|
|
this.objMap[did].sonobj.needDelete = true;
|
|
}
|
|
this.objMap[did] = null;
|
|
}
|
|
}
|
|
|
|
if (frame.chged_property_list) {
|
|
for (
|
|
var i = 0, l = frame.chged_property_list.length;
|
|
i < l;
|
|
i++
|
|
) {
|
|
let chobj =
|
|
this.objMap[frame.chged_property_list[i].obj_id];
|
|
if (chobj) {
|
|
chobj.pctrl.chged_property(
|
|
frame.chged_property_list[i]
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (frame.team_data.length > 0) {
|
|
this.player.pctrl.refreshTeam(frame.team_data);
|
|
}
|
|
if (frame.airdrop) {
|
|
this.aridorp(
|
|
cc.v2(frame.airdrop.pos.x, frame.airdrop.pos.y),
|
|
frame.airdrop.appear_time / 1000,
|
|
frame.airdrop.box_id
|
|
);
|
|
}
|
|
if (frame.airraid) {
|
|
this.uic.dokongxi(frame.airraid);
|
|
}
|
|
|
|
if (frame.plane && this.uic.hasPalneLine == false) {
|
|
var rot = this.uic.drawPlaneLine(frame.plane);
|
|
this.planetime = 1;
|
|
var sp = cc.v2(
|
|
frame.plane.start_point.x,
|
|
frame.plane.start_point.y
|
|
);
|
|
var ep = cc.v2(
|
|
frame.plane.end_point.x,
|
|
frame.plane.end_point.y
|
|
);
|
|
var dir = cc.v2(ep.x - sp.x, ep.y - sp.y).normalize();
|
|
|
|
this.map.x = -(sp.x + dir.x * 400) * tiaosanview;
|
|
this.map.y = -(sp.y + dir.y * 400) * tiaosanview;
|
|
|
|
var oldx2 = this.nd_plane.x;
|
|
var oldy2 = this.nd_plane.y;
|
|
|
|
this.nd_plane.active = true;
|
|
this.nd_plane.x -= dir.x * 500;
|
|
this.nd_plane.y -= dir.y * 500;
|
|
|
|
this.planepos2 = cc.v2(
|
|
oldx2 + dir.x * 800,
|
|
oldy2 + dir.y * 800
|
|
);
|
|
this.nd_plane.runAction(cc.moveTo(1, cc.v2(oldx2, oldy2)));
|
|
this.planeing = true;
|
|
}
|
|
|
|
if (frame.chged_buff_list) {
|
|
for (var i = 0, l = frame.chged_buff_list.length; i < l; i++) {
|
|
var cplayer = this.objMap[frame.chged_buff_list[i].obj_id];
|
|
if (cplayer) {
|
|
cplayer.pctrl.changeBuff(frame.chged_buff_list[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (frame.dead_alive_objs) {
|
|
for (var i = 0, l = frame.dead_alive_objs.length; i < l; i++) {
|
|
var onedata = frame.dead_alive_objs[i];
|
|
if (onedata.values[2] == 0) {
|
|
if (this.objMap[onedata.values[0]]) {
|
|
this.objMap[
|
|
onedata.values[0]
|
|
].pctrl.ondeadthisframe(onedata.values[1] / 1000); //ondeadzombie
|
|
}
|
|
} else {
|
|
this.objMap[onedata.values[0]].pctrl.onrevive();
|
|
}
|
|
}
|
|
}
|
|
|
|
if (frame.game_left_time) {
|
|
this.uic.updateGameTime(frame.game_left_time);
|
|
}
|
|
if (frame.object_positions) {
|
|
this.uic.zombie_positions(frame.object_positions);
|
|
}
|
|
|
|
if (frame.play_skill_list) {
|
|
for (var i = 0, l = frame.play_skill_list.length; i < l; i++) {
|
|
this.objMap[
|
|
frame.play_skill_list[i].obj_uniid
|
|
].pctrl.showskill(frame.play_skill_list[i].skill_id);
|
|
}
|
|
}
|
|
|
|
if (frame.del_bullets > 0) {
|
|
this.bulletManager.deletabullets(frame.del_bullets);
|
|
}
|
|
|
|
// if (frame.dead_objects) {
|
|
// for (var i = 0, l = frame.dead_objects.length; i < l; i++) {
|
|
// var onep = this.objMap[frame.dead_objects[i]]
|
|
// if(onep){
|
|
// onep.pctrl.ondeadthisframe()
|
|
// }
|
|
|
|
// }
|
|
// }
|
|
|
|
if (!this.canStart) {
|
|
this.uic.dostart();
|
|
this.canStart = true;
|
|
}
|
|
}
|
|
|
|
if (this.canStart) {
|
|
this.canOpendoor = false;
|
|
|
|
for (var i = this.playerarr.length - 1; i >= 0; i--) {
|
|
if (this.playerarr[i].needDelete) {
|
|
this.playerarr[i].destroy();
|
|
this.playerarr.splice(i, 1);
|
|
} else {
|
|
this.playerarr[i].pctrl.updateNet(dt);
|
|
}
|
|
}
|
|
|
|
for (var i = this.cararr.length - 1; i >= 0; i--) {
|
|
if (this.cararr[i].needDelete) {
|
|
this.cararr[i].pctrl.dodestroy();
|
|
this.cararr.splice(i, 1);
|
|
} else {
|
|
this.cararr[i].pctrl.updateNet(dt);
|
|
}
|
|
}
|
|
|
|
for (var i = this.npcarr.length - 1; i >= 0; i--) {
|
|
if (this.npcarr[i].needDelete) {
|
|
this.npcarr[i].pctrl.dodestroy();
|
|
this.npcarr.splice(i, 1);
|
|
} else {
|
|
this.npcarr[i].pctrl.updateNet(dt);
|
|
}
|
|
}
|
|
|
|
for (let i = this.lootarr.length - 1; i >= 0; i--) {
|
|
if (this.lootarr[i].needDelete) {
|
|
var nowloot = this.lootarr[i];
|
|
nowloot.needDelete = false;
|
|
nowloot.doout();
|
|
nowloot.removeFromParent(false);
|
|
this.lootpool.push(nowloot);
|
|
this.lootarr.splice(i, 1);
|
|
if (nowloot.objuuid) {
|
|
this.objMap[nowloot.objuuid] = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
this.bulletManager.update(
|
|
dt,
|
|
this.housearr,
|
|
this.playerarr,
|
|
this.lootarr
|
|
);
|
|
this.dropManager.update(this.playerarr, dt);
|
|
this.updateView(dt);
|
|
this.displayercount++;
|
|
|
|
if (this.displayercount % 15 == 0) {
|
|
this.updateHouseView();
|
|
this.updatezindex();
|
|
this.updateDisplay(dt * 15);
|
|
}
|
|
|
|
if (this.planetime > 0) {
|
|
this.planetime -= dt;
|
|
// this.map.x = this.lerpv(this.map.x, -this.watchPlayer.x * this.map.scale, 0.72)
|
|
// this.map.y = this.lerpv(this.map.y, -this.watchPlayer.y * this.map.scale, 0.72)
|
|
} else {
|
|
if (this.viewcd > 0) {
|
|
this.viewcd--;
|
|
}
|
|
if (
|
|
this.watchPlayer.pctrl.joyMoveing &&
|
|
!this.watchPlayer.pctrl.shoting &&
|
|
this.viewcd <= 0
|
|
) {
|
|
this.map.x = this.lerpv(
|
|
this.map.x,
|
|
-this.watchPlayer.x * this.map.scale,
|
|
0.72
|
|
);
|
|
this.map.y = this.lerpv(
|
|
this.map.y,
|
|
-this.watchPlayer.y * this.map.scale,
|
|
0.72
|
|
);
|
|
|
|
this.watchPlayer.x = -this.map.x / this.map.scale;
|
|
this.watchPlayer.y = -this.map.y / this.map.scale;
|
|
} else {
|
|
this.map.x = -this.watchPlayer.x * this.map.scale;
|
|
this.map.y = -this.watchPlayer.y * this.map.scale;
|
|
}
|
|
}
|
|
|
|
if (this.time > 0.09) {
|
|
this.player.pctrl.report();
|
|
this.time = 0;
|
|
}
|
|
}
|
|
},
|
|
|
|
lerpv(fromv, tov, ratio) {
|
|
return fromv + (tov - fromv) * ratio;
|
|
},
|
|
|
|
updatezindex() {
|
|
for (var i = this.playerarr.length - 1; i >= 0; i--) {
|
|
if (this.playerarr[i].opacity == 255) {
|
|
this.playerarr[i].zIndex =
|
|
-this.playerarr[i].y / cc.zscale +
|
|
this.playerarr[i].zplus +
|
|
this.playerarr[i].zplus2;
|
|
}
|
|
}
|
|
for (var i = this.cararr.length - 1; i >= 0; i--) {
|
|
if (this.cararr[i].opacity == 255) {
|
|
this.cararr[i].zIndex =
|
|
-this.cararr[i].y / cc.zscale + this.cararr[i].zplus;
|
|
}
|
|
}
|
|
for (var i = this.npcarr.length - 1; i >= 0; i--) {
|
|
if (this.npcarr[i].opacity == 255) {
|
|
this.npcarr[i].zIndex =
|
|
-this.npcarr[i].y / cc.zscale + this.npcarr[i].zplus;
|
|
}
|
|
}
|
|
},
|
|
// update(dt){
|
|
// if(cc.battlepause){
|
|
// battlenet.updateevent(dt)
|
|
// }
|
|
// },
|
|
|
|
lateUpdate(dt) {
|
|
if (cc.battlepause) {
|
|
return;
|
|
}
|
|
var olddt = dt;
|
|
|
|
this.shakethisframe = false;
|
|
// if (cc.highmode) {
|
|
// this.fpscount++;
|
|
// this.fpstotal += dt
|
|
// if (this.fpscount >= 60) {
|
|
// var fps = 1 / this.fpstotal * 60
|
|
// this.fpscount = 0
|
|
// this.fpstotal = 0
|
|
// if (fps < 55) {
|
|
// this.lowcount++;
|
|
// this.lowfpscount += fps
|
|
// if (this.lowcount > 10) {
|
|
// cc.highmode = false
|
|
// var midfps = this.lowfpscount / this.lowcount
|
|
// var fpsxz = 30
|
|
// var fpsv = 0.033
|
|
// if (midfps > 50) {
|
|
// fpsxz = 50
|
|
// fpsv = 0.02
|
|
// } else if (midfps > 40) {
|
|
// fpsxz = 40
|
|
// fpsv = 0.024
|
|
// } else {
|
|
// fpsxz = 30
|
|
// fpsv = 0.033
|
|
// }
|
|
|
|
// cc.game.setFrameRate(fpsxz)
|
|
// cc.mygamedelta = fpsv
|
|
|
|
// }
|
|
// } else {
|
|
// this.lowfpscount = 0
|
|
// this.lowcount = 0
|
|
// }
|
|
|
|
// }
|
|
// }
|
|
// if (cc.mygamedelta / dt > 0.9) {
|
|
// dt = cc.mygamedelta
|
|
// }
|
|
|
|
dt *= cc.mytimescale;
|
|
|
|
this.updateNet(dt);
|
|
this.updateSafe(dt);
|
|
this.effectManager.update(dt);
|
|
for (var i = this.playerarr.length - 1; i >= 0; i--) {
|
|
this.playerarr[i].pctrl.update2(olddt);
|
|
}
|
|
for (var i = this.lootarr.length - 1; i >= 0; i--) {
|
|
this.lootarr[i].update2(olddt);
|
|
}
|
|
|
|
this.maskNode.width = this.maskNode.height =
|
|
(this.nowSafe / this.halfSize) * this.mapSize;
|
|
|
|
this.updategasefire();
|
|
if (this.plusMgr) {
|
|
this.plusMgr.update();
|
|
}
|
|
this.yinidian = this.getNearLoot();
|
|
if (this.yinidian) {
|
|
this.uic.btn_yinni.active = true;
|
|
} else {
|
|
this.uic.btn_yinni.active = false;
|
|
}
|
|
},
|
|
_getDistance(pos1, pos2) {
|
|
return Math.sqrt(
|
|
Math.pow(pos1.x - pos2.x, 2) + Math.pow(pos1.y - pos2.y, 2)
|
|
);
|
|
},
|
|
|
|
getVectorByAngle(angel) {},
|
|
|
|
updategasefire() {
|
|
var distocenter = this._getDistance(
|
|
this.watchPlayer.position,
|
|
this.maskNode.position
|
|
);
|
|
var halfwidth = this.maskNode.width / 2;
|
|
var preag = 4;
|
|
if (halfwidth < 256) {
|
|
preag = 36;
|
|
} else if (halfwidth < 384) {
|
|
preag = 20;
|
|
} else if (halfwidth < 512) {
|
|
preag = 10;
|
|
} else if (halfwidth < 1024) {
|
|
preag = 6;
|
|
}
|
|
if (Math.abs(halfwidth - distocenter) < 512) {
|
|
var startdir = cc.v2(0, 1);
|
|
var sidex = 0;
|
|
var jiajiao =
|
|
Math.atan2(
|
|
this.watchPlayer.x - this.maskNode.x,
|
|
this.watchPlayer.y - this.maskNode.y
|
|
) * 57.3;
|
|
// var preag = this.fireag
|
|
jiajiao = (Math.floor(jiajiao / preag) - 5) * preag;
|
|
var sidx = 0;
|
|
var isz = false;
|
|
for (var i = 0; i < 10; i++) {
|
|
if (this.firearr[i].rotation == jiajiao) {
|
|
sidx = i;
|
|
isz = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!isz) {
|
|
var tsx = Math.floor(
|
|
(this.firearr[0].rotation - jiajiao) / preag
|
|
);
|
|
tsx %= 10;
|
|
if (tsx > 0) {
|
|
sidx = 10 - tsx;
|
|
}
|
|
}
|
|
|
|
for (var i = 0; i < 10; i++) {
|
|
var tarv = Utils.dirRotate(startdir, jiajiao + preag * i);
|
|
var ridx = (i + sidx) % 10;
|
|
this.firearr[ridx].opacity = 255;
|
|
this.firearr[ridx].x = tarv.x * halfwidth;
|
|
this.firearr[ridx].y = tarv.y * halfwidth;
|
|
this.firearr[ridx].rotation = jiajiao + preag * i;
|
|
}
|
|
} else {
|
|
for (var i = 0; i < 10; i++) {
|
|
this.firearr[i].opacity = 0;
|
|
}
|
|
}
|
|
},
|
|
// lateUpdate(dt){
|
|
// this.maskNode.width = this.maskNode.height = this.nowSafe/this.halfSize*this.mapSize
|
|
// },
|
|
updateDisplay(dt) {
|
|
var px = this.watchPlayer.x;
|
|
var py = this.watchPlayer.y;
|
|
var vw = cc.winSize.width / 2 / this.viewScale;
|
|
var vh = cc.winSize.height / 2 / this.viewScale;
|
|
// if (vw < vh) {
|
|
// vw = vh
|
|
// } else {
|
|
// vh = vw
|
|
// }
|
|
var dxx = 0;
|
|
var dyy = 0;
|
|
var maxv = 0;
|
|
var nullopacity = 0;
|
|
if (cc.jietumode || cc.battledebug) {
|
|
nullopacity = 255;
|
|
}
|
|
|
|
for (let i = this.housearr.length - 1; i >= 0; i--) {
|
|
if (
|
|
Math.abs(this.housearr[i].x - px) >
|
|
vw + this.housearr[i].width ||
|
|
Math.abs(this.housearr[i].y - py) > vh + this.housearr[i].height
|
|
) {
|
|
this.housearr[i].opacity = nullopacity;
|
|
} else {
|
|
this.housearr[i].opacity = 255;
|
|
}
|
|
}
|
|
|
|
for (let i = this.lootarr.length - 1; i >= 0; i--) {
|
|
let nowloot = this.lootarr[i];
|
|
if (
|
|
Math.abs(nowloot.x - px) > vw + nowloot.viewWidth + 256 ||
|
|
Math.abs(nowloot.y - py) > vh + nowloot.viewHeight + 256
|
|
) {
|
|
nowloot.active = false;
|
|
} else {
|
|
nowloot.active = true;
|
|
}
|
|
|
|
if (nowloot.active && nowloot.istree == 4) {
|
|
if (Utils.hitTestRectangle(this.watchPlayer, nowloot.viewhit)) {
|
|
nowloot.hidemode = 1;
|
|
} else {
|
|
nowloot.hidemode = 2;
|
|
}
|
|
}
|
|
// if (nowloot.active && nowloot.viewtest) {
|
|
// if (!nowloot.isdead) {
|
|
// if (Utils.hitTestRectangle(this.watchPlayer, nowloot.viewtest)) {
|
|
// if (this.watchPlayer.zIndex < nowloot.zIndex) {
|
|
// nowloot.opacity = 180
|
|
// } else {
|
|
// nowloot.opacity = 255
|
|
// }
|
|
// } else {
|
|
// nowloot.opacity = 255
|
|
// }
|
|
// }
|
|
|
|
// }
|
|
|
|
// dxx = nowloot.x - px
|
|
// dyy = nowloot.y - py
|
|
// if (Math.abs(dxx - dyy) > vh * 1.5 || Math.abs(dxx + dyy) > vw * 1.5) {
|
|
// nowloot.opacity = nullopacity
|
|
// } else {
|
|
// nowloot.opacity = 255
|
|
// }
|
|
|
|
// nowloot.lifeTime-=dt
|
|
if (nowloot.isout) {
|
|
nowloot.lifeTime -= dt;
|
|
if (nowloot.lifeTime < 0) {
|
|
nowloot.isout = false;
|
|
nowloot.doout();
|
|
nowloot.removeFromParent(false);
|
|
this.lootpool.push(nowloot);
|
|
// if (nowloot.istree != 2) {
|
|
// this.lootpool.push(nowloot)
|
|
// } else {
|
|
// this.loottreepool.push(nowloot)
|
|
// }
|
|
this.lootarr.splice(i, 1);
|
|
this.objMap[nowloot.objuuid] = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
for (let i = this.cararr.length - 1; i >= 0; i--) {
|
|
let oneplayer = this.cararr[i];
|
|
if (oneplayer.isout) {
|
|
oneplayer.opacity = 0;
|
|
} else {
|
|
oneplayer.opacity = 255;
|
|
}
|
|
}
|
|
|
|
for (let i = this.npcarr.length - 1; i >= 0; i--) {
|
|
let oneplayer = this.npcarr[i];
|
|
if (oneplayer.isout) {
|
|
oneplayer.pctrl.dodestroy();
|
|
this.npcarr.splice(i, 1);
|
|
this.objMap[oneplayer.objuuid] = null;
|
|
}
|
|
}
|
|
|
|
for (let i = this.playerarr.length - 1; i >= 0; i--) {
|
|
let oneplayer = this.playerarr[i];
|
|
|
|
// oneplayer.lifeTime-=dt
|
|
if (
|
|
oneplayer.isout &&
|
|
this.watchPlayer != oneplayer &&
|
|
this.playerarr[i].pctrl.isMember == false
|
|
) {
|
|
oneplayer.isout = false;
|
|
oneplayer.removeFromParent(false);
|
|
playerpool.push(oneplayer);
|
|
this.playerarr.splice(i, 1);
|
|
this.objMap[oneplayer.objuuid] = null;
|
|
|
|
this.objdatamap[oneplayer.objuuid] = {
|
|
//skin
|
|
currentGun: oneplayer.pctrl.currentGun,
|
|
skin1: oneplayer.pctrl.skinarr[0],
|
|
skin2: oneplayer.pctrl.skinarr[1],
|
|
skin3: oneplayer.pctrl.skinarr[2],
|
|
skin4: oneplayer.pctrl.skinarr[3],
|
|
isdown: oneplayer.pctrl.isdown,
|
|
defhp: oneplayer.pctrl.defhp,
|
|
hp: oneplayer.pctrl.hp,
|
|
maxhp: oneplayer.pctrl.maxhp,
|
|
bagid: oneplayer.pctrl.bagid,
|
|
buffhead: oneplayer.pctrl.buffhead,
|
|
buffbody: oneplayer.pctrl.buffbody,
|
|
buffidarr: [],
|
|
fakeid: oneplayer.pctrl.fakeid,
|
|
fakemode: oneplayer.pctrl.fakemode,
|
|
};
|
|
var barr = this.objdatamap[oneplayer.objuuid].buffidarr;
|
|
for (var ii = 0; ii < oneplayer.pctrl.buffidarr.length; ii++) {
|
|
barr.push(oneplayer.pctrl.buffidarr[ii]);
|
|
}
|
|
|
|
for (var kk in oneplayer.pctrl.buffmap) {
|
|
oneplayer.pctrl.removebuffeff(kk);
|
|
//this.objdatamap[oneplayer.objuuid].buffmap[kk] = true
|
|
}
|
|
oneplayer.pctrl.cleanbuffnode();
|
|
continue;
|
|
}
|
|
|
|
dxx = oneplayer.x - px;
|
|
dyy = oneplayer.y - py;
|
|
if (Math.abs(dxx) > vw || Math.abs(dyy) > vh || oneplayer.isout) {
|
|
oneplayer.active = false;
|
|
} else {
|
|
oneplayer.active = true;
|
|
}
|
|
}
|
|
},
|
|
setSafe(v) {
|
|
v = (this.mapSize / 2) * v;
|
|
this.safeLength = v;
|
|
var b = (this.safeLength / this.mapSize) * 2;
|
|
|
|
cc.gameMgr.uic && cc.gameMgr.uic.refreshSafe(b);
|
|
},
|
|
|
|
aridorp(airpos, airtime, boxid) {
|
|
if (!ItemConfig[boxid].manual_airdrop) {
|
|
this.airstart = true;
|
|
this.aripos = airpos;
|
|
this.uic.aridorp();
|
|
cc.gameMgr.playSound('game_airplane02');
|
|
}
|
|
|
|
var self = this;
|
|
var cb = function (nd) {
|
|
if (self.isValid) {
|
|
nd.zIndex = 9999;
|
|
nd.position = airpos;
|
|
self.ndhouseCell.addChild(nd);
|
|
nd.pname = 'parachute';
|
|
var cb = cc.callFunc(function () {
|
|
self.effectManager.huishouprefab(nd.pname, nd);
|
|
});
|
|
|
|
nd.scale = 2.5;
|
|
nd.stopAllActions();
|
|
nd.opacity = 255;
|
|
nd.runAction(
|
|
cc.sequence(
|
|
cc.scaleTo(airtime + 1, 0.5),
|
|
cc.fadeOut(0.5),
|
|
cb
|
|
)
|
|
);
|
|
}
|
|
};
|
|
this.effectManager.createprefab('parachute', 'prefabs/gameprefab/', cb);
|
|
},
|
|
getlootarr(data) {
|
|
return this.myTree.retrieve(data);
|
|
},
|
|
getNearJZ() {},
|
|
getNearLoot() {
|
|
if (cc.gameMgr.watchPlayer.pctrl.sanmode) {
|
|
return null;
|
|
}
|
|
if (!this.nditem.active) {
|
|
return null;
|
|
}
|
|
|
|
var outarr = [];
|
|
for (let i = this.lootarr.length - 1; i >= 0; i--) {
|
|
let nowloot = this.lootarr[i];
|
|
if (
|
|
nowloot.active &&
|
|
!nowloot.isdead &&
|
|
nowloot.button_name != undefined
|
|
) {
|
|
outarr.push(nowloot);
|
|
}
|
|
}
|
|
if (outarr.length == 0) {
|
|
return null;
|
|
}
|
|
outarr = outarr.sort((a, b) => {
|
|
var disa =
|
|
Math.pow(cc.gameMgr.watchPlayer.x - a.x, 2) +
|
|
Math.pow(cc.gameMgr.watchPlayer.y - a.y, 2);
|
|
var disb =
|
|
Math.pow(cc.gameMgr.watchPlayer.x - b.x, 2) +
|
|
Math.pow(cc.gameMgr.watchPlayer.y - b.y, 2);
|
|
return disa - disb;
|
|
});
|
|
|
|
var hittest2 = {
|
|
x: outarr[0].x,
|
|
y: outarr[0].y,
|
|
width: outarr[0].width + 20,
|
|
height: outarr[0].height + 20,
|
|
};
|
|
|
|
if (Utils.hitTestRectangle(hittest2, cc.gameMgr.watchPlayer)) {
|
|
//this.uic.btn_name.string = outarr[0].button_name
|
|
var btndata = btnyinshe[outarr[0].button_name];
|
|
if (btndata) {
|
|
this.uic.btn_name.string = btndata.name;
|
|
var self = this;
|
|
cc.loader.loadRes(
|
|
'icons/' + btndata.pic,
|
|
cc.SpriteFrame,
|
|
function (err, res) {
|
|
if (!err && self.isValid) {
|
|
self.uic.sp_btnicon.spriteFrame = res;
|
|
}
|
|
}
|
|
);
|
|
//sp_btnicon
|
|
}
|
|
return outarr[0];
|
|
} else {
|
|
return null;
|
|
}
|
|
},
|
|
doyinni() {
|
|
if (this.yinidian.isdead == false) {
|
|
this.player.pctrl.pushObj(this.yinidian.objuuid);
|
|
}
|
|
},
|
|
// createclientsp(outarr,addarr){
|
|
|
|
// },
|
|
});
|