zhuguoqing ff550d5d6a init
2022-05-22 10:32:02 +08:00

298 lines
8.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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);
// this.spine1.changepic("tou",this.tex1)
// this.spine2.changepic("tou",this.tex2)
// this.spine1.setAnimation(0,"atk")
// if (CC_JSB) {
// if (cc.sys.os == cc.sys.OS_ANDROID) {
// // 反射调用原生的隐藏方法
// jsb.reflection.callStaticMethod(
// "org/cocos2dx/javascript/AppActivity",
// "showtips",
// "()V"
// );
// }
// jsb.reflection.callStaticMethod(
// "org/cocos2dx/javascript/AppActivity",
// "hideSplash",
// "()V"
// );
// }
cc.battleCache.loadwave();
cc.highmode = true;
SDKManage.nickName = "战斗测试";
cc.game.setFrameRate(60);
cc.macro.CLEANUP_IMAGE_CACHE = false;
cc.dynamicAtlasManager.enabled = true;
cc.mygamedelta = 0.0167;
// cc.view.enableAntiAlias(false)
// cc.dynamicAtlasManager.showDebug(true);
//cc.view.enableRetina(false)
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() + "", //账号id account_id
player_count: 4, //玩家数(单人时为1)
energy_shield: 0, //能量护盾
baseskin: [cc.heroidx + 1, 13001, 15001, 1], //皮肤idcc.heroidx+1
team_uuid: testid, //队伍唯一id (没组队时为空字符串)
team_mode: 0, //队伍模式 0:单人 1:多人
auto_fill: true, //是否自动填充玩家
hero_id: heroIDArr[cc.heroidx],
weapons: [],
first_game: false,
skins: [],
prepare_items: [], // 12809
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) {},
});