zhuguoqing c21cd97580 udpate
2022-05-26 14:48:21 +08:00

275 lines
7.3 KiB
JavaScript

// Learn cc.Class:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
var battlenet = require("battlenetmanage");
var SDKManage = require("SDKManage");
var clientserver = require("clientserver");
var gameConfig = require("gameConfig");
var wxVoice = require("wxVoice");
var maxhero = 10;
cc.gm = function (str) {
battlenet.sendgm(str);
};
cc.Class({
extends: cc.Component,
properties: {
nd_gas: {
default: null,
type: cc.Camera,
},
wssCacert: {
type: cc.Asset,
default: null,
},
pageview: {
type: cc.PageView,
default: null,
},
ndarrleft: {
default: null,
type: cc.Node,
},
ndarrright: {
default: null,
type: cc.Node,
},
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
gamedatamoni() {
var itemcfg = gameConfig.itemConfig;
(itemcfg["70001"] = {
attack_type: 1,
name: "\u65c5\u884c\u8f66",
img: "map-oldcar2",
thing_id: 70001,
height: 64,
width: 32,
type: 2,
event: 1,
}),
(itemcfg["70002"] = {
attack_type: 1,
name: "\u65c5\u884c\u8f66",
img: "map-oldcar2",
thing_id: 70001,
height: 64,
width: 32,
type: 2,
event: 1,
});
},
GetRequest() {
if (cc.sys.platform == cc.sys.WECHAT_GAME) {
return "";
}
var url = window.location.search;
var theRequest = {};
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
var strArray = strs[i].split("=");
theRequest[strArray[0]] = unescape(strArray[1]);
}
}
return theRequest;
},
start() {
if (cc.heroidx == undefined) {
cc.heroidx = 0;
} else {
this.pageview.scrollToPage(cc.heroidx, 0);
}
this.refresharr();
wxVoice.playbgm("bgm");
var sx = 0;
var sy = 0;
var px = 200;
var py = 100;
var jiajiao = Math.atan2(px, py) * 57.3;
this.pageview.node.on("page-turning", this.callback, this);
cc.battleCache.loadwave();
cc.highmode = true;
SDKManage.nickName = "battletest";
cc.game.setFrameRate(60);
cc.macro.CLEANUP_IMAGE_CACHE = false;
cc.dynamicAtlasManager.enabled = true;
cc.mygamedelta = 0.0167;
this.canclick = true;
var self = this;
},
stringformat(key, arr) {
var str = cc.ldata[key];
if (!str) {
str = key;
}
var cb = function () {
var n = str.search("%");
if (n != -1) {
var idx = Number(str[n + 1]);
str = str.replace("%" + idx, arr[idx - 1]);
cb();
}
};
cb();
return str;
},
test() {
if (!this.canclick) {
return;
}
var testweapon = [];
for (var i = 12103; i <= 12122; i++) {
testweapon.push({
weapon_id: i,
weapon_lv: 100,
});
}
var testid = "";
var gamecount = "10";
var wincount = "1";
var killcount = "1";
var aaa = this.GetRequest();
if (aaa["team_uuid"]) {
testid = aaa["team_uuid"];
}
if (aaa["gamecount"]) {
gamecount = aaa["gamecount"];
wincount = aaa["wincount"];
killcount = aaa["killcount"];
}
cc.nettest = true;
cc.battledebug = true;
var fgarr = [];
var skarr = [];
var autoSkill = [];
let heroIDArr = [
30100, 30200, 30300, 30400, 30500, 30600, 30700, 30800, 30900,
31000,
];
for (var i = 0; i < maxhero; i++) {
fgarr.push(10001 + (i + 1) * 100);
skarr.push(20001 + (i + 1) * 100);
autoSkill.push(30001 + (i + 1) * 100);
}
cc.uiHelper.wssCacert = this.wssCacert;
battlenet.initengine({
account_id: "6000_" + new Date().getTime() + "",
player_count: 4,
energy_shield: 0,
baseskin: [cc.heroidx + 1, 13001, 15001, 1],
team_uuid: testid,
team_mode: 0,
auto_fill: true,
hero_id: heroIDArr[cc.heroidx],
weapons: [],
first_game: false,
skins: [],
prepare_items: [], //
prepare_items2: [
{
key: 30703,
value: 5,
},
],
atk_add: 0,
battlecount: 11,
pre_settlement_info: gamecount + "," + wincount + "," + killcount,
emojis: ["1", "2", "3", "4", "5", "6"],
needbox: true,
// offline: true,
// newbiemode: true,
mapid: 1001,
sex: 2,
skill_list: [
{
key: fgarr[cc.heroidx],
value: 0,
},
{
key: skarr[cc.heroidx],
value: 0,
},
{
key: autoSkill[cc.heroidx],
value: 0,
},
],
//room_mode:1,
// firstzombie:true,
});
},
refresharr() {
this.ndarrright.active = true;
this.ndarrleft.active = true;
if (cc.heroidx == maxhero - 1) {
this.ndarrright.active = false;
}
if (cc.heroidx == 0) {
this.ndarrleft.active = false;
}
},
aaaaa() {
cc.uiHelper.showTips("comming soon...");
},
right() {
cc.heroidx--;
if (cc.heroidx < 0) {
cc.heroidx = 0;
}
this.pageview.setCurrentPageIndex(cc.heroidx);
this.refresharr();
},
left() {
cc.heroidx++;
if (cc.heroidx > maxhero - 1) {
cc.heroidx = maxhero - 1;
}
this.pageview.setCurrentPageIndex(cc.heroidx);
this.refresharr();
},
callback: function (pageView) {
cc.heroidx = pageView.getCurrentPageIndex();
this.refresharr();
},
// update (dt) {},
});