更新
This commit is contained in:
parent
1431ea689a
commit
b617219f5b
File diff suppressed because it is too large
Load Diff
|
@ -212,8 +212,8 @@ export default class GameManager extends cc.Component {
|
|||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
MiniGameSdk.API.shushu_Init();
|
||||
Utils.getUserInfo((data)=>{
|
||||
console.log("登陆成功",data);
|
||||
Utils.getUserInfo((data) => {
|
||||
console.log("登陆成功", data);
|
||||
});
|
||||
let levelInfo = cc.fx.StorageMessage.getStorage("level");
|
||||
//旧的读取数据设置数据方法,以强联网为主
|
||||
|
@ -259,7 +259,7 @@ export default class GameManager extends cc.Component {
|
|||
|
||||
//新用户,有本地缓存读取配置
|
||||
newReadData() {
|
||||
console.log("读取新信息");
|
||||
console.log("读取新信息2");
|
||||
let openid = cc.fx.StorageMessage.getStorage("openid");
|
||||
if (openid == null || openid == "" || openid == undefined) {
|
||||
console.log("没有openid");
|
||||
|
@ -270,7 +270,7 @@ export default class GameManager extends cc.Component {
|
|||
action: 'read'
|
||||
},
|
||||
success: res => {
|
||||
console.log('读取用户数据成功', res.result)
|
||||
console.log('读取用户数据成功_____________________', res.result)
|
||||
if (res.result.code == 404 && res.result.message == "未找到用户数据") {
|
||||
}
|
||||
else if (res.result.code == 200) {
|
||||
|
@ -479,7 +479,7 @@ export default class GameManager extends cc.Component {
|
|||
console.log(res.result.openid);
|
||||
cc.fx.GameConfig.GM_INFO.openid = res.result.openid
|
||||
}
|
||||
else{
|
||||
else {
|
||||
console.log("用户此一次进入游戏为正确获取openid");
|
||||
}
|
||||
cc.fx.GameConfig.GM_INFO.first = true;
|
||||
|
@ -687,7 +687,7 @@ export default class GameManager extends cc.Component {
|
|||
MiniGameSdk.API.shushu_Login();
|
||||
MiniGameSdk.API.yinli_Init();
|
||||
MiniGameSdk.API.yinli_Login();
|
||||
cc.fx.GameTool.setWechatGameGroup(2);
|
||||
const group = cc.fx.GameTool.setWechatGameGroup(2);
|
||||
this.startGame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ export default class MapConroler extends cc.Component {
|
|||
setPropNum() {
|
||||
//如果道具数量大于0,显示 cc.fx.GameConfig.GM_INFO.freezeAmount,如果为零显示'mul10'
|
||||
|
||||
if(cc.fx.GameConfig.GM_INFO.freezeAmount > 0) {
|
||||
if (cc.fx.GameConfig.GM_INFO.freezeAmount > 0) {
|
||||
this.iceNode.children[0].active = false;
|
||||
this.iceNode.children[1].active = true;
|
||||
this.iceNode.children[2].active = true;
|
||||
|
@ -197,7 +197,7 @@ export default class MapConroler extends cc.Component {
|
|||
this.iceNode.children[1].active = false;
|
||||
this.iceNode.children[2].active = false;
|
||||
}
|
||||
if(cc.fx.GameConfig.GM_INFO.hammerAmount > 0) {
|
||||
if (cc.fx.GameConfig.GM_INFO.hammerAmount > 0) {
|
||||
this.hammerNode.children[1].active = true;
|
||||
this.hammerNode.children[0].active = false;
|
||||
this.hammerNode.children[2].active = true;
|
||||
|
@ -207,7 +207,7 @@ export default class MapConroler extends cc.Component {
|
|||
this.hammerNode.children[1].active = false;
|
||||
this.hammerNode.children[2].active = false;
|
||||
}
|
||||
if(cc.fx.GameConfig.GM_INFO.magicAmount > 0) {
|
||||
if (cc.fx.GameConfig.GM_INFO.magicAmount > 0) {
|
||||
this.magicNode.children[1].active = true;
|
||||
this.magicNode.children[0].active = false;
|
||||
this.magicNode.children[2].active = true;
|
||||
|
@ -226,7 +226,7 @@ export default class MapConroler extends cc.Component {
|
|||
this.count_Time = Date.now();
|
||||
//发送数数事件——进入关卡
|
||||
console.log("准备进入下一关,发送下一关进入");
|
||||
if((cc.fx.GameConfig.GM_INFO.level + 1) == 1) {
|
||||
if ((cc.fx.GameConfig.GM_INFO.level + 1) == 1) {
|
||||
this.guideNode.getComponent(Animation).stop();
|
||||
this.guideNode.active = false;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ export default class MapConroler extends cc.Component {
|
|||
|
||||
this.wallInit();
|
||||
this.blockInit();
|
||||
if((cc.fx.GameConfig.GM_INFO.level + 1) == 1) {
|
||||
if ((cc.fx.GameConfig.GM_INFO.level + 1) == 1) {
|
||||
// 如果是第一关,显示引导
|
||||
this.guideNode.active = true;
|
||||
this.guideNode.zIndex = 1000;
|
||||
|
@ -1334,16 +1334,16 @@ export default class MapConroler extends cc.Component {
|
|||
|
||||
}
|
||||
|
||||
judgeWin(number){
|
||||
judgeWin(number) {
|
||||
this.blockNum = this.blocks.length;
|
||||
if(number == 1){
|
||||
if((this.blockNum == 0 || this.blockNum == 1) &&!this.gameWin &&!this.gameOver){
|
||||
if (number == 1) {
|
||||
if ((this.blockNum == 0 || this.blockNum == 1) && !this.gameWin && !this.gameOver) {
|
||||
this.stopTimeCutDown();
|
||||
this.stopBoom();
|
||||
}
|
||||
}
|
||||
else if(number == 0){
|
||||
if(this.blockNum == 0 &&!this.gameWin &&!this.gameOver){
|
||||
else if (number == 0) {
|
||||
if (this.blockNum == 0 && !this.gameWin && !this.gameOver) {
|
||||
this.stopTimeCutDown();
|
||||
this.stopBoom();
|
||||
}
|
||||
|
@ -1362,7 +1362,7 @@ export default class MapConroler extends cc.Component {
|
|||
// alert("游戏成功");
|
||||
MiniGameSdk.API.showToast(cc.fx.GameConfig.GM_INFO.level);
|
||||
this.gameWin = true;
|
||||
console.log("恢复一点体力",cc.fx.GameConfig.GM_INFO.level);
|
||||
console.log("恢复一点体力", cc.fx.GameConfig.GM_INFO.level);
|
||||
cc.fx.GameTool.setUserHealth(1, (data) => {
|
||||
})
|
||||
this.stopTimeCutDown();
|
||||
|
@ -1406,14 +1406,14 @@ export default class MapConroler extends cc.Component {
|
|||
|
||||
winLevel() {
|
||||
MiniGameSdk.API.showToast(cc.fx.GameConfig.GM_INFO.level);
|
||||
if(this.node.parent.parent.getChildByName("Win").
|
||||
getChildByName("nextBtn").getComponent("btnControl")._touch == false){
|
||||
if (this.node.parent.parent.getChildByName("Win").
|
||||
getChildByName("nextBtn").getComponent("btnControl")._touch == false) {
|
||||
return;
|
||||
}
|
||||
this.node.parent.parent.getChildByName("Win").
|
||||
getChildByName("nextBtn").getComponent("btnControl").setTouch(false);
|
||||
cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
|
||||
console.log("下一关",cc.fx.GameConfig.GM_INFO.level);
|
||||
console.log("下一关", cc.fx.GameConfig.GM_INFO.level);
|
||||
if (cc.fx.GameConfig.GM_INFO.level > 249) {
|
||||
cc.fx.GameConfig.GM_INFO.level = 249;
|
||||
MiniGameSdk.API.showToast("每周更新,敬请期待!");
|
||||
|
@ -1467,8 +1467,8 @@ export default class MapConroler extends cc.Component {
|
|||
}
|
||||
|
||||
//时间到了复活
|
||||
reviewLevel(event,type) {
|
||||
if(this.reviewState == true){
|
||||
reviewLevel(event, type) {
|
||||
if (this.reviewState == true) {
|
||||
return;
|
||||
}
|
||||
this.reviewState = true;
|
||||
|
@ -1479,11 +1479,11 @@ export default class MapConroler extends cc.Component {
|
|||
type: type,
|
||||
coin: -coin
|
||||
}
|
||||
if(type == "time"){
|
||||
if (type == "time") {
|
||||
if (cc.fx.GameConfig.GM_INFO.review == 1) coin = 1900;
|
||||
else if (cc.fx.GameConfig.GM_INFO.review == 2) coin = 2500;
|
||||
}
|
||||
else if(type == "boom"){
|
||||
else if (type == "boom") {
|
||||
if (cc.fx.GameConfig.GM_INFO.reviewBoom == 1) coin = 1900;
|
||||
else if (cc.fx.GameConfig.GM_INFO.reviewBoom == 2) coin = 2500;
|
||||
}
|
||||
|
@ -1509,19 +1509,26 @@ export default class MapConroler extends cc.Component {
|
|||
cc.fx.GameTool.changeCoin(data.coin);
|
||||
MiniGameSdk.API.showToast("继续游戏");
|
||||
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||
if (data.type == "time") {
|
||||
if (cc.fx.GameConfig.GM_INFO.review < 2)
|
||||
cc.fx.GameConfig.GM_INFO.review += 1;
|
||||
}
|
||||
else if (data.type == "boom") {
|
||||
if (cc.fx.GameConfig.GM_INFO.reviewBoom < 2)
|
||||
cc.fx.GameConfig.GM_INFO.reviewBoom += 1;
|
||||
}
|
||||
|
||||
|
||||
this.gameOver = false;
|
||||
this.gameWin = false;
|
||||
this.pause = false;
|
||||
if(data.type == "time"){
|
||||
if (data.type == "time") {
|
||||
this.timeNumber = 21;
|
||||
this.add_Time += 20;
|
||||
}
|
||||
|
||||
this.blockNum = this.blocks.length;
|
||||
if (this.blockNum == 0 )this.nextLevel();
|
||||
if (this.blockNum == 0) this.nextLevel();
|
||||
|
||||
this.node.parent.parent.getChildByName("Lose").active = false;
|
||||
setTimeout(() => {
|
||||
|
@ -1603,7 +1610,7 @@ export default class MapConroler extends cc.Component {
|
|||
this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = true;
|
||||
this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = false;
|
||||
if (type) {
|
||||
if (type == "time"){
|
||||
if (type == "time") {
|
||||
let buyBtn = this.node.parent.parent.getChildByName("Lose").getChildByName("Time").getChildByName("buyBtn");
|
||||
buyBtn.getChildByName("coin1").active = buyBtn.getChildByName("coin2").active = buyBtn.getChildByName("coin3").active = false;
|
||||
if (cc.fx.GameConfig.GM_INFO.review == 0) buyBtn.getChildByName("coin1").active = true;
|
||||
|
@ -1793,7 +1800,7 @@ export default class MapConroler extends cc.Component {
|
|||
this.setPropNum();
|
||||
// this.iceLabel.string = cc.fx.GameConfig.GM_INFO.freezeAmount.toString();
|
||||
MiniGameSdk.API.showToast("购买冻结时间成功");
|
||||
}, 2000);
|
||||
}, 200);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1808,7 +1815,7 @@ export default class MapConroler extends cc.Component {
|
|||
MiniGameSdk.API.showToast("购买魔法棒成功");
|
||||
this.setPropNum();
|
||||
// this.magicLabel.string = cc.fx.GameConfig.GM_INFO.magicAmount.toString();
|
||||
}, 2000);
|
||||
}, 200);
|
||||
|
||||
}
|
||||
else if (data == "hammerAmount") {
|
||||
|
@ -1822,7 +1829,7 @@ export default class MapConroler extends cc.Component {
|
|||
this.setPropNum();
|
||||
// this.hammerLabel.string = cc.fx.GameConfig.GM_INFO.hammerAmount.toString();
|
||||
MiniGameSdk.API.showToast("购买锤子成功");
|
||||
}, 2000);
|
||||
}, 200);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1840,15 +1847,6 @@ export default class MapConroler extends cc.Component {
|
|||
if (hammerBtn.getComponent("btnControl")._touch) {
|
||||
hammerBtn.getComponent("btnControl").setTouch(false);
|
||||
if (cc.fx.GameConfig.GM_INFO.hammerAmount < 1) {
|
||||
// if (cc.fx.GameConfig.GM_INFO.coin < 1500) {
|
||||
// MiniGameSdk.API.showToast("金币不足,无法购买道具");
|
||||
// setTimeout(() => {
|
||||
// this.openShop();
|
||||
// hammerBtn.getComponent("btnControl").setTouch(true);
|
||||
// }, 500);
|
||||
|
||||
// return;
|
||||
// }
|
||||
this.node.parent.parent.getChildByName("propWindow").active = true;
|
||||
this.node.parent.parent.parent.getComponent("SceneManager").openPropBuy("hammer");
|
||||
}
|
||||
|
@ -1917,7 +1915,7 @@ export default class MapConroler extends cc.Component {
|
|||
cc.fx.GameTool.buyProp(2001, this.handleBuySuccess.bind(this, "freezeAmount"));
|
||||
}
|
||||
|
||||
openShop(){
|
||||
openShop() {
|
||||
const winCOIN = cc.find("Canvas"); // 假设 Canvas 节点
|
||||
if (winCOIN) {
|
||||
const wincoin = winCOIN.getComponent(SceneManager);
|
||||
|
@ -1978,7 +1976,7 @@ export default class MapConroler extends cc.Component {
|
|||
this.setPropNum();
|
||||
// this.magicLabel.string = cc.fx.GameConfig.GM_INFO.magicAmount.toString();
|
||||
let propInfo = cc.fx.StorageMessage.getStorage("prop");
|
||||
if(propInfo){
|
||||
if (propInfo) {
|
||||
propInfo.magicAmount = cc.fx.GameConfig.GM_INFO.magicAmount;
|
||||
propInfo.timestamp = timestamp;
|
||||
cc.fx.StorageMessage.setStorage("prop", propInfo);
|
||||
|
@ -2204,7 +2202,7 @@ export default class MapConroler extends cc.Component {
|
|||
}
|
||||
}
|
||||
|
||||
startBoom(){
|
||||
startBoom() {
|
||||
for (let i = 0; i < this.blocks.length; i++) {
|
||||
if (this.blocks[i].getComponent("Block").type == 6) {
|
||||
this.blocks[i].getChildByName("boom").getComponent("Boom").startBoom();
|
||||
|
|
|
@ -1127,7 +1127,7 @@ export namespace MiniGameSdk {
|
|||
},
|
||||
// 根据环境变量设置 debug 模式
|
||||
debug: !isProduction,
|
||||
enableLog:false
|
||||
enableLog: false
|
||||
};
|
||||
// 创建 TA 实例
|
||||
API._ta = new ThinkingAnalyticsAPI(config);
|
||||
|
@ -1154,7 +1154,7 @@ export namespace MiniGameSdk {
|
|||
|
||||
static shushu_Login() {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
console.log("数数登录时,获取到的openId:",cc.fx.GameConfig.GM_INFO.openid);
|
||||
console.log("数数登录时,获取到的openId:", cc.fx.GameConfig.GM_INFO.openid);
|
||||
API._ta.login(cc.fx.GameConfig.GM_INFO.openid);
|
||||
cc.fx.GameConfig.GM_INFO.shushu_AccountId = cc.fx.GameConfig.GM_INFO.openid;
|
||||
const result = "success";
|
||||
|
@ -1170,6 +1170,14 @@ export namespace MiniGameSdk {
|
|||
}
|
||||
}
|
||||
|
||||
static updateCoinAndLevel() {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
console.log("上传金币和关卡信息给数数")
|
||||
API._ta.userSet({ current_level: cc.fx.GameConfig.GM_INFO.level });
|
||||
API._ta.userSet({ current_coin: cc.fx.GameConfig.GM_INFO.coin });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 数数平台设置动态公共属性
|
||||
*/
|
||||
|
@ -1183,16 +1191,17 @@ export namespace MiniGameSdk {
|
|||
tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
||||
version: cc.fx.GameConfig.GM_INFO.version.toString(),//当前版本号
|
||||
};
|
||||
if(register_time != null){
|
||||
if (register_time != null) {
|
||||
superProperties = {
|
||||
current_level: (cc.fx.GameConfig.GM_INFO.level + 1), //当前关卡等级 number
|
||||
current_health: cc.fx.GameConfig.GM_INFO.hp, //当前体力值
|
||||
tmp_coin: cc.fx.GameConfig.GM_INFO.coin,//当前金币
|
||||
version: cc.fx.GameConfig.GM_INFO.version.toString(),
|
||||
register_time:register_time
|
||||
register_time: register_time
|
||||
};
|
||||
}
|
||||
API._ta.setSuperProperties(superProperties);//设置公共事件属性
|
||||
API.updateCoinAndLevel();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1249,7 +1258,7 @@ export namespace MiniGameSdk {
|
|||
}
|
||||
|
||||
//#region 引力平台-
|
||||
static yinli_Init(){
|
||||
static yinli_Init() {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
const configYinli = {
|
||||
accessToken: "aGws0nluotbm6Jjiv9WMuzOAbXLydxwe", // 项目通行证,在:网站后台-->设置-->应用列表中找到Access Token列 复制(首次使用可能需要先新增应用)
|
||||
|
@ -1268,9 +1277,9 @@ export namespace MiniGameSdk {
|
|||
},
|
||||
};
|
||||
API._ge = new GravityAnalyticsAPI(configYinli);
|
||||
API._ge .setupAndStart();
|
||||
API._ge.setupAndStart();
|
||||
|
||||
API._ge .initialize({
|
||||
API._ge.initialize({
|
||||
name: cc.fx.GameConfig.GM_INFO.openid,
|
||||
version: cc.fx.GameConfig.GM_INFO.version,
|
||||
openid: cc.fx.GameConfig.GM_INFO.openid,
|
||||
|
@ -1283,7 +1292,7 @@ export namespace MiniGameSdk {
|
|||
console.log("引力引擎初始化失败 " + err);
|
||||
});
|
||||
|
||||
if(cc.fx.GameConfig.GM_INFO.shushu_AccountId == "") cc.fx.GameConfig.GM_INFO.shushu_AccountId =
|
||||
if (cc.fx.GameConfig.GM_INFO.shushu_AccountId == "") cc.fx.GameConfig.GM_INFO.shushu_AccountId =
|
||||
cc.fx.GameConfig.GM_INFO.openid;
|
||||
|
||||
const CURRENT_USER_TA_ACCOUNT_ID = cc.fx.GameConfig.GM_INFO.shushu_AccountId; // 用户唯一标识,如产品为小游戏,则必须填用户openid(注意,不是小游戏的APPID!!!)
|
||||
|
@ -1293,8 +1302,8 @@ export namespace MiniGameSdk {
|
|||
}
|
||||
}
|
||||
|
||||
static yinli_Register(){
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
static yinli_Register() {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
API._ge.registerEvent();
|
||||
}
|
||||
}
|
||||
|
@ -1307,14 +1316,14 @@ export namespace MiniGameSdk {
|
|||
* @param payReason 付费原因 例如:购买钻石、办理月卡
|
||||
* @param payMethod 付费方式 例如:支付宝、微信、银联等
|
||||
*/
|
||||
static yinli_Pay(payAmount,orderId,payReason){
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
static yinli_Pay(payAmount, orderId, payReason) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
API._ge.payEvent(payAmount, "CNY", orderId, payReason, "微信");
|
||||
}
|
||||
}
|
||||
|
||||
static yinli_Login(){
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
static yinli_Login() {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
API._ge.loginEvent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ const { ccclass, property } = cc._decorator;
|
|||
@ccclass('GameConfig')
|
||||
export class GameConfig {
|
||||
//所有控制信息都通过GameAppStart内控制
|
||||
private static _instance : GameConfig = null;
|
||||
private static _instance: GameConfig = null;
|
||||
|
||||
static GAME_DATA: any[];
|
||||
//关卡数据
|
||||
|
@ -101,16 +101,14 @@ export class GameConfig {
|
|||
|
||||
//游戏内信息
|
||||
|
||||
static get Instance()
|
||||
{
|
||||
if (this._instance == null)
|
||||
{
|
||||
static get Instance() {
|
||||
if (this._instance == null) {
|
||||
this._instance = new GameConfig();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
//getSeedRandom
|
||||
static init(Authentication){
|
||||
static init(Authentication) {
|
||||
//@ts-ignore
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
//@ts-ignore
|
||||
|
@ -122,7 +120,7 @@ export class GameConfig {
|
|||
this.TA = null;
|
||||
this.CLICK_init();
|
||||
this.GM_INFO_init();
|
||||
this.LEVEL_INFO_init(false,0);
|
||||
this.LEVEL_INFO_init(false, 0);
|
||||
|
||||
var self = this;
|
||||
//GAME_DATA 废弃了,暂时不删除以防后面修改回 一整局传一次
|
||||
|
@ -136,7 +134,7 @@ export class GameConfig {
|
|||
|
||||
|
||||
static generateUUID(): string {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
const r = Math.random() * 16 | 0;
|
||||
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
|
@ -162,7 +160,7 @@ export class GameConfig {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static GM_INFO_SET(key,value) {
|
||||
static GM_INFO_SET(key, value) {
|
||||
this.GM_INFO[key] = value;
|
||||
}
|
||||
static CLICK_init() {
|
||||
|
@ -178,17 +176,17 @@ export class GameConfig {
|
|||
optimizedSteps: 0, //关卡最短步数
|
||||
usedSteps: 0, //玩家修建总步数
|
||||
stepList: [], //U、D、L、R X 息壤 F 加固
|
||||
startTime:-1, //从游戏开始到玩家操作的第一步截止时间 单位毫秒
|
||||
submitTime:-1, //从第一步操作到提交时间,如果未提交为-1 单位毫秒
|
||||
duration:0, //游戏总用时(截止到提交) 单位毫秒 如果未他移交则为时间上限
|
||||
drawingBack:0, //后退次数
|
||||
drawingReset:0, //清空次数
|
||||
startTime: -1, //从游戏开始到玩家操作的第一步截止时间 单位毫秒
|
||||
submitTime: -1, //从第一步操作到提交时间,如果未提交为-1 单位毫秒
|
||||
duration: 0, //游戏总用时(截止到提交) 单位毫秒 如果未他移交则为时间上限
|
||||
drawingBack: 0, //后退次数
|
||||
drawingReset: 0, //清空次数
|
||||
timer: 0 //测评倒计时剩余时间 去秒
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static CLICK_SET(key,value) {
|
||||
static CLICK_SET(key, value) {
|
||||
this.CLICK_DATA[key] = value;
|
||||
}
|
||||
|
||||
|
@ -198,35 +196,35 @@ export class GameConfig {
|
|||
// isEnd: false,
|
||||
mean_Time: 0, //平均放箭速度
|
||||
hp: 5, //体力值
|
||||
review:0, //复活次数
|
||||
review: 0, //复活次数
|
||||
reviewBoom: 0, //炸弹复活次数
|
||||
reviewDoor: 0, //门复活次数
|
||||
currSeed: 200000, //用于随机数种子
|
||||
openid:"", //微信用户唯一id
|
||||
openid: "", //微信用户唯一id
|
||||
gameId: "100001", //游戏ID
|
||||
userId: 0, //用户ID
|
||||
scode: "", //用户code,从网页后缀获取
|
||||
username:"user", //用户名称
|
||||
useravatar:"", //用户头像地址
|
||||
username: "user", //用户名称
|
||||
useravatar: "", //用户头像地址
|
||||
guide: true, //是否有引导
|
||||
url: "https://api.sparkus.cn",//访问域名
|
||||
coin: 10000, //用户金币
|
||||
coin: 0, //用户金币
|
||||
success: false, //用户游戏成功与否
|
||||
matchId: null, //用于埋点上传的ID
|
||||
gameState:false,
|
||||
gameState: false,
|
||||
custom: 0, //用于测试跳关卡
|
||||
round:0, //回合数
|
||||
round: 0, //回合数
|
||||
level: 0, //具体游戏内进行到第几步
|
||||
stepTimeList:0, //整局游戏用时,由于涉及场景切换,数据需要保留
|
||||
successList:[], //整局胜负
|
||||
first:false, //是否首次进入游戏
|
||||
score:0, //总得分
|
||||
stepTimeList: 0, //整局游戏用时,由于涉及场景切换,数据需要保留
|
||||
successList: [], //整局胜负
|
||||
first: false, //是否首次进入游戏
|
||||
score: 0, //总得分
|
||||
scale: 1, //玩家总计成功点火数
|
||||
iosOutTradeNo:0, //ios订单号
|
||||
min_Time:0, //体力恢复的剩余时间
|
||||
freezeAmount:0, //冻结道具次数
|
||||
hammerAmount:0, //锤子道具次数
|
||||
magicAmount:0, //魔法棒道具次数
|
||||
iosOutTradeNo: 0, //ios订单号
|
||||
min_Time: 0, //体力恢复的剩余时间
|
||||
freezeAmount: 0, //冻结道具次数
|
||||
hammerAmount: 0, //锤子道具次数
|
||||
magicAmount: 0, //魔法棒道具次数
|
||||
musicOpen: true, //音乐
|
||||
effectOpen: true, //音效
|
||||
vibrateOpen: true, //震动
|
||||
|
@ -253,7 +251,7 @@ export class GameConfig {
|
|||
}
|
||||
|
||||
|
||||
static LEVEL_INFO_init(type,time) {
|
||||
static LEVEL_INFO_init(type, time) {
|
||||
// 示例 围墙会根据缺的地块自动生成
|
||||
// 带缺口 {"id":"1006","map":[10,11],"gap":[cc.v2(4,9),cc.v2(5,9)]},
|
||||
// 带升降地块 {"id":"1004","map":[7,8],"risefall":[{pos:cc.v2(5,4),color:2},{pos:cc.v2(5,5),color:5}]},
|
||||
|
@ -261,18 +259,18 @@ export class GameConfig {
|
|||
var self = this;
|
||||
|
||||
|
||||
if((cc.fx.GameConfig.GM_INFO.level) > 249){
|
||||
if ((cc.fx.GameConfig.GM_INFO.level) > 249) {
|
||||
cc.fx.GameConfig.GM_INFO.level = 249;
|
||||
}
|
||||
let name = "Json/level" + (cc.fx.GameConfig.GM_INFO.level+1);
|
||||
let name = "Json/level" + (cc.fx.GameConfig.GM_INFO.level + 1);
|
||||
|
||||
// //console.log("关卡名称:",name);
|
||||
// name = "Json/level" + 68;
|
||||
// cc.fx.StorageMessage.setStorage("level",cc.fx.GameConfig.GM_INFO.level.toString());
|
||||
cc.resources.load(name, (err: any, res: cc.JsonAsset) => {
|
||||
if (err) {
|
||||
cc.fx.GameTool.addLevel(null,null);
|
||||
self.LEVEL_INFO_init(type,time);
|
||||
cc.fx.GameTool.addLevel(null, null);
|
||||
self.LEVEL_INFO_init(type, time);
|
||||
return;
|
||||
}
|
||||
let jsonData: object = res.json!;
|
||||
|
@ -280,10 +278,10 @@ export class GameConfig {
|
|||
self.LEVEL_INFO = jsonData["LEVEL_INFO"];
|
||||
self.WALL_INFO = jsonData["WALL_INFO"];
|
||||
// //console.log("配置加载完成");
|
||||
if(type){
|
||||
cc.director.preloadScene("GameScene", ()=>{
|
||||
if(time == 0) cc.director.loadScene("GameScene");
|
||||
else{
|
||||
if (type) {
|
||||
cc.director.preloadScene("GameScene", () => {
|
||||
if (time == 0) cc.director.loadScene("GameScene");
|
||||
else {
|
||||
setTimeout(() => {
|
||||
cc.director.loadScene("GameScene");
|
||||
}, time);
|
||||
|
@ -486,11 +484,11 @@ export class GameConfig {
|
|||
|
||||
|
||||
|
||||
static setCode(code){
|
||||
static setCode(code) {
|
||||
this.GM_INFO.scode = code;
|
||||
}
|
||||
|
||||
static getKey(key){
|
||||
static getKey(key) {
|
||||
// var reg = new RegExp('(^|&)' + key + '=([^&]*)(&|$)', 'i');
|
||||
// var r = window.location.search.substring(1).match(reg);
|
||||
// if (r != null) {
|
||||
|
@ -500,7 +498,7 @@ export class GameConfig {
|
|||
}
|
||||
|
||||
|
||||
static Authentication(){
|
||||
static Authentication() {
|
||||
cc.fx.GameTool.Authentication();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,18 +10,18 @@ var GameTool = {
|
|||
_totalTime: 0,
|
||||
|
||||
//获取userId
|
||||
Authentication(){
|
||||
Authentication() {
|
||||
let name = "user_" + cc.fx.GameConfig.GM_INFO.gameId;
|
||||
var data = JSON.parse(localStorage.getItem(name));
|
||||
if(data == "undifend" || data==null || data == ""){
|
||||
if (data == "undifend" || data == null || data == "") {
|
||||
var urlNow = window.location.href;
|
||||
if(!this.containsTrain(urlNow)){
|
||||
let url = "https://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback="+location.href;
|
||||
if (!this.containsTrain(urlNow)) {
|
||||
let url = "https://api.sparkus.cn/api/user/auth/login?domain=hui32579WdYPsgYq&callback=" + location.href;
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
else{
|
||||
cc.fx.StorageMessage.setStorage(name,data);
|
||||
else {
|
||||
cc.fx.StorageMessage.setStorage(name, data);
|
||||
cc.fx.GameConfig.GM_INFO.userId = parseInt(data.userId);
|
||||
}
|
||||
},
|
||||
|
@ -31,7 +31,7 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//埋点上传
|
||||
setGameData(){
|
||||
setGameData() {
|
||||
//GAME_DATA 初始化 每次清零
|
||||
cc.fx.GameConfig.GAME_DATA = [];
|
||||
cc.fx.GameConfig.GAME_DATA.push(cc.fx.GameConfig.CLICK_DATA);
|
||||
|
@ -39,10 +39,10 @@ var GameTool = {
|
|||
let data = cc.fx.GameConfig.GAME_DATA;
|
||||
let matchId = this.getMatchId();
|
||||
let postData = {
|
||||
"gameId":cc.fx.GameConfig.GM_INFO.gameId,
|
||||
"userId":cc.fx.GameConfig.GM_INFO.userId,
|
||||
"gameId": cc.fx.GameConfig.GM_INFO.gameId,
|
||||
"userId": cc.fx.GameConfig.GM_INFO.userId,
|
||||
"scode": cc.fx.GameConfig.GM_INFO.scode,
|
||||
"matchId":matchId,
|
||||
"matchId": matchId,
|
||||
"data": data
|
||||
};
|
||||
|
||||
|
@ -50,12 +50,12 @@ var GameTool = {
|
|||
// cc.fx.HttpUtil.uploadUserLogData(postData,function(){})
|
||||
},
|
||||
//上传排行榜 type为1
|
||||
setRank(data){
|
||||
setRank(data) {
|
||||
//GAME_DATA 初始化 每次清零
|
||||
let postData = {
|
||||
"gameId":cc.fx.GameConfig.GM_INFO.gameId,
|
||||
"userId":cc.fx.GameConfig.GM_INFO.userId,
|
||||
"type":1,
|
||||
"gameId": cc.fx.GameConfig.GM_INFO.gameId,
|
||||
"userId": cc.fx.GameConfig.GM_INFO.userId,
|
||||
"type": 1,
|
||||
"score": data.score,
|
||||
"accuracy": data.date,
|
||||
"success": cc.fx.GameConfig.GM_INFO.success
|
||||
|
@ -63,41 +63,41 @@ var GameTool = {
|
|||
// cc.fx.HttpUtil.rankData(1,function(){},postData);
|
||||
},
|
||||
//获取排行榜 type为2
|
||||
getRank(data,callback){
|
||||
getRank(data, callback) {
|
||||
let rankLength = data.length;
|
||||
let postData = {
|
||||
"gameId":cc.fx.GameConfig.GM_INFO.gameId,
|
||||
"userId":cc.fx.GameConfig.GM_INFO.userId,
|
||||
"page":1,
|
||||
"pageSize":rankLength
|
||||
"gameId": cc.fx.GameConfig.GM_INFO.gameId,
|
||||
"userId": cc.fx.GameConfig.GM_INFO.userId,
|
||||
"page": 1,
|
||||
"pageSize": rankLength
|
||||
};
|
||||
//回调进getRankData
|
||||
// cc.fx.HttpUtil.rankData(2,data =>{callback(data)},postData);
|
||||
},
|
||||
//获取matchId 用于上传每次点击数据里面记录id方便查询
|
||||
getMatchId (){
|
||||
getMatchId() {
|
||||
let matchId = cc.sys.localStorage.getItem("matchId");
|
||||
let tempId = matchId;
|
||||
if(matchId == "undifend" || matchId==null){
|
||||
if (matchId == "undifend" || matchId == null) {
|
||||
matchId = this.setMatchId();
|
||||
}
|
||||
else{
|
||||
if(this.containsNanana(matchId) == true){
|
||||
else {
|
||||
if (this.containsNanana(matchId) == true) {
|
||||
matchId = this.setMatchId();
|
||||
}
|
||||
else{
|
||||
let char = parseInt(tempId.substring(10,tempId.length));
|
||||
if(cc.fx.GameConfig.GM_INFO.level == 1){
|
||||
else {
|
||||
let char = parseInt(tempId.substring(10, tempId.length));
|
||||
if (cc.fx.GameConfig.GM_INFO.level == 1) {
|
||||
char += 1;
|
||||
matchId = tempId.slice(0, 10) + char + "";
|
||||
if(this.containsNanana(matchId)) matchId = this.setMatchId();
|
||||
if (this.containsNanana(matchId)) matchId = this.setMatchId();
|
||||
cc.fx.GameConfig.GM_INFO.matchId = matchId;
|
||||
cc.sys.localStorage.setItem("matchId",matchId);
|
||||
cc.sys.localStorage.setItem("matchId", matchId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.containsNanana(matchId) == true){
|
||||
if (this.containsNanana(matchId) == true) {
|
||||
matchId = this.setMatchId();
|
||||
}
|
||||
return matchId;
|
||||
|
@ -107,7 +107,7 @@ var GameTool = {
|
|||
return /na/i.test(str);
|
||||
},
|
||||
//重新设置MatchId
|
||||
setMatchId (){
|
||||
setMatchId() {
|
||||
// 定义包含可用字符的字符集
|
||||
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
||||
// 创建一个数组以保存随机字符
|
||||
|
@ -122,20 +122,20 @@ var GameTool = {
|
|||
uuidArray.push(randomChar);
|
||||
}
|
||||
let data = uuidArray.join('') + 1 + "";
|
||||
cc.sys.localStorage.setItem("matchNumber",1);
|
||||
cc.sys.localStorage.setItem("matchId",data);
|
||||
cc.sys.localStorage.setItem("matchNumber", 1);
|
||||
cc.sys.localStorage.setItem("matchId", data);
|
||||
cc.fx.GameConfig.GM_INFO.matchId = data;
|
||||
return data;
|
||||
},
|
||||
//截取名字
|
||||
subName(name,length){
|
||||
if(name.length > length){
|
||||
name = name.substring(0,length) + "..."
|
||||
subName(name, length) {
|
||||
if (name.length > length) {
|
||||
name = name.substring(0, length) + "..."
|
||||
}
|
||||
return name;
|
||||
},
|
||||
//设置头像
|
||||
setPic(node,pic){
|
||||
setPic(node, pic) {
|
||||
node.active = false;
|
||||
let url = pic;
|
||||
setTimeout(() => {
|
||||
|
@ -144,7 +144,7 @@ var GameTool = {
|
|||
return response.headers.get('Content-Length');
|
||||
})
|
||||
.then(errNo => {
|
||||
if(errNo == "5093"){
|
||||
if (errNo == "5093") {
|
||||
node.active = true;
|
||||
}
|
||||
})
|
||||
|
@ -152,42 +152,42 @@ var GameTool = {
|
|||
// console.error('Error fetching X-Info:', error);
|
||||
});
|
||||
}, 100);
|
||||
cc.assetManager.loadRemote(url, {ext:'.png'},(err, texture:cc.Texture2D) => {
|
||||
if(texture){
|
||||
cc.assetManager.loadRemote(url, { ext: '.png' }, (err, texture: cc.Texture2D) => {
|
||||
if (texture) {
|
||||
node.active = true;
|
||||
node.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
// console.log(err,texture)
|
||||
}
|
||||
})
|
||||
},
|
||||
//第一个参数把目标带进来处理,第二个参数为名字长度,不同场景不同需求
|
||||
//名字4短,小排行,名字6长,大排行
|
||||
getRankData(data,target,nameLength){
|
||||
getRankData(data, target, nameLength) {
|
||||
target.listData = data.data.list;
|
||||
target.selfData = data.data.info;
|
||||
let rankData = [];
|
||||
let self = false;
|
||||
cc.fx.GameTool.setPic(target.selfNode.getChildByName("pic").getChildByName("icon"),target.selfData.pic);
|
||||
for(let i=0;i<=target.listData.length-1;i++){
|
||||
rankData.push({rank:(i+1), name:target.listData[i].nickName, total:target.listData[i].score,time:null, pic:target.listData[i].pic});
|
||||
if(cc.fx.GameConfig.GM_INFO.userId == target.listData[i].userId){
|
||||
cc.fx.GameTool.setPic(target.selfNode.getChildByName("pic").getChildByName("icon"), target.selfData.pic);
|
||||
for (let i = 0; i <= target.listData.length - 1; i++) {
|
||||
rankData.push({ rank: (i + 1), name: target.listData[i].nickName, total: target.listData[i].score, time: null, pic: target.listData[i].pic });
|
||||
if (cc.fx.GameConfig.GM_INFO.userId == target.listData[i].userId) {
|
||||
self = true;
|
||||
target.rankNumber = i;
|
||||
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string =(i+1) + "";
|
||||
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = (i + 1) + "";
|
||||
}
|
||||
if(i == (target.listData.length-1) && self == false){
|
||||
if (i == (target.listData.length - 1) && self == false) {
|
||||
target.rankNumber = i;
|
||||
target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string = "99+";
|
||||
}
|
||||
}
|
||||
target.selfData.nickName = cc.fx.GameTool.subName(target.selfData.nickName,nameLength);
|
||||
target.selfData.nickName = cc.fx.GameTool.subName(target.selfData.nickName, nameLength);
|
||||
target.selfNode.getChildByName("nameLab").getComponent(cc.Label).string = target.selfData.nickName;
|
||||
target.selfNode.getChildByName("totalLab").getComponent(cc.Label).string = target.selfData.score;
|
||||
let timeTemp = cc.fx.GameTool.getTimeShenNong(target.selfData.totleTimes);
|
||||
// target.selfNode.getChildByName("timeLab").getComponent(cc.Label).string = timeTemp + "";
|
||||
switch(target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string){
|
||||
switch (target.selfNode.getChildByName("rankLab").getComponent(cc.Label).string) {
|
||||
case "1":
|
||||
target.selfNode.getChildByName("rank").getChildByName("one").active = true;
|
||||
break;
|
||||
|
@ -199,10 +199,10 @@ var GameTool = {
|
|||
break;
|
||||
}
|
||||
// 大排行
|
||||
if(nameLength == 6){
|
||||
if (nameLength == 6) {
|
||||
target.rankList.setData(rankData);
|
||||
target.selfNode.opacity = 255;
|
||||
if(target.selfData.totalSunCount == 0) target.selfNode.opacity = 0;
|
||||
if (target.selfData.totalSunCount == 0) target.selfNode.opacity = 0;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -216,33 +216,33 @@ var GameTool = {
|
|||
return parseInt(tmp);
|
||||
},
|
||||
//获取关卡配置的那个关卡数
|
||||
getCustom(type){
|
||||
getCustom(type) {
|
||||
let custom = cc.fx.StorageMessage.getStorage(cc.fx.storageType.storageTypeCustom);
|
||||
if(custom == "undifend" || custom==null || custom == ""){
|
||||
if (custom == "undifend" || custom == null || custom == "") {
|
||||
this.setCustom();
|
||||
}
|
||||
else{
|
||||
cc.fx.GameConfig.GM_INFO_SET("custom",custom[0]);
|
||||
if(custom[0] != 0 || type == true){
|
||||
else {
|
||||
cc.fx.GameConfig.GM_INFO_SET("custom", custom[0]);
|
||||
if (custom[0] != 0 || type == true) {
|
||||
custom.shift();
|
||||
if(custom.length == 0){
|
||||
if (custom.length == 0) {
|
||||
this.setCustom();
|
||||
}
|
||||
else cc.fx.StorageMessage.setStorage(cc.fx.storageType.storageTypeCustom,custom);
|
||||
else cc.fx.StorageMessage.setStorage(cc.fx.storageType.storageTypeCustom, custom);
|
||||
}
|
||||
}
|
||||
},
|
||||
//本地没有存储到配置,或者配置用完,重新创建配置
|
||||
setCustom(){
|
||||
setCustom() {
|
||||
let arrayLength = cc.fx.GameConfig.LEVEL_INFO.length;
|
||||
let arrayList = [];
|
||||
for(let i=1; i<arrayLength;i++){
|
||||
for (let i = 1; i < arrayLength; i++) {
|
||||
arrayList.push(i);
|
||||
}
|
||||
arrayList.sort(() => Math.random() - 0.5);
|
||||
arrayList.unshift(0)
|
||||
cc.fx.GameConfig.GM_INFO_SET("custom",arrayList[0]);
|
||||
cc.fx.StorageMessage.setStorage(cc.fx.storageType.storageTypeCustom,arrayList);
|
||||
cc.fx.GameConfig.GM_INFO_SET("custom", arrayList[0]);
|
||||
cc.fx.StorageMessage.setStorage(cc.fx.storageType.storageTypeCustom, arrayList);
|
||||
},
|
||||
|
||||
|
||||
|
@ -264,23 +264,23 @@ var GameTool = {
|
|||
return flag;
|
||||
},
|
||||
//获取游戏信息
|
||||
getGameInfo: function(node){
|
||||
getGameInfo: function (node) {
|
||||
var jg = false;
|
||||
return jg;
|
||||
},
|
||||
//设置游戏信息
|
||||
setGameInfo: function(pd){
|
||||
setGameInfo: function (pd) {
|
||||
|
||||
},
|
||||
|
||||
//打字机效果
|
||||
typingAni(label,text,cb,target){
|
||||
typingAni(label, text, cb, target) {
|
||||
var self = target;
|
||||
var html = '';
|
||||
var arr = text.split('');
|
||||
var len = arr.length;
|
||||
var step = 0;
|
||||
self.func = ()=>{
|
||||
self.func = () => {
|
||||
html += arr[step];
|
||||
label.string = html;
|
||||
if (++step == len) {
|
||||
|
@ -288,33 +288,33 @@ var GameTool = {
|
|||
cb && cb();
|
||||
}
|
||||
}
|
||||
self.schedule(self.func,0.1, cc.macro.REPEAT_FOREVER, 0)
|
||||
self.schedule(self.func, 0.1, cc.macro.REPEAT_FOREVER, 0)
|
||||
},
|
||||
|
||||
//输入秒,返回需要展示时间格式
|
||||
getTimeMargin:(second) => {
|
||||
getTimeMargin: (second) => {
|
||||
let total = 0;
|
||||
total = second;
|
||||
let hour = 0;
|
||||
hour = parseInt((total / 3600) + "");//计算整数小时数
|
||||
let afterHour = total - hour * 60 * 60;//取得算出小时数后剩余的秒数
|
||||
let min = parseInt((afterHour / 60)+"");//计算整数分
|
||||
let min = parseInt((afterHour / 60) + "");//计算整数分
|
||||
let m = "" + min;
|
||||
if(min < 10) m = "0"+min;
|
||||
if (min < 10) m = "0" + min;
|
||||
let afterMin = total - hour * 60 * 60 - min * 60;//取得算出分后剩余的秒数
|
||||
let miao = afterMin + "";
|
||||
if(afterMin < 10) miao = "0" + afterMin;
|
||||
if (afterMin < 10) miao = "0" + afterMin;
|
||||
return m + ':' + miao
|
||||
},
|
||||
|
||||
//输入秒,返回需要展示时间格式
|
||||
getTimeShenNong:(second) => {
|
||||
second = parseInt(second/1000+"");
|
||||
getTimeShenNong: (second) => {
|
||||
second = parseInt(second / 1000 + "");
|
||||
let total = 0;
|
||||
total = second;
|
||||
let min = 0;
|
||||
if(total > 60){
|
||||
min = parseInt((total / 60)+"");//计算整数分
|
||||
if (total > 60) {
|
||||
min = parseInt((total / 60) + "");//计算整数分
|
||||
}
|
||||
let m = min + "'";
|
||||
|
||||
|
@ -334,30 +334,30 @@ var GameTool = {
|
|||
|
||||
|
||||
//增加关卡数
|
||||
addLevel(time1,time2){
|
||||
addLevel(time1, time2) {
|
||||
cc.fx.GameConfig.GM_INFO.level += 1;
|
||||
if(cc.fx.GameConfig.GM_INFO.level > 249){
|
||||
if (cc.fx.GameConfig.GM_INFO.level > 249) {
|
||||
cc.fx.GameConfig.GM_INFO.level = 249;
|
||||
}
|
||||
const timestamp = Date.now();
|
||||
let levelInfo = {
|
||||
level:cc.fx.GameConfig.GM_INFO.level,
|
||||
timestamp:timestamp,
|
||||
level: cc.fx.GameConfig.GM_INFO.level,
|
||||
timestamp: timestamp,
|
||||
}
|
||||
console.log("55555存储关卡数据:",time1,time2);
|
||||
console.log("55555存储关卡数据:", time1, time2);
|
||||
|
||||
cc.fx.StorageMessage.setStorage("level",levelInfo);
|
||||
if(time1!=null && time2!=null){
|
||||
cc.fx.StorageMessage.setStorage("level", levelInfo);
|
||||
if (time1 != null && time2 != null) {
|
||||
let data = {
|
||||
time:time1,
|
||||
add_Time:time2,
|
||||
result:"success"
|
||||
time: time1,
|
||||
add_Time: time2,
|
||||
result: "success"
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("finish_stage",data);
|
||||
cc.fx.GameTool.shushu_Track("finish_stage", data);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null);
|
||||
}
|
||||
|
||||
cc.fx.GameTool.setUserLevel((data)=>{
|
||||
cc.fx.GameTool.setUserLevel((data) => {
|
||||
// console.log("存储结果:",data);
|
||||
// console.log("上传",data);
|
||||
})
|
||||
|
@ -372,11 +372,11 @@ var GameTool = {
|
|||
return;
|
||||
}
|
||||
cc.fx.GameConfig.GM_INFO.coin += coin;
|
||||
if(coin > 0){
|
||||
if (coin > 0) {
|
||||
// let data = "获得" + (coin) + "金币";
|
||||
// MiniGameSdk.API.showToast(data);
|
||||
}
|
||||
else{
|
||||
else {
|
||||
let data = "消耗" + (-coin) + "金币";
|
||||
MiniGameSdk.API.showToast(data);
|
||||
}
|
||||
|
@ -397,11 +397,11 @@ var GameTool = {
|
|||
// console.log("上传",data);
|
||||
})
|
||||
},
|
||||
//@ts-ignore
|
||||
//@ts-ignore
|
||||
//获取用户金币数量
|
||||
getUserCoin(callback: Function) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
name: 'userCoin',
|
||||
|
@ -410,7 +410,7 @@ var GameTool = {
|
|||
},
|
||||
success: res => {
|
||||
// console.log('读取用户金币数据成功', res.result)
|
||||
if(callback)
|
||||
if (callback)
|
||||
callback(res);
|
||||
|
||||
},
|
||||
|
@ -423,15 +423,15 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//改变用户金币
|
||||
setUserCoin(callback){
|
||||
setUserCoin(callback) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if(cc.fx.GameConfig.GM_INFO.coin <= 0 || cc.fx.GameConfig.GM_INFO.coin == undefined){
|
||||
console.log("金币上传失败",cc.fx.GameConfig.GM_INFO.coin);
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
if (cc.fx.GameConfig.GM_INFO.coin <= 0 || cc.fx.GameConfig.GM_INFO.coin == undefined) {
|
||||
console.log("金币上传失败", cc.fx.GameConfig.GM_INFO.coin);
|
||||
// MiniGameSdk.API.showToast(cc.fx.GameConfig.GM_INFO.coin);
|
||||
cc.fx.GameConfig.GM_INFO.coin = 0;
|
||||
}
|
||||
console.log("即将上传的金币数量:",cc.fx.GameConfig.GM_INFO.coin);
|
||||
console.log("即将上传的金币数量:", cc.fx.GameConfig.GM_INFO.coin);
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
name: 'userCoin',
|
||||
|
@ -441,17 +441,17 @@ var GameTool = {
|
|||
},
|
||||
success: res => {
|
||||
// console.log('云函数返回结果:', res);
|
||||
if(res.result.code == 200){
|
||||
if (res.result.code == 200) {
|
||||
// console.log('存储金币数据成功',cc.fx.GameConfig.GM_INFO.coin);
|
||||
}
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
|
||||
},
|
||||
fail: err => {
|
||||
// console.log('存储金币数据失败')
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
console.error('存储用户数据失败', err)
|
||||
|
@ -464,7 +464,7 @@ var GameTool = {
|
|||
//获取用户关卡数
|
||||
getUserLevel(callback: Function) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
name: 'userLevel',
|
||||
|
@ -472,7 +472,7 @@ var GameTool = {
|
|||
action: 'read'
|
||||
},
|
||||
success: res => {
|
||||
if(callback)
|
||||
if (callback)
|
||||
callback(res);
|
||||
|
||||
},
|
||||
|
@ -485,48 +485,48 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//进游戏处理 体力值情况
|
||||
getHealth(callback: Function){
|
||||
getHealth(callback: Function) {
|
||||
let health = cc.fx.StorageMessage.getStorage("health");
|
||||
const timestamp = Date.now();
|
||||
cc.fx.GameConfig.GM_INFO.hp = 5;
|
||||
//没有存储过体力值
|
||||
if(health == null || health == undefined || health == ""){
|
||||
if (health == null || health == undefined || health == "") {
|
||||
console.log("没存储过体力值,初进");
|
||||
cc.fx.GameConfig.GM_INFO.hp = 5;
|
||||
cc.fx.GameTool.getUserHealth((data)=>{
|
||||
console.log("体力接口返回结果",data);
|
||||
if(data.result.code == 200){
|
||||
cc.fx.GameTool.getUserHealth((data) => {
|
||||
console.log("体力接口返回结果", data);
|
||||
if (data.result.code == 200) {
|
||||
cc.fx.GameConfig.GM_INFO.hp = data.result.data;
|
||||
cc.fx.GameConfig.GM_INFO.min_Time = data.result.timestamp;
|
||||
let healthInfo = {
|
||||
"health":cc.fx.GameConfig.GM_INFO.hp,
|
||||
"timestamp":data.result.timestamp
|
||||
"health": cc.fx.GameConfig.GM_INFO.hp,
|
||||
"timestamp": data.result.timestamp
|
||||
}
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null);
|
||||
cc.fx.StorageMessage.setStorage("health",healthInfo);
|
||||
cc.fx.StorageMessage.setStorage("health", healthInfo);
|
||||
}
|
||||
else if(data.result.code == 404 && data.result.message == "未找到体力数据"){
|
||||
cc.fx.GameTool.setUserHealth(0,()=>{
|
||||
else if (data.result.code == 404 && data.result.message == "未找到体力数据") {
|
||||
cc.fx.GameTool.setUserHealth(0, () => {
|
||||
});
|
||||
}
|
||||
if(callback) callback();
|
||||
if (callback) callback();
|
||||
})
|
||||
}
|
||||
else{
|
||||
console.log("有存储过体力值:",health);
|
||||
else {
|
||||
console.log("有存储过体力值:", health);
|
||||
cc.fx.GameConfig.GM_INFO.hp = health.health;
|
||||
if(callback){
|
||||
if (callback) {
|
||||
console.log("体力值读取完毕");
|
||||
callback();
|
||||
}
|
||||
if(health.health < 0){
|
||||
if (health.health < 0) {
|
||||
console.log("体力值异常,归零");
|
||||
cc.fx.GameConfig.GM_INFO.hp = 0;
|
||||
cc.fx.GameTool.setUserHealth(0,()=>{
|
||||
if(callback) callback();
|
||||
cc.fx.GameTool.setUserHealth(0, () => {
|
||||
if (callback) callback();
|
||||
});
|
||||
}
|
||||
else if(health.health < 5){
|
||||
else if (health.health < 5) {
|
||||
// 30分钟的毫秒数
|
||||
const thirtyMinutes = 30 * 60 * 1000;
|
||||
const elapsedTime = timestamp - health.timestamp;
|
||||
|
@ -534,8 +534,8 @@ var GameTool = {
|
|||
const recoveredHealth = Math.min(5 - health.health, Math.floor(elapsedTime / thirtyMinutes));
|
||||
if (recoveredHealth > 0) {
|
||||
health.health += recoveredHealth;
|
||||
cc.fx.GameTool.setUserHealth(recoveredHealth,()=>{
|
||||
if(callback) callback();
|
||||
cc.fx.GameTool.setUserHealth(recoveredHealth, () => {
|
||||
if (callback) callback();
|
||||
});
|
||||
console.log(`体力值恢复 ${recoveredHealth} 点,当前体力值: ${cc.fx.GameConfig.GM_INFO.hp}`);
|
||||
} else {
|
||||
|
@ -551,7 +551,7 @@ var GameTool = {
|
|||
//获取用户体力值
|
||||
getUserHealth(callback: Function) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
console.log("即将进入体力获取接口");
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
|
@ -561,7 +561,7 @@ var GameTool = {
|
|||
},
|
||||
success: res => {
|
||||
// console.log("体力获取成功",res);
|
||||
if(callback)
|
||||
if (callback)
|
||||
callback(res);
|
||||
},
|
||||
fail: err => {
|
||||
|
@ -573,48 +573,48 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//设置用户体力值 有可能加,有可能定时器减
|
||||
setUserHealth(health,callback){
|
||||
setUserHealth(health, callback) {
|
||||
cc.fx.GameConfig.GM_INFO.hp += health;
|
||||
// if(health < 0) {
|
||||
// }
|
||||
// else MiniGameSdk.API.showToast("体力值恢复");
|
||||
const timestamp = Date.now();
|
||||
let healthInfo ={}
|
||||
let healthInfo = {}
|
||||
|
||||
//如果消耗之前不是满体力,说明已经在恢复期,并不用修改时间
|
||||
if(health < 0 && cc.fx.GameConfig.GM_INFO.hp != 4) {
|
||||
if (health < 0 && cc.fx.GameConfig.GM_INFO.hp != 4) {
|
||||
let oldTime = cc.fx.StorageMessage.getStorage("health").timestamp;
|
||||
healthInfo = {
|
||||
"health":cc.fx.GameConfig.GM_INFO.hp,
|
||||
"timestamp":oldTime
|
||||
"health": cc.fx.GameConfig.GM_INFO.hp,
|
||||
"timestamp": oldTime
|
||||
}
|
||||
}
|
||||
else{
|
||||
else {
|
||||
healthInfo = {
|
||||
"health":cc.fx.GameConfig.GM_INFO.hp,
|
||||
"timestamp":timestamp
|
||||
"health": cc.fx.GameConfig.GM_INFO.hp,
|
||||
"timestamp": timestamp
|
||||
}
|
||||
}
|
||||
cc.fx.StorageMessage.setStorage("health",healthInfo);
|
||||
cc.fx.StorageMessage.setStorage("health", healthInfo);
|
||||
MiniGameSdk.API.shushu_SetSuperProperties(null);
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
name: 'userHealth',
|
||||
data: {
|
||||
action: 'save',
|
||||
healthAmount: cc.fx.GameConfig.GM_INFO.hp,
|
||||
timestamp:timestamp
|
||||
timestamp: timestamp
|
||||
},
|
||||
success: res => {
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
|
||||
},
|
||||
fail: err => {
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
// console.error('存储关卡数据失败', err)
|
||||
|
@ -624,9 +624,9 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//购买行为
|
||||
buyReview(coin,callback: Function){
|
||||
buyReview(coin, callback: Function) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
// console.log("实际即将消耗金币:",coin);
|
||||
// this.changeCoin(coin);
|
||||
callback();
|
||||
|
@ -634,36 +634,36 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//更改用户道具数
|
||||
buyProp(propid,callback: Function) {
|
||||
buyProp(propid, callback: Function) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
let num = 3;
|
||||
let cost = 1500;
|
||||
if(propid == 2002){
|
||||
if (propid == 2002) {
|
||||
cost = 1000;
|
||||
num = 1;
|
||||
}
|
||||
cc.fx.GameTool.changeCoin(-cost);
|
||||
cc.fx.GameTool.setUserProp(propid,num,(data)=>{
|
||||
cc.fx.GameTool.setUserProp(propid, num, (data) => {
|
||||
})
|
||||
const data = {
|
||||
id: (propid + ""),
|
||||
num:3
|
||||
num: 3
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("resource_get",data);
|
||||
cc.fx.GameTool.shushu_Track("resource_get", data);
|
||||
let _id = "";
|
||||
if(propid == 2001) _id = "freeze_in_game";
|
||||
else if(propid == 2002) _id = "hammer_in_game";
|
||||
else if(propid == 2003) _id = "wand_in_game";
|
||||
if (propid == 2001) _id = "freeze_in_game";
|
||||
else if (propid == 2002) _id = "hammer_in_game";
|
||||
else if (propid == 2003) _id = "wand_in_game";
|
||||
|
||||
const buyData = {
|
||||
item_id:_id,
|
||||
item_num:3,
|
||||
item_price:cost,
|
||||
cost_type:"gold"
|
||||
item_id: _id,
|
||||
item_num: 3,
|
||||
item_price: cost,
|
||||
cost_type: "gold"
|
||||
}
|
||||
console.log("____________即将上传Shop_buy",buyData);
|
||||
cc.fx.GameTool.shushu_Track("shop_buy",buyData);
|
||||
console.log("____________即将上传Shop_buy", buyData);
|
||||
cc.fx.GameTool.shushu_Track("shop_buy", buyData);
|
||||
|
||||
|
||||
callback();
|
||||
|
@ -672,9 +672,9 @@ var GameTool = {
|
|||
|
||||
|
||||
//改变用户关卡
|
||||
setUserLevel(callback){
|
||||
setUserLevel(callback) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
// if(cc.fx.GameConfig.GM_INFO.level <= 0 || cc.fx.GameConfig.GM_INFO.level == undefined){
|
||||
// console.log("等级重置为0");
|
||||
// cc.fx.GameConfig.GM_INFO.level = 0;
|
||||
|
@ -690,7 +690,7 @@ var GameTool = {
|
|||
success: res => {
|
||||
// console.log('云函数返回结果:', res);
|
||||
// console.log('存储关卡数据成功',cc.fx.GameConfig.GM_INFO.level);
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
|
||||
|
@ -698,7 +698,7 @@ var GameTool = {
|
|||
fail: err => {
|
||||
// console.log('存储关卡数据失败')
|
||||
return;
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
console.error('存储关卡数据失败', err)
|
||||
|
@ -710,7 +710,7 @@ var GameTool = {
|
|||
//获取用户关卡数
|
||||
getUserProp(callback: Function) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
//@ts-ignore
|
||||
wx.cloud.callFunction({
|
||||
name: 'userProp',
|
||||
|
@ -719,12 +719,12 @@ var GameTool = {
|
|||
},
|
||||
success: res => {
|
||||
// console.log('读取用户道具数据成功', res.result)
|
||||
if(res.result.data){
|
||||
if (res.result.data) {
|
||||
// cc.fx.GameConfig.GM_INFO.freezeAmount = res.result.data.freeze;
|
||||
// cc.fx.GameConfig.GM_INFO.hammerAmount = res.result.data.hammer;
|
||||
// cc.fx.GameConfig.GM_INFO.magicAmount = res.result.data.magic_wand;
|
||||
}
|
||||
if(callback)
|
||||
if (callback)
|
||||
callback(res);
|
||||
|
||||
},
|
||||
|
@ -736,24 +736,24 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//改变用户道具
|
||||
setUserProp(propid,amount,callback){
|
||||
setUserProp(propid, amount, callback) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
let newPropData = null;
|
||||
if(propid == 0){
|
||||
if (propid == 0) {
|
||||
newPropData = {
|
||||
freeze:cc.fx.GameConfig.GM_INFO.freezeAmount,
|
||||
hammer:cc.fx.GameConfig.GM_INFO.hammerAmount,
|
||||
magic_wand:cc.fx.GameConfig.GM_INFO.magicAmount,
|
||||
freeze: cc.fx.GameConfig.GM_INFO.freezeAmount,
|
||||
hammer: cc.fx.GameConfig.GM_INFO.hammerAmount,
|
||||
magic_wand: cc.fx.GameConfig.GM_INFO.magicAmount,
|
||||
}
|
||||
}
|
||||
else if(propid == 2001){
|
||||
else if (propid == 2001) {
|
||||
newPropData = amount;
|
||||
}
|
||||
else if(propid == 2002){
|
||||
else if (propid == 2002) {
|
||||
newPropData = amount;
|
||||
}
|
||||
else if(propid == 2003){
|
||||
else if (propid == 2003) {
|
||||
newPropData = amount;
|
||||
}
|
||||
|
||||
|
@ -767,14 +767,14 @@ var GameTool = {
|
|||
},
|
||||
success: res => {
|
||||
// console.log('云函数返回结果:', res);
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
// console.log('存储道具数据成功')
|
||||
},
|
||||
fail: err => {
|
||||
// console.log('存储道具数据失败')
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(err);
|
||||
}
|
||||
console.error('存储道具数据失败', err)
|
||||
|
@ -792,7 +792,7 @@ var GameTool = {
|
|||
// 设置用户信息
|
||||
setUserInfo(callback: Function) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
const time = cc.fx.GameTool.formatDate(new Date());
|
||||
let userInfo = {
|
||||
// 这里填写要存储的用户数据
|
||||
|
@ -810,13 +810,13 @@ var GameTool = {
|
|||
},
|
||||
success: res => {
|
||||
// console.log('存储用户数据成功')
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
|
||||
},
|
||||
fail: err => {
|
||||
if(callback){
|
||||
if (callback) {
|
||||
callback("fail");
|
||||
}
|
||||
}
|
||||
|
@ -825,10 +825,10 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//商城购买
|
||||
shopBuy(productId){
|
||||
shopBuy(productId) {
|
||||
let coin = 0;
|
||||
let price = 0;
|
||||
switch(productId){
|
||||
switch (productId) {
|
||||
case "gold_1":
|
||||
cc.fx.GameTool.changeCoin(1200);
|
||||
coin = 1200;
|
||||
|
@ -867,12 +867,12 @@ var GameTool = {
|
|||
break;
|
||||
}
|
||||
const buyData = {
|
||||
item_id:productId,
|
||||
item_num:coin,
|
||||
item_price:price,
|
||||
cost_type:"cash"
|
||||
item_id: productId,
|
||||
item_num: coin,
|
||||
item_price: price,
|
||||
cost_type: "cash"
|
||||
}
|
||||
cc.fx.GameTool.shushu_Track("shop_buy",buyData);
|
||||
cc.fx.GameTool.shushu_Track("shop_buy", buyData);
|
||||
},
|
||||
|
||||
formatDate(date: Date): string {
|
||||
|
@ -888,20 +888,20 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//获取时间戳
|
||||
getTime(){
|
||||
getTime() {
|
||||
const timestamp = (new Date().getTime())
|
||||
return timestamp;
|
||||
},
|
||||
pushLister:function () {
|
||||
pushLister: function () {
|
||||
|
||||
},
|
||||
removeAllLister:function () {
|
||||
removeAllLister: function () {
|
||||
|
||||
},
|
||||
//上报数据
|
||||
shushu_Track: function(name,data){
|
||||
shushu_Track: function (name, data) {
|
||||
let eventData = {}
|
||||
switch(name){
|
||||
switch (name) {
|
||||
case "login":
|
||||
eventData = {
|
||||
register_time: data.register_time,
|
||||
|
@ -927,16 +927,16 @@ var GameTool = {
|
|||
break;
|
||||
case "resource_get":
|
||||
eventData = {
|
||||
change_reason:"购买道具", //获得来源
|
||||
change_num:data.num, //获得数量
|
||||
resource_id:data.id //道具id
|
||||
change_reason: "购买道具", //获得来源
|
||||
change_num: data.num, //获得数量
|
||||
resource_id: data.id //道具id
|
||||
}
|
||||
break;
|
||||
case "resource_cost":
|
||||
eventData = {
|
||||
change_reason:"使用道具", //获得来源
|
||||
change_num:data.num, //获得数量
|
||||
resource_id:data.id //道具id
|
||||
change_reason: "使用道具", //获得来源
|
||||
change_num: data.num, //获得数量
|
||||
resource_id: data.id //道具id
|
||||
}
|
||||
break;
|
||||
case "shop_buy":
|
||||
|
@ -976,7 +976,7 @@ var GameTool = {
|
|||
}
|
||||
break;
|
||||
}
|
||||
if(name == "finish_stage"){
|
||||
if (name == "finish_stage") {
|
||||
console.log("准备上报完成");
|
||||
console.log(eventData);
|
||||
// MiniGameSdk.API.showToast("准备上报完成游戏");
|
||||
|
@ -986,9 +986,9 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//获取微信小游戏版本号
|
||||
getWechatGameVersion: function(){
|
||||
getWechatGameVersion: function () {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
//@ts-ignore
|
||||
const accountInfo = wx.getAccountInfoSync();
|
||||
const miniProgram = accountInfo.miniProgram;
|
||||
|
@ -1006,19 +1006,19 @@ var GameTool = {
|
|||
},
|
||||
|
||||
//微信小游戏根据openId将用户分组,有可能会两分,三分,六分
|
||||
setWechatGameGroup: function(type: 2 | 3 | 6) {
|
||||
setWechatGameGroup: function (type: 2 | 3 | 6) {
|
||||
//@ts-ignore
|
||||
if (typeof wx!== 'undefined' && wx!== null) {
|
||||
if (typeof wx !== 'undefined' && wx !== null) {
|
||||
//@ts-ignore
|
||||
if(cc.fx.GameConfig.GM_INFO.openid) {
|
||||
if (cc.fx.GameConfig.GM_INFO.openid) {
|
||||
const openid = cc.fx.GameConfig.GM_INFO.openid;
|
||||
const lastChar = openid[openid.length - 1];
|
||||
const charCode = lastChar.charCodeAt(0);
|
||||
let groupNumber: number;
|
||||
console.log("openid尾数____________________:",charCode);
|
||||
console.log("openid尾数____________________:", charCode);
|
||||
|
||||
// 根据 type 参数计算分组编号
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case 2:
|
||||
groupNumber = charCode % 2;
|
||||
break;
|
||||
|
@ -1032,11 +1032,12 @@ var GameTool = {
|
|||
console.log('type 参数值无效,必须为 2、3 或 6');
|
||||
return;
|
||||
}
|
||||
console.log("type____________________:",type);
|
||||
console.log("分组编号____________________:",groupNumber);
|
||||
|
||||
console.log("type____________________:", type);
|
||||
console.log("分组编号____________________:", groupNumber);
|
||||
return groupNumber;
|
||||
}
|
||||
}
|
||||
else return 1;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import MapConroler from "../Map";
|
||||
import NumberToImage from "../NumberToImage";
|
||||
|
||||
const {ccclass, property} = cc._decorator;
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
|
||||
|
||||
|
@ -20,44 +20,44 @@ export default class Boom extends cc.Component {
|
|||
|
||||
// mapInfo: number[][] = [];
|
||||
|
||||
onLoad () {
|
||||
onLoad() {
|
||||
this.over = false;
|
||||
}
|
||||
|
||||
start () {
|
||||
start() {
|
||||
this.over = false;
|
||||
}
|
||||
|
||||
init(time){
|
||||
if(time) this.time = time;
|
||||
init(time) {
|
||||
if (time) this.time = time;
|
||||
this.node.getChildByName("time").active = true;
|
||||
NumberToImage.numberToImageNodes(this.time,20,8,"lock_",this.node.getChildByName("time"),false);
|
||||
NumberToImage.numberToImageNodes(this.time, 20, 8, "lock_", this.node.getChildByName("time"), false);
|
||||
// this.node.getChildByName("time").getComponent(cc.Label).string = this.time.toString();
|
||||
|
||||
}
|
||||
|
||||
startBoom(){
|
||||
startBoom() {
|
||||
this.schedule(this.updateTime, 1);
|
||||
}
|
||||
|
||||
destroyBoom(type){
|
||||
if(this.over) return;
|
||||
destroyBoom(type) {
|
||||
if (this.over) return;
|
||||
this.over = true;
|
||||
this.unschedule(this.updateTime);
|
||||
this.node.parent.getComponent("Block").resetFreeze();
|
||||
this.node.destroy();
|
||||
}
|
||||
|
||||
stopBoom(){
|
||||
stopBoom() {
|
||||
this.unschedule(this.updateTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
updateTime(){
|
||||
this.time --;
|
||||
NumberToImage.numberToImageNodes(this.time,20,8,"lock_",this.node.getChildByName("time"),false);
|
||||
if(this.time <= 0){
|
||||
updateTime() {
|
||||
this.time--;
|
||||
NumberToImage.numberToImageNodes(this.time, 20, 8, "lock_", this.node.getChildByName("time"), false);
|
||||
if (this.time <= 0) {
|
||||
// 创建模拟触摸事件对象
|
||||
const mockTouchEvent = {
|
||||
getLocation: () => {
|
||||
|
@ -70,11 +70,12 @@ export default class Boom extends cc.Component {
|
|||
// 触发父节点 Block 的 touchEnd 事件
|
||||
this.node.parent.getComponent("Block").touchEnd(mockTouchEvent);
|
||||
this.unschedule(this.updateTime);
|
||||
this.node.getChildByName("time").active = false;
|
||||
MapConroler._instance.failLevel("boom");
|
||||
this.node.getChildByName("zhandan").active = true;
|
||||
this.node.getChildByName("bg").active = false;
|
||||
const skeleton = this.node.getChildByName("zhandan").getComponent(sp.Skeleton);
|
||||
skeleton.setAnimation(1,"eff",false);
|
||||
skeleton.setAnimation(1, "eff", false);
|
||||
// 监听动画完成事件,销毁自身爆炸节点
|
||||
skeleton.setCompleteListener(() => {
|
||||
// 动画播放完成后销毁节点
|
||||
|
|
Loading…
Reference in New Issue
Block a user