pubgv3/assets/scripts/game/playerCtrl.js
zhuguoqing 62d8fb825e update
2022-05-28 11:15:04 +08:00

4709 lines
116 KiB
JavaScript

var Utils = require('Utils');
var PLAYERLENGTH = 40;
var HALFLENGTH = PLAYERLENGTH / 2;
var gameConfig = require('gameConfig');
var battlenet = require('battlenetmanage');
var baseconfig = require('Config');
var playerconfig = gameConfig.playerConfig;
var skillConfig = gameConfig.skillConfig;
var tileConfig = require('tileConfig');
var myAni = require('myAni');
var SDKManage = require('SDKManage');
var TempV2 = cc.v2(0, 0);
var playerFrame = {};
var playerReadyFrame = {};
var weaponAniArr = ['melee', 'melee', 'gun', 'throw'];
var walkAniArr = ['', 'idle', 'run', 'walk'];
var faceArr = ['face01', 'face10', 'face03', 'face18'];
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
//var AnidirArr = [4,4,3,3,2,2,1,1,0,0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 7, 7, 6, 6, 5, 5]
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
var AnidirArr = [
12, 12, 3, 11, 2, 10, 1, 9, 0, 9, 1, 10, 2, 11, 3, 12, 4, 13, 5, 14, 6, 15,
7, 16, 8, 16, 7, 15, 6, 14, 13, 4,
];
var ani_add_hp_time1 = 6;
var ani_add_hp_time2 = 3;
var ani_add_hp_time3 = 6;
var ani_rescue_time = 3;
var ani_replace_weapon_time = 0.2;
var ani_replace_weapon_time_boom = 0.5;
var ani_dash_time = 0.35;
var houseoffest = 22;
var ani_horse_time = 0.35;
var revive_time = 0.6;
var san_time = 0.4;
var lineopacity = 0;
var maxmovedis = 60;
var slowswitch = 1300;
var longswitch = 2800;
var ani_reload_bullet_time = 1.1;
var ani_reload_bullet_time1 = 2.6;
var ani_reload_bullet_time2 = 5;
var ani_fake_time = 1;
var autoshot = false;
var shotdelta = 25;
var speedweight = 119;
var yinshentouming = 150;
var shotanicd = 0.33333;
var firedis = 31; //
var spinexiuzheng = 28;
var sansacle = 1.2;
var rayhide = 0.3;
var thrwotime = 0.5;
var tbuiup = {
12809: 64,
10086: 100,
};
var shouleipic = 'game_icon2';
var guntppic = {
1: 'game_icon3',
2: 'game_icon1',
3: 'game_icon1',
4: 'game_icon1',
5: 'game_icon1',
6: 'game_icon1',
7: 'game_icon1',
8: 'game_icon1',
};
var fakehidetime = 0.8; //
var fakesmoketime = 0.8; //
var reset2ani = {
replace_weapon2: true,
hero_skill9: true,
hero_skill10: true,
hero_skill9_back: true,
hero_skill10_back: true,
hero_skill11: true,
hero_skill12: true,
hero_skill11_back: true,
hero_skill12_back: true,
hero_skill11_2: true,
hero_skill12_2: true,
hero_skill11_2_back: true,
hero_skill12_2_back: true,
crawl: true,
crawl_back: true,
crawl_idle: true,
crawl_back_idle: true,
replace_weapon3: true,
replace_weapon: true,
replace_weapon3_back: true,
replace_weapon4_back: true,
};
var joytouch = cc.v2();
cc.Class({
extends: cc.Component,
properties: {
nd_display: {
default: null,
type: cc.Node,
},
sp_w1: {
default: null,
type: cc.Sprite,
},
nd_pbgun: {
default: null,
type: cc.Node,
},
nd_shotrff: {
default: null,
type: cc.Node,
},
sp_boom: {
default: null,
type: cc.Node,
},
nd_dead: {
default: null,
type: cc.Node,
},
nd_emote: {
default: null,
type: cc.Node,
},
sp_emote: {
default: null,
type: cc.Sprite,
},
nd_shield: {
default: null,
type: cc.Node,
},
nd_down: {
default: null,
type: cc.Node,
},
pr_hp: {
default: null,
type: cc.ProgressBar,
},
bar_hp: {
default: null,
type: cc.Node,
},
ani_kill2: {
default: null,
type: cc.Animation,
},
nd_member: {
default: null,
type: cc.Node,
},
nd_atkup: {
default: null,
type: cc.Node,
},
// aniweapon:{
// default: null,
// type: cc.Animation,
// },
sp_boom2: {
default: null,
type: cc.Node,
},
nd_ui1: {
default: null,
type: cc.Node,
},
nd_ui2: {
default: null,
type: cc.Node,
},
parsmoke: {
default: null,
type: cc.ParticleSystem,
},
nd_shadow: {
default: null,
type: cc.Node,
},
nd_team: {
default: null,
type: cc.Node,
},
sp_teampoint: {
default: null,
type: cc.Sprite,
},
lb_teamname: {
default: null,
type: cc.Label,
},
nd_miaozhun: {
default: null,
type: cc.Node,
},
nd_moveline: {
default: null,
type: cc.Node,
},
lineNode: {
default: null,
type: cc.Node,
},
sp_fake: {
default: null,
type: cc.Sprite,
},
parfake: {
default: null,
type: cc.Node,
},
// anibuff:{
// default: null,
// type: cc.Animation,
// },
nd_role: {
default: null,
type: cc.Node,
},
nd_buff: {
default: null,
type: cc.Node,
},
parmove: {
default: null,
type: cc.ParticleSystem,
},
skeleton: {
default: null,
type: sp.Skeleton,
},
aniweapon: {
default: null,
type: cc.Animation,
},
nd_newbody: {
default: null,
type: cc.Node,
},
nd_hand: {
default: null,
type: cc.Node,
},
// nd_san: {
// default: null,
// type: cc.Node,
// },
skilllineNode: {
default: null,
type: cc.Node,
},
sp_skillboom: {
default: null,
type: cc.Node,
},
sp_skillboom2: {
default: null,
type: cc.Node,
},
sp_skillline: {
default: null,
type: cc.Node,
},
nd_buffgun: {
default: null,
type: cc.Node,
},
nd_sanfront: {
default: null,
type: cc.Node,
},
nd_sanback: {
default: null,
type: cc.Node,
},
anidixing: {
default: null,
type: cc.Animation,
},
anihit: {
default: null,
type: cc.Animation,
},
nd_hp: {
default: null,
type: cc.Node,
},
lineani: {
default: null,
type: cc.Animation,
},
pr_yangqi: {
default: null,
type: cc.ProgressBar,
},
nd_noyangqi: {
default: null,
type: cc.Node,
},
},
doxiaqian() {
this.dive = 1;
},
showskill(sid) {
var skillcfg = skillConfig[sid];
this.otherani = skillcfg.skill_anim;
this.othertime = skillcfg.anim_time / 1000;
this.skillbuding = this.othertime;
if (skillcfg.skill_sound) {
cc.gameMgr.playSound(skillcfg.skill_sound);
}
},
canusesweizhuang(fid) {
if (
tileConfig.canusewz[fid] &&
this.nowmoveid != tileConfig.canusewz[fid]
) {
return false;
}
return true;
},
cannotuseskill(x, y) {
return false;
var gid = 0;
var cds = cc.gameMgr.maptile._layers;
var px = Math.floor(x / 32);
var py = cc.gameMgr.mapheight - Math.floor(y / 32) - 1;
px = Math.min(Math.max(0, px), cc.gameMgr.mapheight - 1);
py = Math.min(Math.max(0, py), cc.gameMgr.mapheight - 1);
for (var i = cds.length - 1; i >= 0; i--) {
var temp = cds[i].getTileGIDAt(px, py);
if (temp > 0 && cc.gameMgr.tiledata[temp - 1]) {
gid = Number(cc.gameMgr.tiledata[temp - 1]);
break;
}
}
return tileConfig.cantskill[gid];
},
joySkillMoveBegin(mode, touch) {
this.skilling = true;
// console.log("iiii joySkillMoveBegin")
joytouch.x = touch.x;
joytouch.y = touch.y;
this.nd_moveline.stopAllActions();
this.nd_moveline.runAction(cc.fadeOut(0.2));
if (this.isdead() || this.isdown || this.sanmode || this.flymode) {
return;
}
var sid = this.skillcdarr[1].skill_id;
var skillcfg = skillConfig[sid];
if (skillcfg.skill_view) {
this.skillview = skillcfg.skill_view;
}
//this.nd_quan.height = this.nd_quan.width = this.skillmaxdis * 2
if (mode == 2) {
cc.gameMgr.uic.nd_quxiao.active = true;
this.skilllineNode.opacity = 255;
} else if (mode == 3) {
cc.gameMgr.uic.nd_quxiao.active = true;
this.sp_skillboom.active = true;
this.nd_quan.opacity = 255;
// this.nd_quan.height = this.nd_quan.width = this.skillmaxdis * 2
} else if (mode == 4) {
cc.gameMgr.uic.nd_quxiao.active = true;
this.skilllineNode.opacity = 0;
this.nd_quan.opacity = 255;
}
},
joySkillMove(ag, dis, mode, touch) {
joytouch.x = touch.x;
joytouch.y = touch.y;
dis *= 2;
// this.nd_moveline.opacity = 0
this.nd_moveline.stopAllActions();
this.nd_moveline.runAction(cc.fadeOut(0.2));
if (this.isdead() || this.sanmode || this.flymode) {
return;
}
this.skilling = true;
this.joyskilldir.x = Math.cos(ag * (Math.PI / 180));
this.joyskilldir.y = Math.sin(ag * (Math.PI / 180));
if (mode == 2) {
this.skilllineNode.rotation =
-Math.atan2(this.joyskilldir.y, this.joyskilldir.x) *
(180 / Math.PI); // + 45;
if (this.skilllineNode.rotation > 180) {
this.skilllineNode.rotation = this.skilllineNode.rotation - 360;
}
} else if (mode == 3) {
var boomDistance = dis;
boomDistance = Math.min(
Math.max(50, boomDistance),
this.skillmaxdis
);
this.skillboomDistance = boomDistance;
this.sp_skillboom2.x = boomDistance; // / this.node.scaleX;
this.sp_skillboom.rotation = -ag; //+ 45
} else if (mode == 4) {
this.skilllineNode.opacity = 255;
this.nd_quan.opacity = 255;
this.skilllineNode.rotation =
-Math.atan2(this.joyskilldir.y, this.joyskilldir.x) *
(180 / Math.PI); // + 45;
if (this.skilllineNode.rotation > 180) {
this.skilllineNode.rotation = this.skilllineNode.rotation - 360;
}
}
},
cleanskilltouch() {
// console.log("iiii joySkillMoveEnd")
this.skillview = 0;
this.skilllineNode.opacity = 0;
this.nd_quan.opacity = 0;
this.skilling = false;
this.sp_skillboom.active = false;
cc.gameMgr.uic.nd_quxiao.active = false;
},
joySkillMoveEnd(mode) {
var isnotmove = this.skilllineNode.opacity == 0;
// if(!this.skilling){
// this.cleanskilltouch()
// return
// }
this.cleanskilltouch();
if (
this.isdead() ||
this.isdown ||
this.sanmode ||
this.flymode ||
this.touchquxiao()
) {
return;
}
var x = this.joyskilldir.x * this.skillboomDistance + this.node.x;
var y = this.joyskilldir.y * this.skillboomDistance + this.node.y;
this.atkdir.x = this.joyskilldir.x;
this.atkdir.y = this.joyskilldir.y;
if (mode == 4 && isnotmove) {
var skillcfg = skillConfig[this.skillcdarr[1].skill_id];
var skillrage = skillcfg.skill_distance * skillcfg.skill_distance;
var temp = [];
var onep = null;
var isMember = false;
for (var i = cc.gameMgr.playerarr.length - 1; i >= 0; i--) {
onep = cc.gameMgr.playerarr[i];
isMember =
battlenet.gamemode == 1
? onep.pctrl.race == this.race
: onep.pctrl.isMember;
if (
onep.active &&
onep.opacity != 0 &&
onep.pctrl != this &&
onep.pctrl.isdead() == false &&
isMember == false &&
onep.pctrl.fakemode == false
) {
if (
Math.pow(onep.x - this.node.x, 2) +
Math.pow(onep.y - this.node.y, 2) <
skillrage ||
battlenet.newbiemode
) {
temp.push(cc.gameMgr.playerarr[i]);
}
}
}
if (temp.length == 0) {
for (var i = cc.gameMgr.npcarr.length - 1; i >= 0; i--) {
onep = cc.gameMgr.npcarr[i];
isMember = onep.pctrl.ismember;
if (
onep.active &&
onep.opacity != 0 &&
!onep.pctrl.isdead &&
!isMember
) {
if (
Math.pow(onep.x - this.node.x, 2) +
Math.pow(onep.y - this.node.y, 2) <
skillrage
) {
temp.push(cc.gameMgr.npcarr[i]);
}
}
}
}
if (temp.length > 0) {
temp = temp.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;
});
this.atkdir.x = temp[0].x - this.node.x;
this.atkdir.y = temp[0].y - this.node.y;
this.joyskilldir.x = this.atkdir.x;
this.joyskilldir.y = this.atkdir.y;
}
}
if (this.cannotuseskill(x, y)) {
cc.uiHelper.showTips("Can't put skills here");
} else {
this.onClickSkill(1);
this.saveskillboomDistance = this.skillboomDistance;
}
},
onClickTiaoSan() {
this.doJump = true;
},
onClickSkill(v) {
var skill_left_time = this.skillcdarr[v].curr_times;
var sid = this.skillcdarr[v].skill_id;
if (
skill_left_time < 1 ||
this.isdead() ||
this.isdown ||
this.sanmode ||
this.flymode
) {
return;
}
cc.Notifier.emit('jiantingbattle', 'dash');
var skillcfg = skillConfig[sid];
var skillrage = skillcfg.skill_distance * skillcfg.skill_distance;
var skill_target = skillcfg.skill_target;
if (skill_target >= 6 && skill_target <= 10) {
var temp = [];
var onep = null;
var isMember = false;
for (var i = cc.gameMgr.playerarr.length - 1; i >= 0; i--) {
onep = cc.gameMgr.playerarr[i];
isMember =
battlenet.gamemode == 1
? onep.pctrl.race == this.race
: onep.pctrl.isMember;
if (
onep.active &&
onep.opacity != 0 &&
onep.pctrl != this &&
onep.pctrl.isdead() == false &&
isMember == false &&
onep.pctrl.fakemode == false
) {
if (
Math.pow(onep.x - this.node.x, 2) +
Math.pow(onep.y - this.node.y, 2) <
skillrage
) {
temp.push(cc.gameMgr.playerarr[i]);
}
}
}
if (temp.length == 0) {
for (var i = cc.gameMgr.npcarr.length - 1; i >= 0; i--) {
onep = cc.gameMgr.npcarr[i];
isMember = onep.pctrl.ismember;
if (
onep.active &&
onep.opacity != 0 &&
!onep.pctrl.isdead &&
!isMember
) {
if (
Math.pow(onep.x - this.node.x, 2) +
Math.pow(onep.y - this.node.y, 2) <
skillrage
) {
temp.push(cc.gameMgr.npcarr[i]);
}
}
}
}
if (temp.length > 0) {
temp = temp.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;
});
this.skill_target_id = temp[0].objuuid;
this.use_skill = true;
} else {
cc.uiHelper.showTips(cc.language.stringformat('buzaifanwei'));
}
} else {
this.use_skill = true;
}
if (this.use_skill) {
this.skill_id = sid;
if (skillcfg.use_method >= 2) {
this.skill_dir = this.joyskilldir;
} else {
this.skill_dir = this.dirforskill;
}
}
},
setpFrame(sprite, frameName, dir) {
if (playerFrame[frameName]) {
sprite.spriteFrame = playerFrame[frameName];
} else {
if (playerReadyFrame[frameName] == undefined) {
playerReadyFrame[frameName] = [];
var self = this;
cc.loader.loadRes(
dir + '/' + frameName,
cc.SpriteFrame,
function (err, res) {
if (!err && self.isValid) {
playerFrame[frameName] = res;
for (
var i = playerReadyFrame[frameName].length - 1;
i >= 0;
i--
) {
try {
playerReadyFrame[frameName][i].spriteFrame =
res;
} catch (e) {}
}
playerReadyFrame[frameName] = null;
}
}
);
}
if (playerReadyFrame[frameName]) {
playerReadyFrame[frameName].push(sprite);
} else {
console.log('error:' + frameName);
}
}
},
onClickSave() {
if (this.saveId) {
this.pushObj(this.saveId);
this.saveId = undefined;
this.showEmoteNetAnimation(1002);
}
},
getItem() {
if (this.get_onobj) {
this.get_on = this.get_onobj;
this.get_onobj = null;
return;
}
if (
(this.nowItem.equip_type == 9 || this.nowItem.equip_type == 10) &&
this.nowItemUUID
) {
this.pushObj(this.nowItemUUID);
this.nowItemUUID = undefined;
if (this.nowItem) {
cc.gameMgr.playSound(this.nowItem.sound_pickup); //
}
} else if (this.nowItem.equip_subtype == 1 && this.guns[0] != 30101) {
this.netGunidxDrop = 0;
} else {
if (this.guns[1] != 0 && this.guns[2] != 0) {
if (this.currentgunidx == 1) {
this.netGunidxDrop = 1;
this.switchGunNet(1);
} else {
this.netGunidxDrop = 2;
if (this.currentgunidx == 2) {
this.switchGunNet(2);
}
}
}
}
},
useItem(idx) {
if (this.yaoArr[idx] == 0 || this.isdead()) {
return;
}
if (this.action_type == 2) {
return;
}
if (this.shoting) {
return;
}
this.yaotime = 0;
this.use_item_idx = idx + 7; //
if (idx == 0) {
this.showEmoteNetAnimation(1001);
} else if (idx == 1) {
this.showEmoteNetAnimation(1004);
} else {
this.showEmoteNetAnimation(1005);
this.use_item_idx = 9;
}
},
stopItem() {
this.cancel_action = true;
},
switchView(lv) {
this.viewScaleIdx = lv;
},
onDestroy() {
this.teamMembers.length = 0;
this.objarr.length = 0;
this.nd_reload = null;
this.node.pctrl = null;
},
cleanbuffnode() {
var bufchilds = this.nd_buff.getChildren();
for (var i = bufchilds.length - 1; i >= 0; i--) {
this.huishoulooteff('buffobj', bufchilds[i]);
}
},
getattr(aid, v) {
if (!this.addrmap[aid]) {
this.addrmap[aid] = {
absv: 0,
ratev: 1,
};
}
return (v + this.addrmap[aid].absv) * this.addrmap[aid].ratev;
},
refrshattrwithmap(attrs) {
this.addrmap = {};
for (var i = 0; i < attrs.length; i++) {
var dat = attrs[i];
this.addrmap[dat.attr_id] = {
absv: dat.abs_val,
ratev: 1 + dat.rate_val / 100,
};
}
},
updatemapv(aid, v, isabs) {
if (!this.addrmap[aid]) {
this.addrmap[aid] = {
absv: 0,
ratev: 1,
};
}
if (isabs) {
this.addrmap[aid].absv = v;
} else {
this.addrmap[aid].ratev = 1 + v / 100;
}
},
initdata() {
this.nd_noyangqi.active = false;
this.pr_yangqi.node.active = false;
this.bagmap = {};
this.skillbuding = 0;
this.checkcd = 0;
this.follow_target = 0;
this.quanidx = 0;
this.hidehptime = 0;
this.afterthrow = false;
this.anihit.node.active = false;
this.nowmovei = 0;
this.sp_fake.node.scale = 1;
this.btotal1 = 0;
this.btotal2 = 0;
this.buffview = 0;
this.buffviewarr = [];
this.shotspanicd = 0;
this.xuanyun = 0;
this.suofangxiang = 0;
this.chuantou = 0;
this.buffanimode = 0;
this.buffanistring = '';
this.uipuvaule = 0;
this.shoot_offset_x = 0;
this.shoot_offset_y = 0;
this.car_uniid = 0;
this.isrun = true;
this.speed = 0;
this.skillview = 0;
this.skilllineNode.opacity = 0;
this.parsmoke.node.active = false;
this.addrmap = {};
// this.parfake.active = false
this.horseqianzui = '';
this.plusshotname = '';
this.houzuoli = 0;
this.buffidarr = [];
this.bulletArr = [0, 0, 0, 0, 0];
if (!this.oldscale) {
this.oldscale = this.node.scale;
this.oldshadowy = this.nd_shadow.y;
}
this.nd_shadow.zIndex = -10;
this.sanmode = false;
this.initspine = null;
this.node.zplus2 = 0;
this.changesan();
if (cc.jietumode) {
this.node.scaleX = 0;
}
// this.spnewbietime = 0
if (!this.hasinitonce) {
this.oldhpy = this.pr_hp.node.y;
var xiuscale = 1;
this.nd_ui2.scaleY = xiuscale;
this.node.zplus = 0;
this.node.width = this.node.height = PLAYERLENGTH;
this.dir = cc.v2(0, 0);
this.dirforskill = cc.v2(0, 0);
this.atkdir = cc.v2(0, 0);
this.atkdir2 = cc.v2(0, 0);
this.joyskilldir = cc.v2(1, 0);
this.atktemp = cc.v2(0, 0);
this.centerVec = cc.v2(
cc.gameMgr.mapSize / 2,
cc.gameMgr.mapSize / 2
);
this.weaponstate = 0;
this.nd_team.active = false;
this.pr_hp.node.active = true;
this.hasinitonce = true;
var self = this;
self.skeleton.setCompleteListener((trackEntry, loopCount) => {
if (trackEntry.trackIndex == 3) {
self.skeleton.clearTrack(3);
}
});
}
if (cc.gameMgr.gameStart) {
cc.gameMgr.findenmey = true;
}
this.cannotzimiao = false;
this.quickstate = false;
this.buffmap = {};
if (!this.pararr) {
this.pararr = [];
this.uppnoearr = [];
this.uppnoearr2 = [];
} else {
for (var i = 0; i < this.pararr.length; i++) {
this.huishoulooteff(
this.pararr[i].resname,
this.pararr[i].node
);
}
for (var i = 0; i < this.uppnoearr.length; i++) {
this.huishoulooteff(
this.uppnoearr[i].resname,
this.uppnoearr[i]
);
}
for (var i = 0; i < this.uppnoearr2.length; i++) {
this.huishoulooteff(
this.uppnoearr2[i].resname,
this.uppnoearr2[i]
);
}
this.pararr = [];
this.uppnoearr = [];
this.uppnoearr2 = [];
}
this.cleanbuffnode();
this.currentGunzuoqi = 0;
this.aniqianzui = '';
this.zombiechage = false;
this.deadtime = 0;
this.nd_newbody.opacity = 255;
this.sp_fake.node.opacity = 0;
this.linehidetime = 0;
this.buffhead = -1;
this.buffbody = -1;
this.node.active = true;
this.gunxishu = 1;
this.yaotime = 0;
this.shotdistance = 256 * 256;
this.bagid = -1;
this.horsemode = false;
this.fakemode = false;
this.autoangle = 0;
this.skinarr = [-1, -1, -1, -1];
this.nowSkin = [0, 0, 0, 0];
this.guns = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
this.gunsammo = [0, 0, 0, 0, 0, 0, 0, 0, 0];
this.yaoArr = [0, 0, 0];
this.glassArr = [1, 0, 0, 0];
// this.skill_left_time = 0;
//this.skill_cd_time = 1;
this.mstate = -1;
this.emoteing = false;
this.dir.x =
this.dir.y =
this.dirforskill.x =
this.dirforskill.y =
this.atkdir.x =
this.atkdir.y =
this.atkdir2.x =
this.atkdir2.y =
0;
this.sleeptime = 0;
this.anishoting = false;
this.shootingtime = 0;
this.teamMembers = [];
this.objarr = [];
this.shot_hold = false;
this.isdown = false;
this.packdata = {};
this.viewScaleIdx = 0;
this.hat = 0;
this.bag = 0;
this.cloth = 0;
this.nd_dead.active = false;
this.nd_dead.opacity = 255;
this.nd_buff.active = true;
this.sp_boom.active = false;
this.sp_skillboom.active = false;
this.nd_newbody.active = true;
this.nd_emote.active = false;
this.maxhp = 200;
this.hp = this.maxhp;
this.action_duration = 0;
this.action_type = 0;
this.hptime = 0;
this.defhp = 0;
this.defhpMax = 1;
this.shotcd = 0;
this.isMember = false;
this.leganicd = 0;
this.findEnemyTime = 0;
this.hasfind = false;
this.nd_atkup.active = false;
this.horseid = 0;
this.fakeid = 0;
this.othertime = 0;
this.otherani = null;
this.nowAni = '';
this.plusView = 0;
this.gudingview = 0;
this.saveview = 0;
this.saveviewadd = 0;
this.weaponView = 0;
this.weaponView2 = 0;
this.vhuiguitime = 0;
this.auto_area = 0;
// this.anishootstop()
this.nd_hp.opacity = 0;
this.parmove.node.active = true;
this.node.sacle = this.oldscale;
this.fakearr = [];
this.skillcdarr = [];
if (this.node.isSelf) {
// this.parmove.node.active = true
this.lineNode.active = true;
this.lineNode.opacity = 0;
this.emote = battlenet.emojis; //[1,2,3,4,5,6]
// this.fakearr = []
this.nd_member.active = true;
this.nd_reload = cc.gameMgr.uic.nd_reload;
this.nd_reload.active = false;
cc.gameMgr.uic.nd_get.active = false;
cc.gameMgr.uic.btn_save.active = false;
cc.gameMgr.uic.nd_offtank.active = false;
this.nd_miaozhun.active = false;
this.nd_moveline.active = true;
this.nd_moveline.opacity = 0;
this.pr_hp.node.active = true;
var quan = new cc.Node();
// var sp = quan.addComponent(cc.Sprite)
// sp.sizeMode = 0
// var self = this
// cc.loader.loadRes("textures/uires/auto_area", cc.SpriteFrame, function(err, res) {
// if (!err && self.isValid) {
// sp.spriteFrame = res;
// sp.sizeMode = 0
// quan.height = quan.width = self.auto_area * 2
// if (self.skillrage2) {
// quan.height = quan.width = self.skillrage2
// }
// }
// });
quan.name = 'quan';
cc.gameMgr.map.addChild(quan);
quan.zIndex = 9999;
this.nd_quan = quan;
this.nd_quan.opacity = 0;
this.nd_skillboom = this.sp_skillboom;
this.nd_skillboom.removeFromParent(false);
this.nd_skillboom.scale = 1;
cc.gameMgr.map.addChild(this.nd_skillboom);
this.nd_skillboom.zIndex = quan.zIndex + 1;
} else {
this.lineNode.active = false;
this.nd_miaozhun.active = true;
this.nd_moveline.active = false;
}
this.nd_miaozhun.opacity = 0;
this.nd_shield.active = false;
this.nd_down.active = false;
this.legstate = 0;
this.aniDir = -1;
this.aniIdx = 0;
this.dashtime = 0;
this.revivetime = 0;
if (cc.gameMgr.objdatamap[this.netuuid]) {
var ndt = cc.gameMgr.objdatamap[this.netuuid];
this.currentGun = ndt.currentGun;
this.isdown = ndt.isdown;
this.defhp = ndt.defhp;
this.hp = ndt.hp;
this.maxhp = ndt.maxhp;
//this.killCount = ndt.killCount
this.nd_shield.active = this.defhp > 0;
// this.weaponstate = ndt.weaponstate
this.checkDown();
this.onChangeGunNet();
this.refreshHpbar();
this.nowSkin[0] = ndt.skin1;
this.nowSkin[1] = ndt.skin2;
this.nowSkin[2] = ndt.skin3;
this.nowSkin[3] = ndt.skin4;
this.buffhead = ndt.buffhead;
this.buffbody = ndt.buffbody;
this.fakemode = ndt.fakemode;
this.fakeid = ndt.fakeid;
this.checkbuff(ndt.buffidarr);
this.ChangeSkin();
this.refreshbag(ndt.bagid);
cc.gameMgr.objdatamap[this.netuuid] = null;
} else {
this.refreshbag(0);
}
this.fixrefeshhp = true;
this.dofake();
},
showFake(idx) {
if (idx >= this.fakearr.length) {
return;
}
if (this.fakearr[idx].count <= 0) {
return;
}
if (!this.canusesweizhuang(this.fakearr[idx].id)) {
cc.uiHelper.showTips('cannot be used here');
return;
}
this.use_item_id = this.fakearr[idx].id;
},
dofake() {
this.nd_newbody.stopAllActions();
if (this.fakemode == false) {
this.nd_newbody.opacity = 255;
this.sp_fake.node.opacity = 0;
//this.pr_yangqi.node.active = false
} else {
// if (this.fakeid == 30707) {
// if(this.node.isSelf){
// this.pr_yangqi.node.active = true
// }
// } else {
// this.pr_yangqi.node.active = false
// }
this.nd_newbody.opacity = 0;
this.sp_fake.node.opacity = 255;
this.sp_fake.spriteFrame = cc.atlMgr.mapthingatlas.getSpriteFrame(
gameConfig.dropItemConfig[this.fakeid].world_img
);
}
},
offtank() {
if (this.sanmode) {
return;
}
if (!cc.gameMgr.gameStart) {
return;
}
this.get_down = true;
},
lefttank() {},
pushBullet() {
if (this.sanmode || this.flymode) {
return;
}
if (this.currentgunidx == 1 || this.currentgunidx == 2) {
this.needReload = true;
}
},
dropItem(idx) {
this.netGunidxDrop = idx;
},
onSwitch(data) {
var gun = this.guns[Number(data)];
this.switchGun(gun);
},
shotSound(sound_use, pos) {
cc.gameMgr.playSound(sound_use, pos);
},
shotAni(sound_use, pos, dir, shotaniname, shot2, rot, gundata) {
if (this.onframe) {
return;
}
this.onframe = true;
if (sound_use) {
this.shotSound(sound_use, pos);
}
// TempV2.x = pos.x+dir.x*20
// TempV2.y = pos.y+dir.y*20
// cc.gameMgr.effectManager.createBulletP(TempV2)
if (!shotaniname) {
shotaniname = 'eff_shootfire';
}
if (this.aniweapon) {
this.aniweapon.play(shotaniname);
}
if (gundata.equip_subtype != 1 && this.shotspanicd <= 0) {
var str = this.sethandrotation()
? 'shoot_idlesway_front'
: 'shoot_idlesway_back';
this.skeleton.setAnimation(3, str, false);
this.shotspanicd = shotanicd;
}
// shot2 = 'efftest'
if (shot2) {
if (cc.gameMgr) {
cc.gameMgr.effectManager.createlooteff2(shot2, this.node, rot);
}
}
},
joyMoveBegin() {
if (this.isdead()) {
return;
}
if (!this.shoting && !this.skilling) {
// this.nd_moveline.opacity = 255
this.nd_moveline.stopAllActions();
this.nd_moveline.runAction(cc.fadeIn(0.2));
}
this.joyMoveing = true;
},
sethandrotation() {
var rot = this.nd_display.rotation;
var isfront = true;
var needflip = false;
// var hrot = 0
if (rot >= 0 && rot <= 90) {
//hrot = rot/2
} else if (rot > 90 && rot < 180) {
// hrot = (180-rot)/2
needflip = true;
} else if (rot <= 0 && rot >= -90) {
// hrot = rot/2
isfront = false;
} else {
//hrot = (180-rot)/2
isfront = false;
needflip = true;
}
if (needflip) {
this.nd_newbody.scaleX = -1;
} else {
this.nd_newbody.scaleX = 1;
}
if (isfront) {
//jjtest1
} else {
}
this.isfront = isfront;
this.nd_hand.zIndex = isfront || this.othertime > 0 ? 1 : -1;
// if(this.node.isSelf){
// // console.log( AnidirArr[this.aniDir] )
// console.log( "dir:"+this.aniDir+" idx:"+ AnidirArr[this.aniDir])
// this.aniDir
// }
if ((this.shoting || this.anishoting) && AnidirArr[this.aniDir] == 4) {
this.nd_hand.zIndex = 1;
}
return isfront;
},
checkAngle(isfront) {
var rot = -1;
if (this.weaponstate != 2) {
rot = isfront ? 1 : 0;
} else {
rot = Math.floor(((this.nd_display.rotation + 180) % 360) / 11.25);
}
if (this.aniDir != rot) {
this.aniDir = rot;
return true;
}
return false;
},
throw(aniname) {
if (!aniname) {
aniname = 'throw';
}
if (this.isfront) {
this.anishootplay(aniname);
this.afterthrow = true;
} else {
this.anishootplay(aniname + '_back');
}
this.sleeptime = 0.4;
},
checkAni(dt) {
if (this.houzuoli > 0) {
this.houzuoli -= dt;
return;
}
if (this.skillbuding > 0) {
this.skillbuding -= dt;
}
// this.legstate = 0 //1idel 2 walk
// var weaponAniArr = ["melee","melee","gun","melee"]
// var walkAniArr = ["","idle","run"]
// var AnidirArr = [4,3,2,1,1,2,3,4,5,6,7,8,8,7,6,5]
if (this.buffanimode > 0) {
if (this.buffanistring != '') {
var ifront = this.sethandrotation();
var nstr = ifront
? this.buffanistring
: this.buffanistring + '_back';
this.anishootstop();
this.anibodyplay(nstr);
this.nowAni = nstr;
this.buffanistring = '';
}
return;
}
if (this.sanmode) {
var ifront = this.sethandrotation();
var nstr = ifront ? 'fly' : 'fly_back';
if (this.nowAni != nstr) {
if (ifront) {
this.nd_sanfront.opacity = 255;
this.nd_sanback.opacity = 0;
} else {
this.nd_sanfront.opacity = 0;
this.nd_sanback.opacity = 255;
}
// this.huanlian()
this.anishootstop();
this.anibodyplay(nstr);
this.nowAni = nstr;
}
return;
}
if (this.isdown) {
var ifront = this.sethandrotation();
var downplus = '';
if (this.legstate == 1) {
downplus = '_idle';
}
var nstr = ifront ? 'crawl' : 'crawl_back';
nstr = nstr + downplus;
if (this.nowAni != nstr) {
this.huanlian();
this.anishootstop();
this.anibodyplay(nstr);
this.nowAni = nstr;
}
return;
}
if (this.dashtime > 0) {
this.dashtime -= dt;
return;
}
this.shadowmode = false;
if (this.sleeptime > 0) {
this.sleeptime -= dt;
if (this.sleeptime <= 0) {
this.anishootstop();
this.nowAni = '';
if (this.afterthrow) {
this.afterthrow = false;
if (this.currentgunidx > 2) {
this.sleeptime = thrwotime;
this.anishootplay('replace_weapon4');
// if (this.currentgunidx == 1 || this.currentgunidx == 2) {
// this.anishootplay("replace_weapon")
// }else{
// this.anishootplay("replace_missile")
// }
}
}
}
return;
}
var isfront = this.sethandrotation();
var plusname = isfront ? '' : '_back'; //
var nowstr = this.weaponstate + '_' + this.legstate + plusname;
if (this.othertime > 0) {
plusname = '';
if (this.otherani) {
this.anishootplay(this.otherani);
this.otherani = null;
}
this.othertime -= dt;
nowstr = nowstr + 'O';
if (this.nowAni != nowstr) {
this.anibodyplay(
this.horseqianzui + 'shoot_' + walkAniArr[this.legstate]
);
this.nowAni = nowstr;
}
if (this.othertime <= 0) {
this.anishootstop();
this.nowAni = '';
}
return;
}
if (this.anishoting || (this.shoting && this.weaponstate != 3)) {
this.emoteing = false;
nowstr = nowstr + '1';
var needcheck = this.checkAngle(isfront);
if (this.node.isSelf) {
// cc.log(this.aniDir)
}
if (this.nowAni != nowstr) {
this.anibodyplay(
this.aniqianzui +
'shoot_' +
walkAniArr[this.legstate] +
plusname
);
this.nowAni = nowstr;
needcheck = true;
}
if (!this.anishotb) {
needcheck = true;
}
if (needcheck) {
if (this.weaponstate == 0) {
var fidx = this.quanidx + 1;
var aniname = isfront
? 'fist_angledown' + fidx
: 'fist_angleup' + fidx;
this.quanidx++;
this.quanidx %= 2;
this.anishootplay2(this.aniqianzui + aniname);
} else if (this.weaponstate == 3) {
// this.sleeptime = 0.5
} else if (this.weaponstate != 2) {
var aniname = isfront ? 'melee_angledown' : 'melee_angleup';
this.anishootplay2(this.aniqianzui + aniname);
} else {
var aniIdx = AnidirArr[this.aniDir];
this.anishootplay2('shoot_' + aniIdx + this.plusshotname);
// if(this.node.isSelf){
// console.log(this.aniDir+":"+this.plusshotname + "shoot_" + aniIdx)
// }
// this.gunani.play(this.plusshotname + "shoot_" + aniIdx)
}
this.anishotb = true;
}
} else {
// this.quanidx = 0
nowstr = nowstr + '2';
if (this.anishotb) {
this.anishootstop();
}
this.anishotb = false;
this.checkAngle(isfront);
if (this.nowAni != nowstr) {
var runani = weaponAniArr[this.weaponstate];
var runaniend = '';
if (this.weaponstate == 2) {
runaniend = this.plusshotname;
}
var ssst = this.legstate;
if (ssst > 2) {
ssst = 2;
}
this.anibodyplay(
runani + '_' + walkAniArr[ssst] + plusname + runaniend
);
this.nowAni = nowstr;
this.emoteing = false;
}
}
// if(this.node.isSelf&&this.shoting&&this.isdead() == false){
// //this.nd_mouse.active = true
// }else{
// //this.nd_mouse.active = this.anishoting
// }
this.checkemote();
},
joyShot(touch) {
if (cc.pcmode && this.skilling) {
this.joySkillMoveEnd(cc.gameMgr.uic.use_method);
this.skilling = false;
return;
}
this.skilling = false;
joytouch.x = touch.x;
joytouch.y = touch.y;
// this.anishoting =true
//this.nd_moveline.opacity = 0
// this.nd_moveline.stopAllActions()
// this.nd_moveline.runAction(cc.fadeOut(0.2))
// this.vhuiguitime = 0
// this.shoting = true;
// this.atkdir.x = this.dir.x
// this.atkdir.y = this.dir.y
if (this.isdead() || this.isdown || this.sanmode || this.flymode) {
return;
}
if (this.shotcd > 0) {
return;
}
this.vhuiguitime = 0;
this.shoting = true;
if (cc.pcmode) {
this.atkdir = cc.gameMgr.uic.node.convertToNodeSpaceAR(touch);
this.atkdir = this.atkdir.normalize();
} else {
this.atkdir.x = this.dir.x;
this.atkdir.y = this.dir.y;
}
if (this.firemode == 2 || this.isBoom) {
this.miaozun = true;
cc.gameMgr.uic.hidenode.opacity = 0;
cc.gameMgr.uic.nd_quxiao.active = true;
}
this.plusView = this.getattr(12, this.saveview);
if (this.currentGunzuoqi == 0) {
this.plusView += this.saveviewadd;
}
// if (this.shotcd > 0) {
// return
// }
this.nd_moveline.stopAllActions();
this.nd_moveline.runAction(cc.fadeOut(0.2));
this.shot_hold = true;
if (this.needline) {
this.lineNode.stopAllActions();
this.lineNode.runAction(cc.fadeIn(0.2));
if (this.gunsub == 7) {
this.lineani.play('sp_line_j');
cc.gameMgr.viewspeed = 0.2;
} else {
this.lineani.play('sp_line_p');
}
// this.lineNode.opacity = 255;
} else {
this.lineNode.opacity = 0;
}
},
joyShotMove(ag, dis, touch) {
this.skilling = false;
joytouch.x = touch.x;
joytouch.y = touch.y;
// this.nd_moveline.opacity = 0
if (!this.shoting || this.sanmode || this.flymode) {
return;
}
if (this.needline) {
// this.lineNode.opacity = 255;
} else {
this.lineNode.opacity = 0;
}
// ag += 45
//console.log(dis)
if (dis < shotdelta && this.dir.x != 0 && this.dir.y != 0) {
// this.atkdir.x = this.dir.x
// this.atkdir.y = this.dir.y
} else {
this.atkdir.x = Math.cos(ag * (Math.PI / 180));
this.atkdir.y = Math.sin(ag * (Math.PI / 180));
}
if (this.isBoom) {
this.boomDistance = dis;
this.boomDistance = Math.min(
Math.max(this.minlength, this.boomDistance),
this.getattr(33, this.maxlength)
);
this.sp_boom2.x = this.boomDistance / this.node.scaleX;
this.sp_boom.rotation = -ag; //+ 45
//this.dianshedir = cc.v2(this.atkdir.x,this.atkdir.y)
}
},
joyShotEnd() {
cc.gameMgr.viewspeed = 2;
cc.gameMgr.uic.hidenode.opacity = 255;
cc.gameMgr.uic.nd_quxiao.active = false;
if (this.shoting == false) {
return;
}
if (this.joyMoveing) {
this.nd_moveline.stopAllActions();
this.nd_moveline.runAction(cc.fadeIn(0.2));
}
this.vhuiguitime = 1;
this.shot_hold = false;
this.shoting = false;
if (this.needline) {
this.lineNode.stopAllActions();
this.lineNode.runAction(cc.fadeOut(0.2));
//this.lineNode.opacity = lineopacity;
} else {
this.lineNode.opacity = 0;
}
this.checkemote();
this.miaozun = false;
if (this.isdead() || this.isdown || this.sanmode || this.flymode) {
return;
}
if (this.isBoom || this.firemode == 2) {
if (this.touchquxiao()) {
return;
}
}
if (this.isBoom) {
this.saveboomDistance = this.boomDistance;
this.dianshedir = cc.v2(this.atkdir.x, this.atkdir.y);
}
if (this.firemode == 2 && this.shotcd <= 0) {
if (this['nowgunbullet' + this.currentgunidx] > 1) {
if (this.nd_reload.active == false) {
cc.gameMgr.uic.lb_reloaddes.string =
cc.language.stringformat('shangtang');
}
if (this.nd_reload) {
this.nd_reload.active = true;
}
}
this.shotcd = this.gunrate;
// this.sleeptime = this.shotcd
this.dianshe = true;
if (!(this.atkdir2.x == 0 && this.atkdir2.y == 0)) {
this.dianshedir = cc.v2(this.atkdir2.x, this.atkdir2.y);
} else {
this.dianshedir = cc.v2(this.atkdir.x, this.atkdir.y);
}
// if(this.nd_reload.active==false){
// this.sleeptime = 0.5
// }
this.atkdir2.x = this.atkdir2.y = 0;
this.report(0);
}
this.atkdir2.x = this.atkdir2.y = 0;
},
joyMove(ag, dis) {
// console.log('joy move in playerctrl');
this.dirforskill = cc.v2(0, 0);
//ag += 45
var dir = cc.v2(
Math.cos(ag * (Math.PI / 180)),
Math.sin(ag * (Math.PI / 180))
);
this.dir = dir.normalize();
// console.log(this.dir);
if ((!this.shoting && this.boomDistance == 0) || this.isdown) {
this.atkdir.x = this.dir.x;
this.atkdir.y = this.dir.y;
}
this.dirforskill.x = this.dir.x;
this.dirforskill.y = this.dir.y;
if (dis > maxmovedis) {
dis = maxmovedis;
}
this.nd_moveline.x = this.dir.x * dis;
this.nd_moveline.y = this.dir.y * dis;
this.nd_moveline.rotation = -ag;
// this.moveing = true
if (!this.shoting && !this.isdead()) {
// this.nd_moveline.opacity = 255
}
},
joyMoveEnd() {
this.atkdir = cc.v2(0, 0);
this.dir.x = this.dir.y = 0;
// this.nd_moveline.opacity = 0
this.nd_moveline.stopAllActions();
this.nd_moveline.runAction(cc.fadeOut(0.2));
this.joyMoveing = false;
this.atkdir.x = 0;
this.atkdir.y = 0;
//this.moveing = false
},
hurt() {
// if(this.node.isSelf){
// cc.gameMgr.doshake();
// }
if (
this.node.active == true &&
!this.horsemode &&
!this.isdead() &&
!this.isdown
) {
this.anihit.node.active = true;
this.anihit.play();
// cc.gameMgr.playSound("game_being_hit",this.node.position)
}
},
getHpBar() {
return this.hp / this.maxhp;
},
isdead() {
if (this.nd_dead.active == true) {
return true;
}
return this.hp <= 0;
},
checkemote() {
var mstate = 0;
if (this.hasfind) {
mstate = 3;
}
// if (this.getHpBar() < cc.gameMgr.uic.safebili) {
// mstate = 1
// }
if (this.shoting) {
mstate = 2;
}
if (this.mstate != mstate) {
this.mstate = mstate;
var self = this;
//self.setpFrame(self.sp_face, faceArr[mstate], "avatar/face")
}
},
lerpv(fromv, tov, ratio) {
if (!fromv) {
return tov;
}
if (Math.abs(fromv - tov) > 180) {
// console.log("from:"+fromv)
// console.log("tov:"+tov)
if (fromv > 0) {
tov = tov + 360;
} else {
fromv = fromv + 360;
}
}
var out = fromv + (tov - fromv) * ratio;
if (out > 180) {
out = out - 360;
}
return out;
},
update2(dt) {
if (this.node.isSelf) {
if (this.nowmoveid == 2) {
cc.gameMgr.uic.btn_xiaqian.active = true;
if (this.horsemode || this.sanmode) {
this.pr_yangqi.node.active = false;
} else {
this.pr_yangqi.node.active = true;
}
} else {
cc.gameMgr.uic.btn_xiaqian.active = false;
this.pr_yangqi.node.active = false;
}
if (
this.fakemode ||
this.horsemode ||
this.sanmode ||
this.isdead()
) {
cc.gameMgr.uic.btn_xiaqian.active = false;
}
if (this.pr_yangqi.progress <= 0) {
this.nd_noyangqi.active = true;
} else {
this.nd_noyangqi.active = false;
}
}
if (this.hidehptime > 0) {
this.hidehptime -= dt;
} else {
if (!(this.node.isSelf || this.isMember || this.iswatching)) {
this.nd_hp.opacity -= dt * 800;
}
}
for (var i = this.pararr.length - 1; i >= 0; i--) {
this.pararr[i].angle = -this.nd_display.rotation;
this.pararr[i].node.x = this.node.x + this.dirGo.x * firedis;
this.pararr[i].node.y = this.node.y + this.dirGo.y * firedis;
this.pararr[i].blifetime -= dt;
if (this.pararr[i].blifetime <= 0) {
this.huishoulooteff(
this.pararr[i].resname,
this.pararr[i].node
);
this.pararr.splice(i, 1);
}
}
for (var i = this.uppnoearr.length - 1; i >= 0; i--) {
this.uppnoearr[i].rotation = this.nd_display.rotation;
this.uppnoearr[i].x = this.node.x + this.dirGo.x * firedis;
this.uppnoearr[i].y = this.node.y + this.dirGo.y * firedis;
this.uppnoearr[i].blifetime -= dt;
if (this.uppnoearr[i].opacity < 255) {
this.uppnoearr[i].scaleY =
this.uppnoearr[i].blifetime / rayhide;
}
if (this.uppnoearr[i].blifetime <= 0) {
this.uppnoearr[i].scaleY = 1;
this.huishoulooteff(
this.uppnoearr[i].resname,
this.uppnoearr[i]
);
this.uppnoearr.splice(i, 1);
}
}
for (var i = this.uppnoearr2.length - 1; i >= 0; i--) {
this.uppnoearr2[i].rotation = this.nd_display.rotation;
this.uppnoearr2[i].x = this.node.x;
this.uppnoearr2[i].y = this.node.y;
// if (this.uppnoearr2[i].blifetime <= 0) {
// this.huishoulooteff(this.uppnoearr2[i].resname, this.uppnoearr2[i])
// this.uppnoearr2.splice(i, 1);
// }
}
if (this.isdead() && this.deadtime > 0) {
this.deadtime -= dt;
if (this.deadtime <= 0) {
this.nd_newbody.active = false;
this.nd_dead.opacity = 255;
}
return;
}
this.shotspanicd -= dt;
if (this.shadowmode && this.legstate == 2) {
this.shadowtime += dt;
if (this.shadowtime > this.shadowtime2) {
this.shadowtime = 0;
this.nd_ui1.opacity = 0;
this.nd_ui2.opacity = 0;
this.parsmoke.node.opacity = 0;
var mopa = this.parmove.node.opacity;
this.parmove.node.opacity = 0;
cc.gameMgr.effectManager.createshadow(this);
this.nd_ui1.opacity = 255;
this.nd_ui2.opacity = 255;
this.parsmoke.node.opacity = 255;
this.parmove.node.opacity = mopa;
}
}
// if (this.spnewbietime > 0) {
// this.spnewbietime -= dt
// }
if (this.sanmode) {
this.updatesan(dt);
}
if (this.nd_quan) {
this.nd_quan.position = this.node.position;
this.nd_skillboom.position = this.node.position;
}
// if (this.linehidetime > 0) {
// this.linehidetime -= dt
// if (this.linehidetime <= 0) {
// this.lineNode.opacity = 0
// }
// }
if (this.vhuiguitime > 0) {
this.vhuiguitime -= dt;
if (this.vhuiguitime <= 0) {
this.plusView = 0;
this.vhuiguitime = 0;
}
}
this.onframe = false;
if (this.anishoting) {
this.shootingtime -= dt;
if (this.shootingtime <= 0) {
this.anishoting = false;
this.shootingtime = 0;
}
}
// if (this.skill_left_time > 0) {
// this.skill_left_time -= dt
// }
for (var i = this.skillcdarr.length - 1; i >= 0; i--) {
this.skillcdarr[i].left_time -= dt * 1000;
}
if (this.hptime > 0) {
this.hptime -= dt;
}
if (this.shotcd > 0) {
this.shotcd -= dt;
if (this.node.isSelf) {
cc.gameMgr.uic.lb_timereload.string = this.shotcd.toFixed(1);
cc.gameMgr.uic.pr_reload.progress = this.shotcd / this.gunrate;
if (this.shotcd <= 0 && this.action_duration <= 0) {
if (this.nd_reload) {
this.nd_reload.active = false;
}
}
}
}
if (this.isBoom && this.shoting) {
this.sp_boom.active = true;
} else {
this.boomDistance = 0;
this.sp_boom.active = false;
}
if (!this.skilling) {
this.sp_skillboom.active = false;
}
if (this.action_duration > 0) {
this.action_duration -= dt;
if (this.action_duration < 0) {
this.action_duration = 0;
if (this.nd_reload) {
this.nd_reload.active = false;
}
}
if (this.node.isSelf) {
cc.gameMgr.uic.lb_timereload.string =
this.action_duration.toFixed(1);
cc.gameMgr.uic.pr_reload.progress =
(this.totalaction_duration - this.action_duration) /
this.totalaction_duration;
}
}
if (this.node.isSelf && this.isdead() == false) {
if (this.sanmode || this.flymode) {
cc.grassdis = 0;
}
this.doselfrotate();
this.checkSave();
this.findEnemyTime += dt;
if (this.findEnemyTime > 0.5) {
this.findEnemyTime = 0;
this.showmiaozhun();
}
//this.shothelp()
this.lineNode.rotation = this.lerpv(
this.lineNode.rotation,
this.nd_display.rotation,
0.7
);
// console.log(this.nd_display.rotation)
// this.yaotime += dt
// if (this.yaotime > 5 && this.action_type == 0 && cc.notheal == false) {
// this.yaotime = 0
// if (this.action_type == 0) {
// var hbili = this.hp / this.maxhp
// if (hbili < 0.5 && this.yaoArr[0] > 0) {
// this.useItem(0)
// } else if (hbili < 0.7 && this.yaoArr[1] > 0) {
// this.useItem(1)
// }
// }
// }
}
if (this.node.opacity == 0) {
return;
}
this.checkAni(dt);
this.updatebones(dt);
},
showmiaozhun(target) {
if (!cc.gameMgr.gameStart) {
return;
}
if (target) {
for (var i = cc.gameMgr.playerarr.length - 1; i >= 0; i--) {
onep = cc.gameMgr.playerarr[i];
onep.pctrl.nd_miaozhun.opacity = 0;
}
target.pctrl.nd_miaozhun.opacity = 255;
this.hasfind = true;
return;
}
var temp = [];
var onep = null;
var hasfind = false;
var isMember = false;
for (var i = cc.gameMgr.playerarr.length - 1; i >= 0; i--) {
onep = cc.gameMgr.playerarr[i];
isMember =
battlenet.gamemode == 1
? onep.pctrl.race == this.race
: onep.pctrl.isMember;
if (
onep.active &&
onep.opacity != 0 &&
onep.pctrl != this &&
onep.pctrl.isdead() == false &&
isMember == false &&
onep.pctrl.fakemode == false
) {
temp.push(cc.gameMgr.playerarr[i]);
}
onep.pctrl.nd_miaozhun.opacity = 0;
}
if (temp.length > 0) {
hasfind = true;
temp = temp.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;
});
temp[0].pctrl.nd_miaozhun.opacity = 255;
}
this.hasfind = hasfind;
},
shothelp() {
// if (cc.notShake) {
// return
// }
if (this.isdead() || this.isdown) {
return;
}
if (!this.shoting || (this.atkdir.x == 0 && this.atkdir.y == 0)) {
return;
}
if (this.isBoom) {
return;
}
this.autoangle = 300; //
if (this.autoangle == 0) {
return;
}
this.atkdir2.x = this.atkdir2.y = 0;
var temp = [];
var onep = null;
var dist = 0;
var isMember = false;
for (var i = cc.gameMgr.playerarr.length - 1; i >= 0; i--) {
onep = cc.gameMgr.playerarr[i];
isMember =
battlenet.gamemode == 1
? onep.pctrl.race == this.race
: onep.pctrl.isMember;
if (
onep.active &&
onep.opacity != 0 &&
onep.pctrl != this &&
onep.pctrl.isdead() == false &&
onep.pctrl.fakemode == false &&
isMember == false
) {
if (!(onep.x == this.node.x && onep.y == this.node.y)) {
dist =
(onep.x - this.node.x) * (onep.x - this.node.x) +
(onep.y - this.node.y) * (onep.y - this.node.y);
if (this.firemode != 2) {
if (dist < this.auto_area * this.auto_area) {
temp.push(cc.gameMgr.playerarr[i]);
}
} else {
dist = dist / this.shotdistance;
if (dist > 1) {
dist = 1;
}
dist = (1 - dist) * this.gunxishu + 1;
if (
this.atkdir.angle(
cc.v2(
onep.x - this.node.x,
onep.y - this.node.y
)
) <
0.0174 * this.autoangle * dist
) {
temp.push(cc.gameMgr.playerarr[i]);
}
}
}
}
//onep.pctrl.nd_miaozhun.opacity = 0
}
if (temp.length == 0) {
this.atktemp.x = this.atktemp.y = 0;
return;
}
if (this.shoting) {
//temp[0].pctrl.nd_miaozhun.opacity = 255
}
// if(cc.notShake){
// return
// }
var self = this;
temp = temp.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;
});
TempV2.x = temp[0].x - self.node.x;
TempV2.y = temp[0].y - self.node.y;
this.atktemp.lerp(TempV2, 0.9, this.atkdir2);
this.atktemp.x = this.atkdir2.x;
this.atktemp.y = this.atkdir2.y;
this.showmiaozhun(temp[0]);
if (autoshot && this.firemode == 2) {
this.lineNode.rotation =
-Math.atan2(TempV2.y, TempV2.x) * (180 / Math.PI); // + 45;
this.joyShotEnd();
this.lineNode.opacity = 255;
this.linehidetime = 0.2;
}
},
checkSavezombie() {
var needHide = true;
for (var i = cc.gameMgr.playerarr.length - 1; i >= 0; i--) {
var oneplayer = cc.gameMgr.playerarr[i];
if (
oneplayer.pctrl.isdown &&
this.action_type == 0 &&
Math.abs(this.node.x - oneplayer.x) < 50 &&
Math.abs(this.node.y - oneplayer.y) < 50
) {
cc.gameMgr.uic.btn_save.active = true;
this.saveId = oneplayer.objuuid;
needHide = false;
break;
}
}
if (needHide || this.isdown) {
cc.gameMgr.uic.btn_save.active = false;
}
},
checkSave() {
if (battlenet.gamemode == 1) {
this.checkSavezombie();
return;
}
var needHide = true;
for (var i = this.teamMembers.length - 1; i >= 0; i--) {
if (
this.teamMembers[i].downed &&
this.action_type == 0 &&
Math.abs(this.node.x - this.teamMembers[i].x) < 50 &&
Math.abs(this.node.y - this.teamMembers[i].y) < 50
) {
cc.gameMgr.uic.btn_save.active = true;
this.saveId = this.teamMembers[i].player_id;
needHide = false;
break;
}
}
if (needHide || this.isdown) {
cc.gameMgr.uic.btn_save.active = false;
}
},
isSafe() {
var dx = cc.gameMgr.centerVec.x - this.node.x;
var dy = cc.gameMgr.centerVec.y - this.node.y;
return (
dx * dx + dy * dy <= cc.gameMgr.safeLength * cc.gameMgr.safeLength
);
},
killSelf() {
this.spectate = true;
},
doselfrotate() {
if (this.suofangxiang > 0) {
return;
}
if (this.xuanyun > 0) {
return;
}
var rotdir;
if (!(this.atkdir2.x == 0 && this.atkdir2.y == 0)) {
rotdir = this.atkdir2;
} else {
rotdir = this.atkdir;
}
if (this.dianshedir) {
rotdir = this.dianshedir;
}
if (this.skilling) {
rotdir = this.joyskilldir;
}
if (!this.dirGo) {
this.dirGo = cc.v2(rotdir.y, rotdir.x);
}
this.dirGo.lerp(rotdir, 0.45, TempV2);
this.dirGo.x = TempV2.x;
this.dirGo.y = TempV2.y;
this.nd_display.rotation =
-Math.atan2(this.dirGo.y, this.dirGo.x) * (180 / Math.PI); // + 45;
if (this.nd_display.rotation > 180) {
this.nd_display.rotation = this.nd_display.rotation - 360;
}
},
checktihuan(idx) {
if (this.guns[idx] == 0) {
return true;
}
var nowguncfg = gameConfig.dropItemConfig[this.guns[idx]];
if (
this.nowItem.index_id == nowguncfg.index_id &&
this.nowItem.quality > nowguncfg.quality
) {
this.netGunidxDrop = idx;
this.switchGunNet(this.currentgunidx);
return false;
}
return true;
},
report() {
if (this.node.isSelf) {
this.packdata.move_dir = this.dir;
if (!(this.atkdir2.x == 0 && this.atkdir2.y == 0)) {
this.packdata.attack_dir = this.atkdir2;
} else {
this.packdata.attack_dir = this.atkdir;
}
this.packdata.shot_hold = this.shot_hold;
var drop = null;
if (!this.isdead() && !this.isdown && !this.sanmode) {
drop = cc.gameMgr.dropManager.getNearDrop(this.horsemode);
//cc.gameMgr.getNearJZ()//
}
if (drop) {
if (drop.dbid) {
this.get_onobj = null;
var dropdata = gameConfig.dropItemConfig[drop.dbid];
if (dropdata.equip_type == 9 || dropdata.equip_type == 10) {
if (cc.gameMgr.gameStart && !this.sanmode) {
cc.gameMgr.uic.lb_wname.string = dropdata.name;
cc.gameMgr.uic.nd_get.active = true;
this.nowItem = dropdata;
this.nowItemUUID = drop.objuuid;
} else {
cc.gameMgr.uic.nd_get.active = false;
}
} else if (dropdata.equip_type == 1) {
cc.gameMgr.uic.lb_wname.string = dropdata.name;
cc.gameMgr.uic.nd_get.active = true;
this.nowItem = dropdata;
this.pushObj(drop.objuuid);
this.checkcd += 1;
if (this.checkcd > 3) {
if (this.checktihuan(1)) {
this.checktihuan(2);
}
this.checkcd = 0;
}
} else {
cc.gameMgr.uic.nd_get.active = false;
this.pushObj(drop.objuuid);
}
} else {
cc.gameMgr.uic.lb_wname.string = 'get in';
cc.gameMgr.uic.nd_get.active = true;
this.get_onobj = drop.objuuid;
}
} else {
cc.gameMgr.uic.nd_get.active = false;
}
if (this.use_skill) {
this.packdata.use_skill = this.use_skill;
this.use_skill = undefined;
this.packdata.skill_id = this.skill_id;
this.skill_id = undefined;
}
if (this.skill_dir) {
this.packdata.skill_dir = this.skill_dir;
this.skill_dir = undefined;
}
if (this.saveskillboomDistance) {
this.packdata.skill_distance = this.saveskillboomDistance;
this.saveskillboomDistance = undefined;
}
if (this.isBoom || this.firemode == 2) {
this.packdata.shot_hold = undefined;
}
this.packdata.fly_distance = this.saveboomDistance;
if (this.saveboomDistance || this.dianshe) {
this.packdata.shot_start = true;
}
if (this.dianshedir) {
this.packdata.attack_dir = this.dianshedir;
this.dianshedir = undefined;
}
if (this.objarr.length > 0) {
this.packdata.interaction = true;
this.packdata.interaction_objids = this.objarr;
} else {
this.packdata.interaction = undefined;
this.packdata.interaction_objids = [];
}
this.packdata.select_weapon = this.netGunidx;
this.netGunidx = undefined;
if (this.netGunidxDrop && this.guns[this.netGunidxDrop] != 0) {
if (gameConfig.dropItemConfig[this.guns[this.netGunidxDrop]]) {
cc.gameMgr.playSound(
gameConfig.dropItemConfig[this.guns[this.netGunidxDrop]]
.sound_drow
); //
}
}
this.packdata.drop_weapon = this.netGunidxDrop;
this.netGunidxDrop = undefined;
this.packdata.cancel_action = this.cancel_action;
this.cancel_action = undefined;
this.packdata.use_item_idx = this.use_item_idx;
this.use_item_idx = undefined;
this.packdata.use_item_id = this.use_item_id;
this.use_item_id = undefined;
this.packdata.use_scope = this.netViewScale;
this.netViewScale = undefined;
this.packdata.reload = this.needReload;
this.needReload = undefined;
this.packdata.spectate = this.spectate;
this.spectate = undefined;
this.packdata.emote = this.emoteNet;
this.emoteNet = undefined;
this.packdata.jump = this.doJump;
this.doJump = undefined;
this.packdata.get_down = this.get_down;
this.get_down = undefined;
this.packdata.get_on = this.get_on;
this.get_on = undefined;
this.packdata.switch_seat = this.switch_seat;
this.switch_seat = undefined;
this.packdata.follow = this.netfollow_target;
this.netfollow_target = undefined;
this.packdata.skill_target_id = this.skill_target_id;
this.skill_target_id = undefined;
this.packdata.dive = this.dive;
this.dive = undefined;
if (this.miaozun != undefined) {
this.packdata.aiming = this.miaozun;
this.miaozun = undefined;
}
if (this.isdead()) {
this.packdata.move_dir = cc.v2(0, 0);
}
if (this.packdata.shot_hold || this.packdata.shot_start) {
if (
this.packdata.attack_dir.x == 0 &&
this.packdata.attack_dir.y == 0
) {
this.packdata.attack_dir.x = 0.8634294965692562;
this.packdata.attack_dir.y = 0.5044695277756237;
}
}
battlenet.move(this.packdata);
this.objarr.length = 0;
this.packdata.shot_start = undefined;
this.saveboomDistance = undefined;
this.dianshe = undefined;
this.packdata.use_skill = undefined;
}
},
updateNet(dt) {
if (this.targetGo) {
var move_dirx = this.targetGo.x - this.node.x;
var move_diry = this.targetGo.y - this.node.y;
if (
Math.abs(move_dirx) > 210 ||
Math.abs(move_diry) > 210 ||
this.quickstate
) {
this.node.x = this.targetGo.x;
this.node.y = this.targetGo.y;
} else {
this.node.position.lerp(this.targetGo, 0.16, TempV2);
this.node.x = TempV2.x;
this.node.y = TempV2.y;
}
this.leganicd -= dt;
if (this.leganicd < 0) {
if (
Math.abs(this.node.x - this.targetGo.x) < 0.5 &&
Math.abs(this.node.y - this.targetGo.y) < 0.5
) {
if (this.legstate != 1) {
this.legstate = 1; //idle
//this.wheelAni.pause()
}
} else {
if (this.legstate != 2) {
if (this.isrun) {
this.legstate = 2; //walk
} else {
this.legstate = 3;
}
// this.wheelAni.resume()
this.leganicd = 0.5;
//cc.gameMgr.maptile._layers[0].getTileGIDAt(10,7)
}
}
}
if (!this.dirGo) {
this.dirGo = cc.v2(this.netShotdir.y, this.netShotdir.x);
}
var delta = 15;
// if(!(this.atkdir2.x==0&&this.atkdir2.y==0)){
// delta=30
// }
this.dirGo.lerp(this.netShotdir, dt * delta, TempV2);
this.dirGo.x = TempV2.x;
this.dirGo.y = TempV2.y;
this.nd_display.rotation =
-Math.atan2(this.dirGo.y, this.dirGo.x) * (180 / Math.PI); // + 45;
if (this.nd_display.rotation > 180) {
this.nd_display.rotation = this.nd_display.rotation - 360;
}
}
if (true || this.node.isSelf) {
if (cc.gameMgr.maptile) {
var gid = 0;
var cds = cc.gameMgr.maptile._layers;
var px = Math.floor(this.node.x / 32);
var py =
cc.gameMgr.mapheight - Math.floor(this.node.y / 32) - 1;
px = Math.min(Math.max(0, px), cc.gameMgr.mapheight - 1);
py = Math.min(Math.max(0, py), cc.gameMgr.mapheight - 1);
for (var i = cds.length - 1; i >= 0; i--) {
var temp = cds[i].getTileGIDAt(px, py);
if (temp > 0 && cc.gameMgr.tiledata[temp - 1]) {
gid = Number(cc.gameMgr.tiledata[temp - 1]);
break;
}
}
if (gid != 0) {
if (this.nowmoveid != gid) {
var self = this;
this.parmove.spriteFrame = null;
cc.loader.loadRes(
'particle/' + tileConfig.tileres[gid],
cc.SpriteFrame,
function (err, res) {
if (!err && self.isValid) {
self.parmove.spriteFrame = res;
}
}
);
this.parmove.resetSystem();
this.nowmoveid = gid;
if (tileConfig.tileres2[gid] && !this.horsemode) {
this.anidixing.node.active = true;
this.anidixing.play(tileConfig.tileres2[gid]);
} else {
this.anidixing.node.active = false;
}
}
} else {
if (this.nowmoveid != 0) {
this.parmove.spriteFrame = null;
this.anidixing.node.active = false;
this.parmove.resetSystem();
}
this.nowmoveid = 0;
}
if (
this.inhouse ||
this.sanmode ||
this.fakemode ||
this.horsemode
) {
this.parmove.node.opacity = 0;
this.anidixing.node.opacity = 0;
} else {
if (this.legstate == 1) {
this.parmove.node.opacity = 0;
} else {
this.parmove.node.opacity = 255;
}
this.anidixing.node.opacity = 255;
}
}
}
},
pushObj(uuid) {
if (!uuid) {
return;
}
for (var i = this.objarr.length - 1; i >= 0; i--) {
if (this.objarr[i] == uuid) {
return;
}
}
this.objarr.push(uuid);
},
refreshTeam(data) {
if (data.length > 0) {
this.teamid = data[0].team_id;
}
var needrefesh = false;
if (this.teamMembers.length != data.length) {
needrefesh = true;
} else {
for (var i = this.teamMembers.length - 1; i >= 0; i--) {
if (this.teamMembers[i].player_id != data[i].player_id) {
needrefesh = true;
break;
}
}
}
if (needrefesh) {
this.teamMembers = [];
cc.gameMgr.uic.cleanTeam();
for (var i = 0; i < data.length; i++) {
this.teamMembers.push({
player_id: data[i].player_id,
x: 0,
y: 0,
health: 0,
dead: false,
downed: false,
disconnected: false,
maxhp: data[i].max_health,
name: data[i].name,
vip_lv: data[i].vip_lv,
head: data[i].head,
user_data: data[i].user_data,
hero_id: gameConfig.skintohero[data[i].skin[0].skin_id],
});
cc.gameMgr.uic.createTeam(this.teamMembers[i], i);
// if(cc.gameMgr.objMap[data[i].player_id]){
// cc.gameMgr.objMap[data[i].player_id].pctrl.setmember(data[i].name,i)
// }
}
}
for (var i = 0, l = data.length; i < l; i++) {
if (data[i].pos != undefined) {
this.teamMembers[i].x = data[i].pos.x;
}
if (data[i].pos != undefined) {
this.teamMembers[i].y = data[i].pos.y;
}
if (data[i].health != undefined) {
this.teamMembers[i].hp = data[i].health;
}
if (data[i].dead != undefined) {
this.teamMembers[i].dead = data[i].dead;
}
if (data[i].downed != undefined) {
this.teamMembers[i].downed = data[i].downed;
}
if (data[i].name != undefined) {
this.teamMembers[i].name = data[i].name;
}
if (data[i].vip_lv != undefined) {
this.teamMembers[i].vip_lv = data[i].vip_lv;
}
if (data[i].head != undefined) {
this.teamMembers[i].head = data[i].head;
}
if (cc.gameMgr.objMap[data[i].player_id]) {
//cc.gameMgr.objMap[data[i].player_id].pctrl.isMember = true
cc.gameMgr.objMap[data[i].player_id].pctrl.setmember(
this.teamMembers[i].name,
i
);
}
}
},
setmember(name, idx) {
if (name && this.lb_teamname.string != name) {
this.lb_teamname.string = name;
}
if (this.nd_team.active) {
return;
}
if (!name) {
name = cc.language.stringformat('nickname');
}
// this.pr_hp.node.active = true
this.isMember = true;
this.nd_member.active = true;
this.nd_team.active = true;
this.lb_teamname.string = name;
var self = this;
cc.loader.loadRes(
'textures/uires/mini-player' + (idx + 1),
cc.SpriteFrame,
function (err, res) {
if (!err && self.isValid) {
self.sp_teampoint.spriteFrame = res;
}
}
);
},
ChangeSkin() {
var id1 = this.nowSkin[0];
var id2 = this.nowSkin[1];
var id3 = this.nowSkin[2];
var id4 = this.nowSkin[3];
if (this.buffhead > 0) {
id1 = this.buffhead;
}
var self = this;
if (this.skinarr[0] != id1) {
//data
this.skinarr[0] = id1;
this.skinarr[1] = id2;
self.spineloaded = false;
///test
var skinid = this.skinarr[0];
if (this.buffhead > 0) {
skinid = this.buffhead;
}
//
cc.loader.loadRes(
'spine/player/hero' + skinid,
sp.SkeletonData,
function (err, sp) {
self.spineloaded = true;
self.skeleton.skeletonData = sp;
self.skeleton._updateSkeletonData();
self.nowAni = '';
self.skeleton.clearTrack(0);
self.skeleton.clearTrack(1);
self.skeleton.clearTrack(2);
self.skeleton.clearTrack(3);
// self.bones = self.skeleton.findBone("gun_slot")
if (self.initspine) {
self.skeleton.setAnimation(0, self.initspine, true);
self.initspine = null;
}
//self.skeleton.setSkin("Skin1")
}.bind(this)
);
} else if (this.skinarr[1] != id2) {
this.skinarr[1] = id2;
//self.skeleton.setSkin("Skin2")
}
},
getDefBar() {
return this.defhp / this.defhpMax;
},
checkDown(v) {
if (this.isdead()) {
this.nd_down.active = false;
}
if (this.isdown != v) {
this.isdown = v;
var isMember = this.isMember;
if (battlenet.gamemode == 1) {
isMember = true;
}
if (isMember || this.node.isSelf) {
this.nd_down.active = v;
} else {
this.nd_down.active = false;
}
this.nowAni = '';
this.shoting = false;
this.shot_hold = false;
this.atkdir2.x = this.atkdir2.y = 0;
this.dianshedir = undefined;
this.miaozun = undefined;
this.plusView = 0;
this.vhuiguitime = 0;
this.lineNode.opacity = 0;
if (this.nd_quan) {
this.nd_quan.opacity = 0;
}
}
},
refreshHpbar(behurt) {
var hbili = this.hp / this.maxhp;
if (this.node.isSelf || this.isMember || this.iswatching) {
this.bar_hp.color = cc.Color.GREEN;
this.nd_hp.opacity = 255;
} else {
this.bar_hp.color = cc.Color.RED;
if (behurt) {
this.hidehptime = 0.5;
this.nd_hp.opacity = 255;
}
}
// if (hbili > 0.6) {
// this.bar_hp.color = cc.Color.GREEN
// } else if (hbili > 0.3) {
// this.bar_hp.color = cc.Color.YELLOW
// } else {
// this.bar_hp.color = cc.Color.RED
// }
this.pr_hp.progress = hbili;
this.fixrefeshhp = false;
},
onrevive() {
this.dashtime = 0;
this.sleeptime = 0;
this.nowAni = '';
this.nd_dead.active = false;
//this.pr_hp.node.opacity = 255
this.ani_kill2.node.active = true;
this.nd_display.active = true;
this.nd_newbody.active = true;
//this.node.zIndex = 4
this.nd_shadow.opacity = 255;
this.anishootstop();
if (battlenet.gamemode == 1) {
this.dashtime = revive_time;
this.beforedash();
// this.anibodyplay(this.aniqianzui + "revive_jump")
this.huanlian();
if (this.node.isSelf) {
cc.Notifier.emit('playerrevive');
}
}
this.nd_buff.active = !this.nd_dead.active;
},
ondeadzombie(time) {
this.ondead();
if (this.node.isSelf) {
cc.gameMgr.uic.playerDead2(time);
}
},
ondead() {
this.plusView = 0;
this.vhuiguitime = 0;
this.defhp = 0;
this.nd_dead.active = true;
this.nd_display.active = false;
this.nd_down.active = false;
//this.pr_hp.node.opacity = 0
this.ani_kill2.node.active = false;
this.nd_shield.active = false;
this.nd_atkup.active = false;
// this.nd_shield.opacity = 0
// this.nd_atkup.opacity = 0
this.nd_newbody.active = false;
if (this.node.isSelf) {
this.nd_reload.active = false;
cc.gameMgr.uic.nd_get.active = false;
cc.gameMgr.uic.btn_save.active = false;
}
this.nd_shadow.opacity = 0;
this.nd_buff.active = !this.nd_dead.active;
},
refreshNetData(netdata) {
if (netdata.skin) {
for (var i = 0; i < 4; i++) {
this.nowSkin[i] = netdata.skin[i].skin_id;
}
this.ChangeSkin();
}
if (netdata.downed != undefined) {
this.checkDown(netdata.downed);
}
if (netdata.energy_shield != undefined) {
this.defhp = netdata.energy_shield;
}
if (netdata.max_energy_shield != undefined) {
this.defhpMax = netdata.max_energy_shield;
}
if (this.revivetime == 0) {
this.nd_shield.active = this.defhp > 0;
} else {
this.nd_shield.active = true;
}
if (netdata.max_health) {
this.maxhp = netdata.max_health;
if (this.hp > this.maxhp) {
this.hp = this.maxhp;
}
}
if (netdata.follow_target != undefined) {
this.follow_target = netdata.follow_target;
}
if (netdata.shoot_offset_x != undefined) {
this.shoot_offset_x = netdata.shoot_offset_x; // / this.node.scaleY
}
if (netdata.shoot_offset_y != undefined) {
this.shoot_offset_y = netdata.shoot_offset_y; /// this.node.scaleY
}
var addx = 0;
var addy = 0;
if (this.horsemode) {
addx = this.shoot_offset_x;
addy = this.shoot_offset_y;
this.pr_hp.node.opacity = 0;
// this.lineNode.y = this.shoot_offset_y
// this.lineNode.x = this.shoot_offset_x
// this.nd_ui2.x = this.shoot_offset_x
// this.nd_ui2.y = this.shoot_offset_y
} else {
this.pr_hp.node.opacity = 255;
// this.lineNode.y = 0
// this.lineNode.x = 0
// this.nd_ui2.x = 0
// this.nd_ui2.y = 0
this.shoot_offset_x = 0;
this.shoot_offset_y = 0;
}
if (this.targetGo) {
this.targetGo.x = netdata.pos.x + addx;
this.targetGo.y = netdata.pos.y + addy;
// if(this.node.isSelf){
// cc.log(this.targetGo)
// }
} else {
this.targetGo = cc.v2(netdata.pos.x + addx, netdata.pos.y + addy);
}
if (this.netShotdir) {
this.netShotdir.x = netdata.dir.x;
this.netShotdir.y = netdata.dir.y;
} else {
this.netShotdir = cc.v2(netdata.dir.x, netdata.dir.y);
}
if (netdata.car_uniid) {
this.car_uniid = netdata.car_uniid;
}
if (netdata.weapon && this.currentGun != netdata.weapon.weapon_id) {
this.currentGun = netdata.weapon.weapon_id;
this.nowgunlv = netdata.weapon.weapon_lv;
this.onChangeGunNet(netdata.weapon.weapon_lv);
}
if (battlenet.gamemode != 1) {
if (this.nd_dead.active && netdata.dead == false) {
this.onrevive();
}
if (netdata.dead && this.nd_dead.active == false) {
this.ondead();
var selfuuid = cc.gameMgr.playeruuid;
if (this.node.isSelf && !cc.gameMgr.playerDead) {
if (netdata.killer_id == selfuuid) {
cc.uiHelper.showTips(
cc.language.stringformat('beigandiao4')
);
} else {
cc.uiHelper.showTips(
cc.language.stringformat('beigandiao3', [
netdata.killer_name,
])
);
}
cc.gameMgr.playerDead = true;
cc.gameMgr.uic.playerDead(netdata);
}
}
}
var needhprefresh = false;
var behurt = false;
if (netdata.health != undefined) {
if (this.hp != netdata.health) {
needhprefresh = true;
}
if (this.hp > netdata.health) {
this.hurt();
behurt = true;
} else if (this.hp < netdata.health) {
this.ani_kill2.play('addhp');
}
this.hp = netdata.health;
}
if (needhprefresh || this.fixrefeshhp) {
this.refreshHpbar(behurt);
}
if (netdata.states) {
for (var i = netdata.states.length - 1; i >= 0; i--) {
var tp = netdata.states[i].state_type;
if (tp == 11) {
if (this.hp > 0) {
this.nd_atkup.active = true;
}
}
}
}
if (netdata.backpack) {
this.refreshbag(netdata.backpack);
}
if (netdata.buff_list) {
this.checkbuff(netdata.buff_list);
}
if (netdata.speed) {
this.checkspeed(netdata.speed);
}
if (netdata.attr_addition) {
this.refrshattrwithmap(netdata.attr_addition);
}
if (netdata.charid) {
this.refreshchar(netdata.charid);
}
// if(netdata.kill_count&&this.killCount<netdata.kill_count){
// this.killCount = netdata.kill_count
// }
if (this.lb_debug) {
this.lb_debug.string = this.node.objuuid;
}
},
refreshchar(charid) {
var pcfg = playerconfig[charid];
this.node.width = this.node.height = pcfg.hit_radius * 2;
this.node.zplus = this.node.height / this.node.scaleY / 2 - 50;
if (cc.battledebug) {
if (!this.chapz) {
var debugnode = new cc.Node();
this.node.addChild(debugnode);
var sprite = debugnode.addComponent('cc.Sprite');
sprite.sizeMode = 0;
cc.loader.loadRes('btn1', cc.SpriteFrame, function (err, res) {
if (!err) {
sprite.spriteFrame = res;
}
});
var debugnode2 = new cc.Node();
this.node.addChild(debugnode2);
var sprite2 = debugnode2.addComponent('cc.Sprite');
sprite2.sizeMode = 0;
cc.loader.loadRes('btn1', cc.SpriteFrame, function (err, res) {
if (!err) {
sprite2.spriteFrame = res;
}
});
debugnode.opacity = 160;
debugnode2.opacity = 160;
debugnode.zIndex = 999;
debugnode2.zIndex = 1000;
debugnode2.color = cc.Color.RED;
debugnode.width = debugnode.height =
(pcfg.hit_radius * 2) / this.node.scaleY;
debugnode2.y = pcfg.move_offset_y / this.node.scale;
debugnode2.width = debugnode2.height =
(pcfg.radius * 2) / this.node.scaleY;
this.chapz = true;
var Labelnode = new cc.Node();
this.node.addChild(Labelnode);
this.lb_debug = Labelnode.addComponent('cc.Label');
Labelnode.zIndex = 1001;
}
}
},
refreshbag(bag) {},
onChangeGunNet(lv) {
if (!lv) {
lv = 1;
}
this.vhuiguitime = 0.2;
this.sp_boom.active = false;
this.isBoom = false;
this.boomDistance = 0;
this.shotcd = 0;
if (this.action_duration <= 0) {
if (this.nd_reload) {
this.nd_reload.active = false;
}
}
this.isshothand = false;
this.needline = false;
var gunid = this.currentGun;
if (this.currentGunzuoqi > 0) {
gunid = this.currentGunzuoqi;
}
var gundata = gameConfig.dropItemConfig[gunid];
if (!gundata) {
return;
}
this.plusshotname = gundata.equip_subtype == 2 ? '' : '_rifle';
this.gunsub = gundata.equip_subtype;
if (gundata.id == 30101) {
this.weaponstate = 0;
} else if (gundata.equip_type == 1) {
if (gundata.equip_subtype == 1) {
this.weaponstate = 1;
this.otherani = 'replace_weapon3';
this.othertime = ani_replace_weapon_time;
//this.needline = true
} else {
this.isshothand = true;
this.weaponstate = 2;
this.otherani = 'replace_weapon';
this.othertime = ani_replace_weapon_time;
this.needline = true;
}
} else if (gundata.equip_type == 3) {
if (this.sleeptime <= 0) {
this.otherani = 'replace_weapon4';
this.othertime = ani_replace_weapon_time_boom;
}
this.isBoom = true;
this.maxlength = gundata.range;
if (gundata.range_min != undefined) {
this.minlength = gundata.range_min;
} else {
this.minlength = 50;
}
this.weaponstate = 3;
}
var self = this;
if (gundata.world_img && this.weaponstate != 0) {
self.sp_w1.spriteFrame = null;
var cb = function (nd) {
if (self.gunpb) {
self.huishouprefab(self.gunpb.pname, self.gunpb);
self.gunpb = null;
}
nd.pname = gundata.world_img;
nd.scale = 1;
self.gunpb = nd;
self.nd_pbgun.addChild(nd);
var cmp = nd.getComponent(cc.Animation);
if (cmp) {
cmp.play(nd.pname + '_' + lv);
}
};
this.createprefab(gundata.world_img, 'prefabs/gunprefab/', cb);
} else {
if (self.gunpb) {
self.huishouprefab(self.gunpb.pname, self.gunpb);
self.gunpb = null;
}
self.sp_w1.spriteFrame = null;
}
this.firemode = gundata.fire_mode;
this.gunrate = gundata.fire_rate / 1000;
// this.shotdistance = gundata.range*gundata.range
if (gundata.auto_angle) {
this.autoangle = gundata.auto_angle;
} else {
this.autoangle = 0;
}
if (gundata.auto_angle2) {
this.gunxishu = gundata.auto_angle2;
}
this.nowAni = '';
this.auto_area = gundata.auto_area;
if (gundata.shootfire_dev) {
this.nd_shotrff.anchorX = Number(
gundata.shootfire_dev.split('|')[lv - 1]
);
} else {
this.nd_shotrff.anchorX = 0.5;
}
this.changeshotmode();
},
switchGunNet(idx) {
this.netGunidx = idx;
},
getTimeBar() {
return this.hptime / this.hptimeMax;
},
updateActive(data) {
for (var i = data.states.length - 1; i >= 0; i--) {
var tp = data.states[i].state_type;
if (tp == 1) {
this.hptime = data.states[i].left_time / 1000;
this.hptimeMax = data.states[i].lasting_time / 1000;
}
}
// cc.gameMgr.watchPlayer.pctrl.iswatching = false
// this.iswatching = true
// if (data.skill_left_time != undefined) {
// this.skill_left_time = data.skill_left_time / 1000
// }
// if (data.skill_cd_time != undefined) {
// this.skill_cd_time = data.skill_cd_time / 1000
// }
if (data.attr_addition) {
this.refrshattrwithmap(data.attr_addition);
}
if (data.shoot_offset_x != undefined) {
this.shoot_offset_x = data.shoot_offset_x; /// this.node.scaleY
}
if (data.shoot_offset_y != undefined) {
this.shoot_offset_y = data.shoot_offset_y; /// this.node.scaleY
}
if (data.skill_list && data.skill_list.length > 0) {
var needrefrshs = false;
if (this.skillcdarr.length != data.skill_list.length) {
needrefrshs = true;
} else {
for (var jj = 0; jj < this.skillcdarr.length; jj++) {
if (
this.skillcdarr[jj].skill_id !=
data.skill_list[jj].skill_id
) {
needrefrshs = true;
break;
}
}
}
if (needrefrshs) {
cc.gameMgr.uic.onchangeskill(data.skill_list);
var scfg = skillConfig[data.skill_list[1].skill_id];
this.skillmaxdis = scfg.range;
var self = this;
if (this.nd_baseskill) {
this.nd_baseskill.destyoy();
this.nd_baseskill = null;
}
cc.loader.loadRes(
'prefabs/skillprefab/' + scfg.skill_line,
cc.Prefab,
function (err, res) {
//
if (!err && self.isValid) {
let nd = cc.instantiate(res);
self.nd_quan.addChild(nd);
self.nd_baseskill = nd;
}
}
);
}
this.skillcdarr = data.skill_list;
cc.gameMgr.uic.refrehskill(this);
}
//
for (var i = data.weapons.length - 1; i >= 0; i--) {
this.gunsammo[i] = data.weapons[i].ammo;
if (data.weapons[i].weapon_id != this.guns[i]) {
//console.log("jjjjweapon_id:"+ this.guns[i] + "idx:" +i)
this.guns[i] = data.weapons[i].weapon_id;
cc.Notifier.emit('getGun', {
idx: i,
lv: data.weapons[i].weapon_lv,
});
if (
data.weapons[i] &&
data.weapons[i].weapon_id != 0 &&
gameConfig.dropItemConfig[data.weapons[i].weapon_id]
) {
cc.gameMgr.playSound(
gameConfig.dropItemConfig[data.weapons[i].weapon_id]
.sound_pickup
);
}
}
}
if (this.currentgunidx != data.cur_weapon_idx) {
cc.Notifier.emit('switchGun', data.cur_weapon_idx);
this.currentgunidx = data.cur_weapon_idx;
if (this.guns[this.currentgunidx] != 0) {
var oneguncfg =
gameConfig.dropItemConfig[this.guns[this.currentgunidx]];
if (oneguncfg) {
if (oneguncfg.equip_type == 1) {
cc.loader.loadRes(
'icons/' + guntppic[oneguncfg.equip_subtype],
cc.SpriteFrame,
function (err, res) {
if (!err) {
cc.gameMgr.uic.sp_shotpoint.spriteFrame =
res;
}
}
);
} else if (oneguncfg.equip_type == 3) {
cc.loader.loadRes(
'icons/' + shouleipic,
cc.SpriteFrame,
function (err, res) {
if (!err) {
cc.gameMgr.uic.sp_shotpoint.spriteFrame =
res;
}
}
);
}
cc.gameMgr.playSound(oneguncfg.sound_pickup);
}
}
}
cc.Notifier.emit('changeguncount');
var wdata = data.weapons[data.cur_weapon_idx];
if (this.currentGunzuoqi == 0) {
// var equipattr = null
// if (gameConfig.equipUpgradeConfig[wdata.weapon_id]) {
// equipattr = gameConfig.equipUpgradeConfig[wdata.weapon_id].spera_attr
// }
if (gameConfig.dropItemConfig[wdata.weapon_id].shoot_view) {
this.saveview =
gameConfig.dropItemConfig[wdata.weapon_id].shoot_view;
this.saveviewadd = 0; //Utils.findvarbylv(12, wdata.weapon_lv, equipattr)
} else {
this.saveview = 0;
this.plusView = 0;
this.saveviewadd = 0;
}
if (gameConfig.dropItemConfig[wdata.weapon_id].fixed_view) {
this.weaponView =
gameConfig.dropItemConfig[wdata.weapon_id].fixed_view;
this.weaponView2 = this.weaponView;
} else {
this.weaponView = 0;
this.weaponView2 = 0;
}
this.gudingview = 0; //Utils.findvarbylv(13, wdata.weapon_lv, equipattr)
} else {
this.saveview = 0;
this.plusView = 0;
this.saveviewadd = 0;
this.gudingview = 0;
this.weaponView = 0;
}
if (
data.action_type != undefined &&
this.action_frameno != data.action_frameno
) {
this.action_frameno = data.action_frameno;
this.action_type = data.action_type;
if (this.action_type == 0) {
if (this.nd_reload) {
this.nd_reload.active = false;
}
this.showEmoteNetAnimation(9999);
} else {
if (this.action_type == 1) {
cc.gameMgr.uic.lb_reloaddes.string =
cc.language.stringformat('zhuantian');
var reloattime = slowswitch;
if (this.nd_reload && this.nd_reload == false) {
if (
gameConfig.dropItemConfig[
this.guns[this.currentgunidx]
]
) {
cc.gameMgr.playSound(
gameConfig.dropItemConfig[
this.guns[this.currentgunidx]
].sound_reload
); //
} else {
cc.log(
'eeeeeeeeeeeeee : idx ' +
this.guns[this.currentgunidx]
);
}
}
if (
gameConfig.dropItemConfig[this.guns[this.currentgunidx]]
) {
reloattime =
gameConfig.dropItemConfig[
this.guns[this.currentgunidx]
].reload_time;
}
if (reloattime <= slowswitch) {
this.showEmoteNetAnimation(1003);
} else if (reloattime >= longswitch) {
this.showEmoteNetAnimation(11005);
} else {
this.showEmoteNetAnimation(11004);
}
} else if (this.action_type == 2) {
cc.gameMgr.uic.lb_reloaddes.string =
cc.language.stringformat('zhiliao');
} else if (this.action_type == 3) {
cc.gameMgr.uic.lb_reloaddes.string =
cc.language.stringformat('jiuyuan');
} else if (this.action_type == 4) {
cc.gameMgr.uic.lb_reloaddes.string =
cc.language.stringformat('jiuyuan');
}
if (this.nd_reload) {
this.nd_reload.active = true;
}
}
if (data.action_duration != undefined) {
this.action_duration = data.action_duration / 1000;
this.totalaction_duration = this.action_duration;
}
}
if (this.hat != data.helmet) {
this.hat = data.helmet;
if (this.hat != 0) {
if (gameConfig.dropItemConfig[this.hat]) {
cc.gameMgr.playSound(
gameConfig.dropItemConfig[this.hat].sound_pickup
);
}
}
cc.gameMgr.uic && cc.gameMgr.uic.onGetHat(this.hat);
}
if (this.cloth != data.chest) {
this.cloth = data.chest;
if (this.cloth != 0) {
if (gameConfig.dropItemConfig[this.cloth]) {
cc.gameMgr.playSound(
gameConfig.dropItemConfig[this.cloth].sound_pickup
);
}
}
cc.gameMgr.uic && cc.gameMgr.uic.onGeCloth(this.cloth);
}
if (this.backpack != data.backpack) {
this.backpack = data.backpack;
if (this.backpack != 0) {
if (gameConfig.dropItemConfig[this.backpack]) {
cc.gameMgr.playSound(
gameConfig.dropItemConfig[this.backpack].sound_pickup
);
}
}
cc.gameMgr.uic && cc.gameMgr.uic.onGetBag(this.backpack);
}
for (var i = 0; i < 5; i++) {
//this.bulletArr[i] = data.inventory[i]
}
if (data.weapons && data.weapons[1]) {
// cc.gameMgr.uic.lb_bulletCount.string = data.weapons[1].ammo
if (data.weapons[1].weapon_id != 0) {
var usebullet =
gameConfig.dropItemConfig[
gameConfig.dropItemConfig[data.weapons[1].weapon_id]
.use_bullet
].inventory_slot;
this.btotal1 = data.weapons[1].volume; //data.inventory[usebullet]
cc.gameMgr.uic.lb_bulletCount.string =
data.weapons[1].ammo + '/' + this.btotal1;
this.nowgunbullet1 = data.weapons[1].ammo;
}
}
if (data.weapons && data.weapons[2]) {
//cc.gameMgr.uic.lb_bulletCount2.string = data.weapons[2].ammo
if (data.weapons[2].weapon_id != 0) {
var usebullet =
gameConfig.dropItemConfig[
gameConfig.dropItemConfig[data.weapons[2].weapon_id]
.use_bullet
].inventory_slot;
this.btotal2 = data.weapons[2].volume; //data.inventory[usebullet]
cc.gameMgr.uic.lb_bulletCount2.string =
data.weapons[2].ammo + '/' + this.btotal2;
this.nowgunbullet2 = data.weapons[2].ammo;
}
}
if (this.guns[1] == 0) {
cc.gameMgr.uic.lb_bulletCount.string = ' ';
}
if (this.guns[2] == 0) {
cc.gameMgr.uic.lb_bulletCount2.string = ' ';
}
if (data.inventory[7] > this.yaoArr[0]) {
if (!this.choseyidx) {
this.choseyidx = 7;
this.yaoArr[0] = data.inventory[7];
// cc.gameMgr.uic.refreshyaoidx(0)
}
if (gameConfig.dropItemConfig[30301]) {
cc.gameMgr.playSound(
gameConfig.dropItemConfig[30301].sound_pickup
);
}
}
if (data.inventory[8] > this.yaoArr[1]) {
if (!this.choseyidx) {
this.choseyidx = 8;
this.yaoArr[1] = data.inventory[8];
// cc.gameMgr.uic.refreshyaoidx(1)
}
if (gameConfig.dropItemConfig[30302]) {
cc.gameMgr.playSound(
gameConfig.dropItemConfig[30302].sound_pickup
);
}
}
this.yaoArr[0] = data.inventory[7];
this.yaoArr[1] = data.inventory[8];
this.yaoArr[2] = data.inventory[9];
this.glassArr[1] = data.inventory[13];
this.glassArr[2] = data.inventory[14];
this.glassArr[3] = data.inventory[15];
this.switchView(data.cur_scope);
cc.gameMgr.uic.onGetGlass(this.viewScaleIdx);
cc.gameMgr.uic.refreshItem();
if (data.items) {
var len = data.items.length;
this.fakearr = [];
this.bagmap = {};
//[{id:17001,count:0},{id:17002,count:0},{id:17003,count:10},{id:17004,count:20},]
//if (this.fakearr.length == 0) {
for (var i = 0; i < len; i++) {
var tep = {
id: data.items[i].key,
count: data.items[i].value,
};
this.bagmap[tep.id] = tep.count;
var eqtype = gameConfig.dropItemConfig[tep.id].equip_type;
if (eqtype == 11) {
if (tep.count > 0) {
this.getfake = true;
}
this.fakearr.push(tep);
}
}
// }
}
if (data.dive_oxygen_curr) {
this.pr_yangqi.progress =
data.dive_oxygen_curr / data.dive_oxygen_max;
}
},
showEmoteNet(idx) {
if (idx >= this.emote.length) {
return;
}
this.emoteNet = Number(this.emote[idx]);
},
showEmoteNetAnimation(idx) {
this.emoteNet = idx;
},
doshowEmote() {
this.nd_emote.active = true;
this.nd_emote.scale = 0;
this.nd_emote.stopAllActions();
var self = this;
var cb = cc.callFunc(function () {
self.nd_emote.active = false;
});
this.nd_emote.runAction(
cc.sequence(cc.scaleTo(0.2, 1), cc.delayTime(1), cb)
);
},
huanlian() {
this.emoteing = true;
},
showEmote(id) {
if (this.dashtime > 0) {
return;
}
if (id > 1000) {
if (this.iszombi || this.sanmode || this.flymode) {
return;
}
if (id == 1001) {
this.otherani = 'add_hp2_front';
this.othertime = ani_add_hp_time1;
this.huanlian();
this.yaotime = 0;
cc.gameMgr.playSound('game_use_healthkit', this.node.position);
} else if (id == 1002) {
this.otherani = 'rescue';
this.othertime = ani_rescue_time;
this.huanlian();
} else if (id == 1003 || id == 11004 || id == 11005) {
if (id == 1003) {
this.otherani = 'reload_bullet';
this.othertime = ani_reload_bullet_time;
} else if (id == 11004) {
this.otherani = 'reload_bullet';
this.othertime = ani_reload_bullet_time1;
} else {
this.otherani = 'reload_bullet';
this.othertime = ani_reload_bullet_time2;
}
if (gameConfig.dropItemConfig[this.currentGun]) {
this.othertime =
gameConfig.dropItemConfig[this.currentGun].reload_time /
1000;
}
this.emoteing = false;
} else if (id == 1004) {
this.otherani = 'add_hp_front';
this.othertime = ani_add_hp_time2;
this.huanlian();
this.yaotime = 0;
cc.gameMgr.playSound('game_use_pills', this.node.position);
} else if (id == 1005) {
this.otherani = 'add_hp3_front';
this.othertime = ani_add_hp_time3;
this.huanlian();
this.yaotime = 0;
cc.gameMgr.playSound('game_use_healthkit', this.node.position);
} else if (id == 9999 && this.skillbuding <= 0) {
if (this.othertime > 0) {
this.othertime = 0.1;
this.otherani = null;
}
}
return;
}
var tex = baseconfig.emoteConfig[id];
var self = this;
cc.loader.loadRes(
'textures/emote/' + tex,
cc.SpriteFrame,
function (err, res) {
if (!err && self.isValid) {
self.sp_emote.spriteFrame = res;
self.doshowEmote();
}
}
);
},
chged_property(v) {
if (v.property_type == 1) {
var behurt = false;
if (this.hp > v.value) {
this.hurt();
behurt = true;
}
this.hp = v.value;
this.refreshHpbar(behurt);
} else if (v.property_type == 10) {
if (v.property_subtype == 1) {
this.nowgunbullet1 = v.value;
cc.gameMgr.uic.lb_bulletCount.string =
v.value + '/' + this.btotal1;
} else if (v.property_subtype == 2) {
this.nowgunbullet2 = v.value;
cc.gameMgr.uic.lb_bulletCount2.string =
v.value + '/' + this.btotal2;
}
this.gunsammo[v.property_subtype] = v.value;
if (v.property_subtype > 2 && this.node.isSelf) {
cc.director.emit('changeguncount');
}
} else if (v.property_type == 2) {
this.maxhp = v.value;
if (this.hp > this.maxhp) {
this.hp = this.maxhp;
}
this.refreshHpbar();
}
// else if(v.property_type==3){
// // var ammo = v.value
// // this.currentgunidx ==0?cc.gameMgr.uic.lb_bulletCount.string = "" :cc.gameMgr.uic.lb_bulletCount.string = ammo
// }
else if (v.property_type == 4) {
// this.skill_left_time = v.value / 1000
} else if (v.property_type == 5) {
// this.skill_cd_time = v.value / 1000
} else if (v.property_type == 6) {
} else if (v.property_type == 7) {
if (v.property_subtype == 1) {
this.maxtankhp = v.value;
} else if (v.property_subtype == 0) {
cc.gameMgr.uic.pr_tankhp.progress = v.value / this.maxtankhp;
if (v.value > 0) {
cc.gameMgr.uic.nd_tanknohp.active = false;
} else {
cc.gameMgr.uic.nd_tanknohp.active = true;
}
}
}
// else if(v.property_type==8){
// //cc.gameMgr.uic.lb_bulletCount.string = v.value
// }
else if (v.property_type == 9) {
var wid = v.property_subtype;
var count = v.value;
this.bagmap[wid] = count;
for (var i = 0; i < this.fakearr.length; i++) {
if (this.fakearr[i].id == wid) {
this.fakearr[i].count = count;
if (count > 0) {
this.getfake = true;
}
break;
}
}
} else if (v.property_type == 23) {
this.zombiechage = true;
} else if (v.property_type == 24) {
var sid = v.property_subtype;
for (var i = this.skillcdarr.length - 1; i >= 0; i--) {
if (this.skillcdarr[i].skill_id == sid) {
this.skillcdarr[i].left_time = v.value;
break;
}
}
} else if (v.property_type == 25) {
var sid = v.property_subtype;
for (var i = this.skillcdarr.length - 1; i >= 0; i--) {
if (this.skillcdarr[i].skill_id == sid) {
this.skillcdarr[i].curr_times = v.value;
break;
}
}
if (this.node.isSelf) {
cc.gameMgr.uic.refrehskill(this);
}
} else if (v.property_type == 11) {
this.car_uniid = v.value;
} else if (v.property_type == 28) {
this.updatemapv(v.property_subtype, v.value, true);
} else if (v.property_type == 29) {
this.updatemapv(v.property_subtype, v.value, false);
} else if (v.property_type == 30) {
this.follow_target = v.value;
} else if (v.property_type == 31) {
this.pr_yangqi.progress = v.value / v.property_subtype;
} else if (v.property_type == 32) {
var sid = v.property_subtype;
for (var i = this.skillcdarr.length - 1; i >= 0; i--) {
if (this.skillcdarr[i].skill_id == sid) {
this.skillcdarr[i].exp = v.value;
break;
}
}
if (this.node.isSelf) {
cc.gameMgr.uic.refrehskill(this);
}
}
},
changefollow(v) {
this.netfollow_target = v;
},
removebuffeff(pbname) {
if (this.buffmap[pbname] && this.buffmap[pbname] != 'loading') {
var pbnd = this.buffmap[pbname];
var quickremove = true;
for (var i = this.pararr.length - 1; i >= 0; i--) {
if (this.pararr[i].resname == pbname) {
this.pararr[i].duration = 0;
this.pararr[i].blifetime = 1;
// this.pararr.splice(i, 1);
quickremove = false;
break;
}
}
for (var i = this.uppnoearr.length - 1; i >= 0; i--) {
if (this.uppnoearr[i].resname == pbname) {
this.uppnoearr[i].blifetime = rayhide;
this.uppnoearr[i].opacity = 254;
quickremove = false;
// this.uppnoearr.splice(i, 1);
break;
}
}
for (var i = this.uppnoearr2.length - 1; i >= 0; i--) {
if (this.uppnoearr2[i].resname == pbname) {
this.uppnoearr2[i].blifetime = 0;
quickremove = false;
this.huishoulooteff(
this.uppnoearr2[i].resname,
this.uppnoearr2[i]
);
this.uppnoearr2.splice(i, 1);
break;
}
}
if (quickremove) {
this.huishoulooteff(pbname, pbnd);
}
}
this.buffmap[pbname] = null;
},
addbuffeff(pbname, efftype, bdata) {
var addnd = this.nd_buff;
if (efftype == 39) {
addnd = this.nd_buffgun;
if (bdata.bulletfire || bdata.needrotate) {
addnd = cc.gameMgr.ndeff;
}
}
if (bdata.needrotate) {
addnd = cc.gameMgr.ndeff;
}
if (pbname && !this.buffmap[pbname]) {
this.buffmap[pbname] = 'loading';
this.createlooteff(pbname, (res) => {
if (bdata.bulletfire) {
var par = res.getComponent(cc.ParticleSystem);
if (par) {
par.targetrot = this.nd_buffgun;
par.duration = -1;
par.blifetime = 9999;
par.resname = pbname;
this.pararr.push(par);
} else {
res.blifetime = 9999;
res.opacity = 255;
res.resname = pbname;
res.scaleY = 1;
this.uppnoearr.push(res);
}
} else if (bdata.needrotate) {
res.blifetime = 9999;
res.resname = pbname;
this.uppnoearr2.push(res);
}
addnd.addChild(res);
if (this.buffmap[pbname]) {
this.buffmap[pbname] = res;
} else {
this.huishoulooteff(pbname, res);
}
});
}
},
getBuffByEffectId(effectId) {
for (var i = 0, l = this.buffidarr.length; i < l; i++) {
var buffConf = gameConfig.buffConfig[this.buffidarr[i].buff_id];
if (buffConf.buff_effect == effectId) {
return this.buffidarr[i];
}
}
return null;
},
getBuffById(buffId) {
for (var i = 0, l = this.buffidarr.length; i < l; i++) {
if (buffidarr[i].buff_id == buffId) {
return buffidarr[i];
}
}
return null;
},
checkbuff(list) {
var horsemode = false;
var fakemode = false;
var buffhead = -1;
this.buffidarr = list;
this.node.opacity = 255;
this.xuanyun = 0;
this.chuantou = 0;
this.suofangxiang = 0;
var oldsanmode = false;
// if(this.node.isSelf){
// cc.log("buff1111")
// }
this.kct = false;
var bufanicount = 0;
for (var i = 0, l = list.length; i < l; i++) {
var efftp = gameConfig.buffConfig[list[i].buff_id].buff_effect;
if (gameConfig.buffConfig[list[i].buff_id].direction) {
this.suofangxiang++;
}
if (efftp == 51 || efftp == 52) {
horsemode = true;
this.horseid =
gameConfig.buffConfig[list[i].buff_id].buff_param4;
//break
} else if (efftp == 5) {
fakemode = true;
this.fakeid =
gameConfig.buffConfig[list[i].buff_id].buff_param1;
if (gameConfig.buffConfig[list[i].buff_id].buff_param2) {
this.kct = true;
}
// break
} else if (efftp == 6) {
this.node.active = false;
} else if (efftp == 38) {
buffhead = gameConfig.buffConfig[list[i].buff_id].buff_param1;
} else if (efftp == 23) {
this.cannotzimiao = true;
} else if (efftp == 24) {
this.node.opacity = 0;
} else if (efftp == 25) {
oldsanmode = true;
this.nowtime =
(list[i].lasting_time - list[i].left_time) / 1000;
//this.nowtime = this.lerpv(this.noewtime,(list[i].lasting_time-list[i].left_time)/1000,0.7)
this.totaltime = list[i].lasting_time / 1000;
} else if (efftp == 32) {
if (this.node.isSelf) {
this.node.opacity = yinshentouming;
} else {
this.node.opacity = 0;
}
} else if (efftp == 14) {
// bufanicount++
// this.buffanistring = gameConfig.buffConfig[list[i].buff_id].buff_param1
} else if (efftp == 15) {
this.xuanyun++;
// console.log("jjjj check:" + this.xuanyun)
} else if (efftp == 48) {
this.chuantou++;
}
if (gameConfig.buffConfig[list[i].buff_id].buff_ef) {
this.addbuffeff(
gameConfig.buffConfig[list[i].buff_id].buff_ef,
efftp,
gameConfig.buffConfig[list[i].buff_id]
);
}
}
//this.buffanimode = bufanicount
if (this.sanmode != oldsanmode) {
this.sanmode = oldsanmode;
this.changesan();
}
// if(bufaniname!=this.bufaniname){
// this.bufaniname = bufaniname
// if(bufaniname!=""){
// this.anibuff.node.active = true
// this.anibuff.play(bufaniname)
// }else{
// this.anibuff.node.active = false
// this.anibuff.stop()
// }
// }
if (this.horsemode != horsemode) {
this.horsemode = horsemode;
this.dohorse();
this.nowAni = '';
}
if (this.fakemode != fakemode) {
this.fakemode = fakemode;
this.dofake();
this.nowAni = '';
}
if (buffhead != this.buffhead) {
this.buffhead = buffhead;
this.ChangeSkin();
}
},
changeBuff(res) {
//console.log(res)
var chg = res.chg;
if (chg == 0) {
this.addBuff(res.buff);
} else if (chg == 1) {
this.removeBuff(res.buff.buff_id, res.buff);
}
},
beforedash() {
this.sethandrotation();
this.nowAni = '';
this.anishootstop();
this.othertime = 0;
this.otherani = null;
this.sleeptime = 0;
},
dozombieskill() {},
addBuff(buff) {
var bid = buff.buff_id;
var bdata = gameConfig.buffConfig[bid];
var needhidem = false;
var needhides = false;
if (bdata.direction) {
this.suofangxiang++;
}
if (bdata.buff_effect == 2) {
this.dodash(bdata.buff_param5);
} else if (bdata.buff_effect == 51 || bdata.buff_effect == 52) {
//
this.horsemode = true;
if (this.node.isSelf) {
var cardata = gameConfig.dropItemConfig[buff.params[0]];
var ccount = Number(cardata.param2);
if (ccount > 1) {
if (bdata.buff_effect == 51) {
//
needhides = true;
} else if (bdata.buff_effect == 52) {
//
needhidem = true;
}
}
}
this.dohorse(true);
// if(this.objMap[this.car_uniid]){
// this.objMap[this.car_uniid].pctrl.dobirth()
// }
// this.horseid = bdata.buff_param4
// this.dohorse(true)
// cc.gameMgr.playSound(this.horseqianzui + "horse_hide", this.node.position)
// this.dashtime = ani_horse_time
// this.beforedash()
// this.anibodyplay(this.horseqianzui + "horse_hide")
} else if (bdata.buff_effect == 4) {
this.revivetime = revive_time;
this.dashtime = revive_time;
this.beforedash();
// this.anibodyplay(this.aniqianzui + "revive_jump")
this.huanlian();
} else if (bdata.buff_effect == 5) {
this.fakemode = true;
this.fakeid = bdata.buff_param1;
this.dofake();
this.dashtime = ani_fake_time;
this.beforedash();
this.anibodystop();
this.nd_newbody.opacity = 255;
this.sp_fake.node.scale = 0;
var self = this;
var spname = 'cosplay';
var cocosname = 'cosplay_smoke';
if (this.fakeid == 30707) {
spname = 'dive';
cocosname = 'eff_ground4_1';
}
var cb = cc.callFunc(function () {
self.nd_newbody.opacity = 0;
self.sp_fake.node.scale = 1;
});
this.nd_newbody.runAction(
cc.sequence(cc.delayTime(fakehidetime), cb)
);
this.parfake.getComponent(cc.Animation).play(cocosname);
// self.scheduleOnce(function() {
// self.parfake.getComponent(cc.Animation).play(cocosname)
// // self.scheduleOnce(function() {
// // self.parfake.active = false
// // }, 2);
// }, fakesmoketime);
if (bdata.buff_param2) {
this.kct = true;
}
// this.sp_fake.node.scale = 0
this.anibodyplay(spname);
} else if (bdata.buff_effect == 6) {
this.node.active = false;
} else if (bdata.buff_effect == 7 || bdata.buff_effect == 13) {
// this.dashtime = revive_time
// this.beforedash()
// // this.anibodyplay(this.aniqianzui + "revive_jump")
// this.huanlian()
// this.buffhead = bdata.buff_param2
// this.buffbody = bdata.buff_param3
//this.ChangeSkin()
} else if (bdata.buff_effect == 14) {
var canadd = true;
if (bdata.anicondition == 1) {
if (this.currentgunidx == 0 && this.guns[0] == 30101) {
canadd = false;
}
}
if (canadd) {
this.dashtime = 0;
this.buffanimode++;
this.buffanistring = bdata.buff_param1;
}
} else if (bdata.buff_effect == 9) {
this.quickstate = true;
} else if (bdata.buff_effect == 23) {
this.cannotzimiao = true;
} else if (bdata.buff_effect == 24) {
if (this.node.isSelf) {
this.cleanskilltouch();
cc.gameMgr.doplane();
this.flymode = true;
}
} else if (bdata.buff_effect == 25) {
//
if (this.node.isSelf) {
cc.gameMgr.dotiaosan(buff.lasting_time / 1000);
this.joyShotEnd();
}
this.dotiaosan(buff.lasting_time / 1000);
this.sanmode = true;
this.changesan();
} else if (bdata.buff_effect == 32) {
var vv = 0;
if (this.node.isSelf) {
vv = yinshentouming;
}
this.node.runAction(cc.fadeTo(0.2, vv));
} else if (bdata.buff_effect == 55) {
this.houzuoli = 0.2;
var ifront = this.sethandrotation();
var nstr = ifront ? 'recoil_front' : 'recoil_back';
this.anishootstop();
this.anibodyplay(nstr);
} else if (bdata.buff_effect == 38) {
this.buffhead = bdata.buff_param1;
this.ChangeSkin();
} else if (bdata.buff_effect == 15) {
this.xuanyun++;
// console.log("jjjj add")
} else if (bdata.buff_effect == 48) {
this.chuantou++;
}
if (bdata.buff_ef) {
this.addbuffeff(bdata.buff_ef, bdata.buff_effect, bdata);
}
if (bdata.buffview) {
this.buffviewarr.push(bdata.buffview);
if (this.buffview < bdata.buffview) {
this.buffview = bdata.buffview;
}
}
if (needhides) {
cc.gameMgr.uic.shotjoy.active = false;
}
if (needhidem) {
cc.gameMgr.uic.movejoy.active = false;
}
if (bdata.zindex) {
this.node.zplus2 = bdata.zindex;
}
},
updatesan(dt) {
var _delta = sansacle - this.oldscale; //0.4
this.nowtime += dt;
var bil = this.nowtime / this.totaltime;
bil = Math.pow(bil, cc.budongbili);
bil = Math.max(0, Math.min(bil, 1));
bil = 1 - bil;
this.node.scale = this.oldscale + _delta * bil;
this.nd_shadow.scale = (1 - bil) * 0.35; //shadowscale
this.nd_shadow.y = -bil * 60 - 20; //shadowy
},
dotiaosan(v) {
this.totaltime = v;
this.nowtime = 0;
},
dodash(ani) {
this.dashtime = ani_dash_time;
this.beforedash();
this.parsmoke.node.active = true;
this.parsmoke.resetSystem();
var self = this;
this.scheduleOnce(function () {
self.parsmoke.node.active = false;
}, 2);
if (!ani) {
ani = 'dodge';
}
if (this.horsemode == false) {
this.anibodyplay(this.aniqianzui + ani);
cc.gameMgr.playSound('game_dash', this.node.position);
} else {
this.anibodyplay(this.horseqianzui + 'horse_jump');
cc.gameMgr.playSound('horse_jump', this.node.position);
}
if (this.node.isSelf) {
this.nd_reload.active = false;
}
//this.createshadow()
},
removeBuff(bid, buff) {
var bdata = gameConfig.buffConfig[bid];
var needshowm = false;
var needshows = false;
if (bdata.direction) {
this.suofangxiang--;
}
if (bdata.buff_effect == 51 || bdata.buff_effect == 52) {
if (this.node.isSelf) {
// var cardata = gameConfig.dropItemConfig[buff.params[0]]
// var ccount = Number(cardata.param2)
//if (ccount > 1) {
if (bdata.buff_effect == 51) {
needshows = true;
} else if (bdata.buff_effect == 52) {
needshowm = true;
}
// }
}
this.horsemode = false;
this.dohorse();
this.nowAni = '';
} else if (bdata.buff_effect == 4) {
this.revivetime = 0;
} else if (bdata.buff_effect == 5) {
var cocosname = 'cosplay_smoke1';
if (bdata.buff_param1 == 30707) {
cocosname = 'eff_ground4_2';
}
this.parfake.getComponent(cc.Animation).play(cocosname);
// var self = this
// this.scheduleOnce(function() {
// self.parfake.active = false
// }, 2);
this.kct = false;
this.dashtime = 0;
this.anishootstop();
this.fakemode = false;
this.dofake();
this.nowAni = '';
} else if (bdata.buff_effect == 6) {
this.node.active = true;
} else if (bdata.buff_effect == 9) {
this.quickstate = false;
} else if (bdata.buff_effect == 23) {
this.cannotzimiao = false;
} else if (bdata.buff_effect == 24) {
if (this.node.isSelf) {
// cc.gameMgr.nd_plane.active = false
cc.gameMgr.uic.btn_san.active = false;
this.flymode = false;
}
} else if (bdata.buff_effect == 25) {
if (this.node.isSelf) {
cc.gameMgr.endtiaosan();
}
this.sanmode = false;
this.changesan(true);
} else if (bdata.buff_effect == 32) {
this.node.runAction(cc.fadeTo(0.2, 255));
} else if (bdata.buff_effect == 38) {
this.buffhead = -1;
this.ChangeSkin();
} else if (bdata.buff_effect == 14) {
if (this.buffanimode > 0) {
this.buffanimode--;
}
} else if (bdata.buff_effect == 15) {
this.xuanyun--;
// console.log("jjjj remove")
} else if (bdata.buff_effect == 48) {
this.chuantou--;
}
if (needshows) {
cc.gameMgr.uic.shotjoy.active = true;
}
if (needshowm) {
cc.gameMgr.uic.movejoy.active = true;
}
if (bdata.buff_ef) {
if (bdata.delaydestroytime) {
setTimeout(() => {
this.removebuffeff(bdata.buff_ef);
}, bdata.delaydestroytime);
} else {
this.removebuffeff(bdata.buff_ef);
}
// this.bufaniname = ""
// this.anibuff.node.active = false
// this.anibuff.stop()
}
if (bdata.buffview) {
for (var i = 0; i < this.buffviewarr.length; i++) {
if (this.buffviewarr[i] == bdata.buffview) {
this.buffviewarr.splice(i, 1);
break;
}
}
if (this.buffview == bdata.buffview) {
if (this.buffviewarr.length > 0) {
this.buffviewarr.sort();
this.buffview =
this.buffviewarr[this.buffviewarr.length - 1];
} else {
this.buffview = 0;
}
}
}
if (bdata.zindex) {
this.node.zplus2 = 0;
}
},
changeshotmode() {
if (!this.node.isSelf) {
return;
}
this.needquan = false;
if (!cc.notShake) {
if (this.firemode != 2) {
this.needline = false;
}
if (this.weaponstate == 2 && this.firemode != 2) {
this.needquan = true;
}
} else {
if (this.weaponstate == 2) {
this.needline = true;
}
}
if (this.lineNode) {
// this.lineNode.opacity = 0;
this.lineNode.stopAllActions();
this.lineNode.runAction(cc.fadeOut(0.2));
}
// if (this.auto_area) {
// this.nd_quan.height = this.nd_quan.width = this.auto_area * 2
// }
// this.nd_quan.opacity = 0
},
getview() {
return (
this.gudingview +
this.plusView +
this.weaponView +
this.skillview +
this.buffview
);
},
createprefab(name, dir, cb) {
if (cc.gameMgr && cc.gameMgr.effectManager) {
cc.gameMgr.effectManager.createprefab(name, dir, cb);
}
},
createlooteff(name, cb) {
if (cc.gameMgr && cc.gameMgr.effectManager) {
cc.gameMgr.effectManager.createlooteff(name, cb);
}
},
huishoulooteff(name, nd) {
if (cc.gameMgr && cc.gameMgr.effectManager) {
cc.gameMgr.effectManager.huishoulooteff(name, nd);
}
},
huishouprefab(name, nd) {
if (cc.gameMgr && cc.gameMgr.effectManager) {
cc.gameMgr.effectManager.huishouprefab(name, nd);
}
},
changesan(isluodi) {
var needparent = null;
if (this.sanmode) {
this.nd_shadow.scaleY = this.nd_shadow.scaleX = 0;
this.nd_shadow.y -= cc.shadowpy;
this.emoteing = false;
this.othertime = 0;
needparent = cc.gameMgr.ndplayersan;
// this.nd_san.opacity = 255
this.nd_sanfront.opacity = 0;
this.nd_sanback.opacity = 0;
// if (this.node.isSelf) {
// this.pr_hp.node.active = false
// }
//this.pr_hp.node.active = false
} else {
this.nd_shadow.scaleY = this.nd_shadow.scaleX = 0.35;
this.nd_shadow.y = this.oldshadowy;
this.node.scale = this.oldscale;
needparent = cc.gameMgr.ndplayer;
//this.nd_san.opacity = 0
this.nd_sanfront.opacity = 0;
this.nd_sanback.opacity = 0;
// if (this.node.isSelf) {
// this.pr_hp.node.active = true
// }
//this.pr_hp.node.active = true
}
if (this.node.parent && this.node.parent != needparent) {
this.node.removeFromParent(false);
needparent.addChild(this.node);
}
if (isluodi) {
if (this.node.isSelf) {
cc.Notifier.emit('doluodi');
}
this.dashtime = san_time;
this.beforedash();
this.anibodyplay('dodge');
}
},
anishootplay(str) {
if (this.spineloaded) {
this.skeleton.clearTrack(1);
var rstr = 'reset';
if (reset2ani[str]) {
rstr = rstr + '2';
}
this.skeleton.setAnimation(1, rstr, false);
this.nextshotani = str;
}
},
lateUpdate(dt) {
if (this.nextshotani) {
this.skeleton.clearTrack(1);
this.skeleton.setAnimation(1, this.nextshotani, false);
this.nextshotani = undefined;
}
if (this.nextbodyani) {
this.skeleton.clearTrack(0);
this.skeleton.setAnimation(0, this.nextbodyani, true);
this.nextbodyani = undefined;
}
// for (var i = this.pararr.length - 1; i >= 0; i--) {
// this.pararr[i].angle = -this.nd_display.rotation
// this.pararr[i].node.x = this.node.x + this.dirGo.x * firedis
// this.pararr[i].node.y = this.node.y + this.dirGo.y * firedis
// this.pararr[i].blifetime -= dt
// if (this.pararr[i].blifetime <= 0) {
// this.huishoulooteff(this.pararr[i].resname, this.pararr[i].node)
// this.pararr.splice(i, 1);
// }
// }
// for (var i = this.uppnoearr.length - 1; i >= 0; i--) {
// this.uppnoearr[i].rotation = this.nd_display.rotation
// this.uppnoearr[i].x = this.node.x + this.dirGo.x * firedis
// this.uppnoearr[i].y = this.node.y + this.dirGo.y * firedis
// this.uppnoearr[i].blifetime -= dt
// if (this.uppnoearr[i].opacity < 255) {
// this.uppnoearr[i].scaleY = this.uppnoearr[i].blifetime / rayhide
// }
// if (this.uppnoearr[i].blifetime <= 0) {
// this.uppnoearr[i].scaleY = 1
// this.huishoulooteff(this.uppnoearr[i].resname, this.uppnoearr[i])
// this.uppnoearr.splice(i, 1);
// }
// }
// for (var i = this.uppnoearr2.length - 1; i >= 0; i--) {
// this.uppnoearr2[i].rotation = this.nd_display.rotation
// this.uppnoearr2[i].x = this.node.x
// this.uppnoearr2[i].y = this.node.y
// if (this.uppnoearr2[i].blifetime <= 0) {
// this.huishoulooteff(this.uppnoearr2[i].resname, this.uppnoearr2[i])
// this.uppnoearr2.splice(i, 1);
// }
// }
},
anishootplay2(str) {
if (this.spineloaded) {
this.skeleton.clearTrack(1);
/////
// this.shotspanicd = 0
// this.skeleton.clearTrack(3)
///
this.skeleton.setAnimation(1, str, true);
}
},
anibodyplay(str) {
if (this.spineloaded) {
this.shotspanicd = 0;
this.skeleton.clearTrack(3);
var rstr = 'reset';
if (reset2ani[str]) {
rstr = rstr + '2';
}
this.skeleton.clearTrack(0);
this.skeleton.setAnimation(0, rstr, false);
this.nextbodyani = str;
} else {
this.initspine = str;
}
},
anishootstop() {
this.skeleton.clearTrack(1);
// this.skeleton.clearTrack(2)
},
anibodystop() {},
createshadow() {
this.shadowmode = true;
this.shadowtime = 999;
this.shadowtime2 = 0.1;
},
updatebones(dt) {
if (this.spineloaded) {
var bone = this.skeleton.findBone('gun_slot');
var ss = Math.abs(this.skeleton.node.scaleX);
var dx = bone.x * this.skeleton.node.scaleX;
var dy = bone.y * ss;
this.nd_hand.x = dx;
this.nd_hand.y = dy - spinexiuzheng;
// this.nd_hand.rotation = -bone.rotation
this.nd_hand.rotation = -bone.rotation; //this.lerpv(this.nd_hand.rotation, -bone.rotation, 0.7)
if (
this.node.isSelf &&
this.lineNode.opacity == 255 &&
this.othertime <= 0
) {
if (this.nd_newbody.scaleX > 0) {
this.nd_hand.rotation = this.lineNode.rotation;
} else {
this.nd_hand.rotation = 180 - this.lineNode.rotation;
}
}
}
},
dohorse(setoffset) {
if (this.horsemode == false) {
if (this.node.isSelf) {
cc.gameMgr.uic.doofftank();
}
this.nd_role.opacity = 255;
} else {
if (this.node.isSelf) {
cc.gameMgr.uic.doontank();
}
this.nd_role.opacity = 0;
}
},
ondeadthisframe() {
this.deadtime = 3;
this.nd_newbody.active = true;
this.nd_dead.opacity = 0;
this.anishootplay('death');
cc.gameMgr.playSound('hero1_death');
},
checkspeed(speed) {
var lastspeed = this.speed;
if (
(speed > speedweight && lastspeed < speedweight) ||
(speed < speedweight && lastspeed > speedweight)
) {
this.legstate = 0;
this.leganicd = 0;
}
if (speed > speedweight) {
this.isrun = true;
} else {
this.isrun = false;
}
this.speed = speed;
},
setcar(id) {
if (tbuiup[id]) {
this.uipuvaule = tbuiup[id];
}
},
doshotevent(data) {
var gundata = gameConfig.dropItemConfig[data.weapon.weapon_id];
if (gundata && gundata.equip_type == 3) {
this.throw(gundata.act_show);
}
if (gundata && gundata.act_show2) {
this.shootingtime = gundata.act_show2 / 1000;
}
},
touchquxiao() {
var nd = cc.gameMgr.uic.nd_quxiao;
var touchPos = nd.convertToNodeSpaceAR(joytouch);
if (
Math.abs(touchPos.x) > nd.width / 2 ||
Math.abs(touchPos.y) > nd.height / 2
) {
return false;
} else {
return true;
}
},
});