This commit is contained in:
guoqing.zhu 2022-06-07 13:23:13 +08:00
parent a941f317bc
commit 2cebeacf6c
2 changed files with 402 additions and 407 deletions

View File

@ -1,4 +1,4 @@
import { isTest, mainConfig } from "./Config"; import { isTest, mainConfig } from './Config';
export var allBaseNet = { export var allBaseNet = {
usa: '-z1-test.cebg.games', usa: '-z1-test.cebg.games',
@ -7,42 +7,38 @@ export var allBaseNet = {
turkey: '-z4-test.cebg.games', turkey: '-z4-test.cebg.games',
}; };
isDevEnv();
isDevEnv() isExamining();
isExamining()
function isDevEnv() { function isDevEnv() {
return true; return true;
} }
function isExamining() { function isExamining() {
if (!isDevEnv() && isTest && mainConfig.packageid != 0) {
if(!isDevEnv() && isTest && mainConfig.packageid!=0 ){ return true;
} else {
return true return false;
}else{
return false
} }
} }
function getDevEnvUrlSuffix() { function getDevEnvUrlSuffix() {
//'-test.kingsome.cn' //'-test.kingsome.cn'
return atob('LXRlc3Qua2luZ3NvbWUuY24='); return atob('LXRlc3Qua2luZ3NvbWUuY24=');
} }
function getExaminingUrlSuffix() { function getExaminingUrlSuffix() {
return '-test.cebg.games'; return '-test.cebg.games';
} }
function getUrlSuffix() { function getUrlSuffix() {
let urlSuffix = '-z3-test.cebg.games'; let urlSuffix = '-z3-test.cebg.games';
if (isDevEnv()) { if (isDevEnv()) {
urlSuffix = getDevEnvUrlSuffix(); urlSuffix = getDevEnvUrlSuffix();
} else if (isExamining()) { } else if (isExamining()) {
urlSuffix = getExaminingUrlSuffix(); urlSuffix = getExaminingUrlSuffix();
} }
return urlSuffix; return urlSuffix;
} }
const netIdHash = (function () { const netIdHash = (function () {
@ -85,11 +81,11 @@ function getCommonParam() {
'_net=' + '_net=' +
encodeURIComponent(localStorage.getItem('currentNet')) + encodeURIComponent(localStorage.getItem('currentNet')) +
'&_os=' + '&_os=' +
encodeURIComponent(os) + encodeURIComponent(os) +
'&_version=' + '&_version=' +
encodeURIComponent(mainConfig.version) + encodeURIComponent(mainConfig.version) +
'&_hotfixversion=' + '&_hotfixversion=' +
encodeURIComponent(mainConfig.hotfixVersion)+ encodeURIComponent(mainConfig.hotfixVersion) +
'&_packageid=' + '&_packageid=' +
encodeURIComponent(mainConfig.packageid) encodeURIComponent(mainConfig.packageid)
); );
@ -98,7 +94,7 @@ function getCommonParam() {
export function getNormalApiUrl(name) { export function getNormalApiUrl(name) {
return ( return (
functionNet[name] + functionNet[name] +
getUrlSuffix() + getUrlSuffix() +
'/webapp/index.php?' + '/webapp/index.php?' +
getCommonParam() getCommonParam()
); );
@ -114,11 +110,7 @@ export function getExaminingUrl() {
} }
export function getRelationUrl() { export function getRelationUrl() {
return ( return functionNet['relation'] + getUrlSuffix() + '/friend/websocket';
functionNet['relation'] +
getUrlSuffix() +
'/friend/websocket'
);
} }
export function getNodeUrl() { export function getNodeUrl() {
@ -185,12 +177,12 @@ function getZName(zid) {
} }
export function getGameServer(teamUuid) { export function getGameServer(teamUuid) {
if (isDevEnv()) { if (isDevEnv()) {
return 'wss://game2006' + getDevEnvUrlSuffix() + '/websocket'; return 'wss://game2006' + getDevEnvUrlSuffix() + '/websocket';
} }
if (isExamining()) { if (isExamining()) {
return 'wss://game2006' + getExaminingUrlSuffix() + '/websocket'; return 'wss://game2006' + getExaminingUrlSuffix() + '/websocket';
} }
const nodeId = teamUuid ? teamUuid.split('_')[0] : cc.SDKManage.NodeId; const nodeId = teamUuid ? teamUuid.split('_')[0] : cc.SDKManage.NodeId;
const zid = teamUuid const zid = teamUuid
? teamUuid.split('_')[1] ? teamUuid.split('_')[1]

View File

@ -1,409 +1,412 @@
var battlenet = require("battlenetmanage"); var battlenet = require('battlenetmanage');
var SDKManage = require("SDKManage"); var SDKManage = require('SDKManage');
var gameConfig = require("gameConfig"); var gameConfig = require('gameConfig');
var Utils = require("Utils"); var Utils = require('Utils');
const NetManage = require("../../manages/NetManage"); const NetManage = require('../../manages/NetManage');
const { showLoading } = require("../../gif/Loading"); const { showLoading } = require('../../gif/Loading');
const { OperationType } = require("../../Operation/Operation"); const { OperationType } = require('../../Operation/Operation');
const jcgamelog = require("../../jcfw/service/jcgamelog"); const jcgamelog = require('../../jcfw/service/jcgamelog');
cc.Class({ cc.Class({
extends: cc.Component, extends: cc.Component,
properties: { properties: {
nd_chat: { nd_chat: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
nd_back: { nd_back: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
lb_time: { lb_time: {
default: null, default: null,
type: cc.Label, type: cc.Label,
}, },
nd_time5: { nd_time5: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
nd_btns: { nd_btns: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
btn_ready: { btn_ready: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
btn_noready: { btn_noready: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
btn_go: { btn_go: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
pb_herolihui: { pb_herolihui: {
default: null, default: null,
type: cc.Prefab, type: cc.Prefab,
}, },
nd_teamlihui: { nd_teamlihui: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
nd_onehui: { nd_onehui: {
default: null, default: null,
type: cc.Node, type: cc.Node,
}, },
tableView_chose: {
default: null,
type: cc.Node,
},
pb_chooseWeapon: { tableView_chose: {
default: null, default: null,
type: cc.Prefab, type: cc.Node,
}, },
nd_weaponNode1: { pb_chooseWeapon: {
default: null, default: null,
type: cc.Node, type: cc.Prefab,
}, },
nd_weaponNode2: {
default: null,
type: cc.Node,
},
},
// LIFE-CYCLE CALLBACKS: nd_weaponNode1: {
default: null,
type: cc.Node,
},
nd_weaponNode2: {
default: null,
type: cc.Node,
},
},
onLoad() { // LIFE-CYCLE CALLBACKS:
this.weaponStr = "[]";
this.weapon_uniid = new Array();
cc.Notifier.on("battleclickchose", this, this.battleclickchose.bind(this)); onLoad() {
cc.Notifier.on( this.weaponStr = '[]';
"SMUpdateMatchInfo", this.weapon_uniid = new Array();
this,
this.SMUpdateMatchInfo.bind(this)
);
cc.Notifier.on("infochangeskin", this, this.infochangeskin.bind(this));
// choose weapon
cc.Notifier.on("haschooseWeapon", this, (index, name) => {
if (index) {
console.log(`index-------${window.currentWeaponName}`);
if (index == 0) {
cc.loader.loadRes(
`icons/${window.currentWeaponName}`,
cc.SpriteFrame,
(err, res) => {
if (this.nd_weaponNode1)
this.nd_weaponNode1.getComponent(cc.Sprite).spriteFrame = res;
}
);
} else if (index == 1) {
cc.loader.loadRes(
`icons/${window.currentWeaponName}`,
cc.SpriteFrame,
(err, res) => {
if (this.nd_weaponNode2)
this.nd_weaponNode2.getComponent(cc.Sprite).spriteFrame = res;
}
);
}
//
if (window.firstgun && this.weapon_uniid) { cc.Notifier.on(
this.weapon_uniid[0] = window.firstgun; 'battleclickchose',
} this,
if (window.secondgun && this.weapon_uniid) { this.battleclickchose.bind(this)
this.weapon_uniid[1] = window.secondgun; );
} cc.Notifier.on(
'SMUpdateMatchInfo',
this,
this.SMUpdateMatchInfo.bind(this)
);
cc.Notifier.on('infochangeskin', this, this.infochangeskin.bind(this));
// choose weapon
cc.Notifier.on('haschooseWeapon', this, (index, name) => {
if (index) {
console.log(`index-------${window.currentWeaponName}`);
if (index == 0) {
cc.loader.loadRes(
`icons/${window.currentWeaponName}`,
cc.SpriteFrame,
(err, res) => {
if (this.nd_weaponNode1)
this.nd_weaponNode1.getComponent(
cc.Sprite
).spriteFrame = res;
}
);
} else if (index == 1) {
cc.loader.loadRes(
`icons/${window.currentWeaponName}`,
cc.SpriteFrame,
(err, res) => {
if (this.nd_weaponNode2)
this.nd_weaponNode2.getComponent(
cc.Sprite
).spriteFrame = res;
}
);
}
//
this.weaponStr = JSON.stringify(this.weapon_uniid); if (window.firstgun && this.weapon_uniid) {
this.weapon_uniid[0] = window.firstgun;
}
if (window.secondgun && this.weapon_uniid) {
this.weapon_uniid[1] = window.secondgun;
}
console.log(this.weaponStr); this.weaponStr = JSON.stringify(this.weapon_uniid);
}
});
},
onDestroy() {
cc.Notifier.off("battleclickchose", this);
cc.Notifier.off("SMUpdateMatchInfo", this);
cc.Notifier.off("infochangeskin", this);
},
SMUpdateMatchInfo(_data) {
var data = _data.info;
this.herodatalist = data.members;
for (var i = 0; i < data.members.length; i++) {
var onedata = data.members[i];
if (onedata.hero_skin > 0) {
onedata.hero_id = gameConfig.all_ItemConfig[onedata.hero_skin].playerid;
onedata.hero_skin = onedata.hero_skin;
}
}
if (data.countdown <= 5) {
this.lb_time.node.active = false;
this.nd_btns.active = false;
this.nd_time5.active = true;
} else {
this.lb_time.node.active = true;
this.lb_time.string = Utils.second3Time(data.countdown);
}
this.refresh();
},
battleclickchose(v) { console.log(this.weaponStr);
this.tmpv = v; }
if (this.mystate != 0) { });
return; },
} onDestroy() {
cc.Notifier.off('battleclickchose', this);
cc.Notifier.off('SMUpdateMatchInfo', this);
cc.Notifier.off('infochangeskin', this);
},
SMUpdateMatchInfo(_data) {
var data = _data.info;
this.herodatalist = data.members;
for (var i = 0; i < data.members.length; i++) {
var onedata = data.members[i];
if (onedata.hero_skin > 0) {
onedata.hero_id =
gameConfig.all_ItemConfig[onedata.hero_skin].playerid;
onedata.hero_skin = onedata.hero_skin;
}
}
if (data.countdown <= 5) {
this.lb_time.node.active = false;
this.nd_btns.active = false;
this.nd_time5.active = true;
} else {
this.lb_time.node.active = true;
this.lb_time.string = Utils.second3Time(data.countdown);
}
this.refresh();
},
var heroDetail = this.getHeroDetailByID(v.hero_id) battleclickchose(v) {
var process = (heroDetail.ceg_uplimit - heroDetail.today_get_gold) / heroDetail.ceg_uplimit; this.tmpv = v;
if (this.mystate != 0) {
return;
}
this.node.getComponentInChildren("pbbattleui").nd_processbar.progress = process; var heroDetail = this.getHeroDetailByID(v.hero_id);
this.node.getComponentInChildren("pbbattleui").nd_remainceg.string = heroDetail.ceg_uplimit - heroDetail.today_get_gold; var process =
(heroDetail.ceg_uplimit - heroDetail.today_get_gold) /
heroDetail.ceg_uplimit;
for (var i = 0; i < this.herodatalist.length; i++) { this.node.getComponentInChildren('pbbattleui').nd_processbar.progress =
if (this.herodatalist[i].account_id == v.account_id) { process;
this.herodatalist[i].hero_id = v.hero_id; this.node.getComponentInChildren('pbbattleui').nd_remainceg.string =
this.herodatalist[i].hero_skin = v.hero_skin; heroDetail.ceg_uplimit - heroDetail.today_get_gold;
this.herodatalist[i].hero_uuid = this.getHeroUUidByid(v.hero_id);
if (SDKManage.account_id == v.account_id) {
cc.playerData.changeHero(v.hero_id);
this.hero_id = v.hero_id;
this.hero_uuid = this.getHeroUUidByid(v.hero_id);
this.canzb = true;
if (this.team_mode) {
let data = {
hero_id: v.hero_id,
weapons: JSON.parse(this.weaponStr),
skins: [],
baseskin: gameConfig.all_ItemConfig[v.hero_skin].skinid,
hero_skin: v.hero_skin,
skill_list: cc.playerData.getbattleskilllist(),
hero_uniid:this.herodatalist[i].hero_uuid,
};
this.matchdata = data; for (var i = 0; i < this.herodatalist.length; i++) {
if (this.herodatalist[i].account_id == v.account_id) {
this.herodatalist[i].hero_id = v.hero_id;
this.herodatalist[i].hero_skin = v.hero_skin;
this.herodatalist[i].hero_uuid = this.getHeroUUidByid(
v.hero_id
);
if (SDKManage.account_id == v.account_id) {
cc.playerData.changeHero(v.hero_id);
this.hero_id = v.hero_id;
this.hero_uuid = this.getHeroUUidByid(v.hero_id);
this.canzb = true;
if (this.team_mode) {
let data = {
hero_id: v.hero_id,
weapons: JSON.parse(this.weaponStr),
skins: [],
baseskin:
gameConfig.all_ItemConfig[v.hero_skin].skinid,
hero_skin: v.hero_skin,
skill_list: cc.playerData.getbattleskilllist(),
hero_uniid: this.herodatalist[i].hero_uuid,
};
cc.battleIns.sendbattlemsg("CMMatchChoose", data); this.matchdata = data;
}
}
this.refresh(); cc.battleIns.sendbattlemsg('CMMatchChoose', data);
break; }
} }
}
},
initdata(opt) {
this.lb_time.node.active = false;
this.mystate = 0;
this.nd_time5.active = false;
this.btn_ready.active = false;
this.btn_noready.active = false;
this.btn_go.active = false;
this.nd_back.active = false;
this.herodatalist = [];
this.herolist = [];
cc.playerData.changeHero(30100); this.refresh();
var addnode = this.nd_teamlihui; break;
var pcount = 1; }
}
},
initdata(opt) {
this.lb_time.node.active = false;
this.mystate = 0;
this.nd_time5.active = false;
this.btn_ready.active = false;
this.btn_noready.active = false;
this.btn_go.active = false;
this.nd_back.active = false;
this.herodatalist = [];
this.herolist = [];
if (opt.teamuuid) { cc.playerData.changeHero(30100);
this.team_mode = true; var addnode = this.nd_teamlihui;
pcount = 4; var pcount = 1;
} else {
this.btn_go.active = true;
this.nd_back.active = true;
addnode = this.nd_onehui;
this.herodatalist.push({
state: 0,
name: cc.playerData.name,
hero_id: 0,
hero_skin: 0,
account_id: SDKManage.account_id,
hero_uuid: 0,
});
}
for (var i = 0; i < pcount; i++) {
var nd = cc.instantiate(this.pb_herolihui);
addnode.addChild(nd);
var scp = nd.getComponent("pbbattleui");
scp.target = this;
this.herolist.push(scp);
}
this.refresh(); if (opt.teamuuid) {
this.changelist(0); this.team_mode = true;
}, pcount = 4;
} else {
this.btn_go.active = true;
this.nd_back.active = true;
addnode = this.nd_onehui;
this.herodatalist.push({
state: 0,
name: cc.playerData.name,
hero_id: 0,
hero_skin: 0,
account_id: SDKManage.account_id,
hero_uuid: 0,
});
}
for (var i = 0; i < pcount; i++) {
var nd = cc.instantiate(this.pb_herolihui);
addnode.addChild(nd);
var scp = nd.getComponent('pbbattleui');
scp.target = this;
this.herolist.push(scp);
}
changetype(data1, data2) { this.refresh();
this.changelist(Number(data2)); this.changelist(0);
cc.Notifier.emit("btnchose", { k: data2 }); },
},
changelist(type) { changetype(data1, data2) {
var cherolist = []; this.changelist(Number(data2));
var openherolist = cc.playerData.getopenhero(); cc.Notifier.emit('btnchose', { k: data2 });
},
var herolist = [];
this.allHeroUUID = [];
this.allHeroID = [];
this.heroDetails=[]
NetManage.getHeroList((data) => { changelist(type) {
herolist = data.hero_list; var cherolist = [];
for (var i = 0; i < herolist.length; i++) { var openherolist = cc.playerData.getopenhero();
var element = herolist[i];
if(element.lock_type!=3){
this.allHeroUUID.push(element.hero_uniid);
this.allHeroID.push(element.hero_id)
this.heroDetails.push(herolist[i])
}
}
console.log(this.allHeroID) var herolist = [];
this.allHeroUUID = [];
this.allHeroID = [];
this.heroDetails = [];
NetManage.getHeroList((data) => {
herolist = data.hero_list;
for (var i = 0; i < herolist.length; i++) {
var element = herolist[i];
if (element.lock_type != 3) {
this.allHeroUUID.push(element.hero_uniid);
this.allHeroID.push(parseInt(element.hero_id));
this.heroDetails.push(herolist[i]);
}
}
for (var i = 0; i < this.allHeroID.length; i++) {
for (var i = 0; i < this.allHeroID.length; i++) { var hid = this.allHeroID[i];
var hid = this.allHeroID[i]; var heroType = gameConfig.playerConfig[hid].herotype;
var heroType = gameConfig.playerConfig[hid].herotype; if (type == 0 || type == heroType) {
if (type == 0 || type == heroType) { if (cc.playerData.checkhasgethero(hid)) {
if (cc.playerData.checkhasgethero(hid)) { cherolist.push(hid);
cherolist.push(hid); }
} }
} }
}
var newlist = Utils.arrtoarr(cherolist, 2); var newlist = Utils.arrtoarr(cherolist, 2);
// this.allHeroID = cherolist; // this.allHeroID = cherolist;
this.tableView_chose this.tableView_chose
.getComponent("tableView") .getComponent('tableView')
.initTableView(newlist.length, { .initTableView(newlist.length, {
array: newlist, array: newlist,
target: this, target: this,
}); });
});
// for (var i = 0; i < openherolist.length; i++) {
// var hid = openherolist[i];
// var heroType = gameConfig.playerConfig[hid].herotype;
// if (type == 0 || type == heroType) {
// if (cc.playerData.checkhasgethero(hid)) {
// cherolist.push(hid);
// }
// }
// }
}); // var newlist = Utils.arrtoarr(cherolist, 2);
// this.allHeroID = cherolist;
// this.tableView_chose
// .getComponent("tableView")
// .initTableView(newlist.length, {
// array: newlist,
// target: this,
// });
},
getHeroUUidByid(id) {
var index = this.allHeroID.indexOf(id);
return this.allHeroUUID[index];
},
// for (var i = 0; i < openherolist.length; i++) { getHeroDetailByID(id) {
// var hid = openherolist[i]; var index = this.allHeroID.indexOf(id);
// var heroType = gameConfig.playerConfig[hid].herotype; return this.heroDetails[index];
// if (type == 0 || type == heroType) { },
// if (cc.playerData.checkhasgethero(hid)) {
// cherolist.push(hid);
// }
// }
// }
// var newlist = Utils.arrtoarr(cherolist, 2); onclickclose() {
// this.allHeroID = cherolist; window.firstgun = null;
// this.tableView_chose window.secondgun = null;
// .getComponent("tableView") this.node.destroy();
// .initTableView(newlist.length, { },
// array: newlist, onclickgo() {
// target: this, //single
// }); jcgamelog.addOperation(OperationType.BUTTON, 'startgame');
}, if (!this.canzb) {
cc.uiHelper.showTips('Please choose a hero first');
return;
}
// showLoading();
// setTimeout(() => {
// this.btn_noready.parent.parent.zindex = 99;
// }, 1500);
var opt = cc.playerData.getbattleopt();
opt.team_mode = 0;
opt.player_count = 1;
opt.hero_uniid = this.hero_uuid;
getHeroUUidByid(id) { if (window.firstgun) {
var index = this.allHeroID.indexOf(id); opt.weapon_uniid = new Array();
return this.allHeroUUID[index]; opt.weapon_uniid.push(window.firstgun);
}, if (window.secondgun) {
opt.weapon_uniid.push(window.secondgun);
}
}
getHeroDetailByID(id){ battlenet.initengine(opt);
var index = this.allHeroID.indexOf(id); },
return this.heroDetails[index]; refresh() {
}, for (var i = 0; i < this.herodatalist.length; i++) {
this.herolist[i].initdata(this.herodatalist[i]);
}
},
onclicktype() {},
onclickcancelready() {
cc.battleIns.sendbattlemsg('CMMatchCancelStartGame');
},
onclickready() {
jcgamelog.addOperation(OperationType.BUTTON, 'startgame');
// team
if (!this.canzb) {
cc.uiHelper.showTips('Please choose a hero first');
return;
}
//
if (this.matchdata) {
this.matchdata.weapons = JSON.parse(this.weaponStr);
cc.battleIns.sendbattlemsg('CMMatchChoose', this.matchdata);
}
//
cc.battleIns.sendbattlemsg('CMMatchStartGame');
},
doready(state) {
if (this.team_mode) {
this.mystate = state;
this.btn_ready.active = state == 0;
this.btn_noready.active = !this.btn_ready.active;
}
},
infochangeskin(v) {
cc.Notifier.emit('battleclickchose', {
account_id: SDKManage.account_id,
hero_id: this.hero_id,
hero_skin: v,
});
cc.playerData.changeSkin(v);
},
onclickclose() { // update (dt) {},
window.firstgun = null;
window.secondgun = null;
this.node.destroy();
},
onclickgo() {
//single
jcgamelog.addOperation(
OperationType.BUTTON,
'startgame',
);
if (!this.canzb) {
cc.uiHelper.showTips("Please choose a hero first");
return;
}
// showLoading();
// setTimeout(() => {
// this.btn_noready.parent.parent.zindex = 99;
// }, 1500);
var opt = cc.playerData.getbattleopt();
opt.team_mode = 0;
opt.player_count = 1;
opt.hero_uniid = this.hero_uuid;
if (window.firstgun) { onClickChooseWeapon(event, data) {
opt.weapon_uniid = new Array(); var node = cc.instantiate(this.pb_chooseWeapon);
opt.weapon_uniid.push(window.firstgun); node.scale = 0.8;
if (window.secondgun) { this.node.addChild(node);
opt.weapon_uniid.push(window.secondgun); node.getComponent('chooseGun').startFrom(data);
} },
}
battlenet.initengine(opt);
},
refresh() {
for (var i = 0; i < this.herodatalist.length; i++) {
this.herolist[i].initdata(this.herodatalist[i]);
}
},
onclicktype() {},
onclickcancelready() {
cc.battleIns.sendbattlemsg("CMMatchCancelStartGame");
},
onclickready() {
jcgamelog.addOperation(
OperationType.BUTTON,
'startgame',
);
// team
if (!this.canzb) {
cc.uiHelper.showTips("Please choose a hero first");
return;
}
//
if (this.matchdata) {
this.matchdata.weapons = JSON.parse(this.weaponStr);
cc.battleIns.sendbattlemsg("CMMatchChoose", this.matchdata);
}
//
cc.battleIns.sendbattlemsg("CMMatchStartGame");
},
doready(state) {
if (this.team_mode) {
this.mystate = state;
this.btn_ready.active = state == 0;
this.btn_noready.active = !this.btn_ready.active;
}
},
infochangeskin(v) {
cc.Notifier.emit("battleclickchose", {
account_id: SDKManage.account_id,
hero_id: this.hero_id,
hero_skin: v,
});
cc.playerData.changeSkin(v);
},
// update (dt) {},
onClickChooseWeapon(event, data) {
var node = cc.instantiate(this.pb_chooseWeapon);
node.scale = 0.8;
this.node.addChild(node);
node.getComponent("chooseGun").startFrom(data);
},
}); });