This commit is contained in:
YZ\249929363 2025-08-04 10:41:10 +08:00
parent 101417464b
commit 7d17b6559d
10 changed files with 374 additions and 294 deletions

View File

@ -451,7 +451,7 @@ export default class Block extends cc.Component {
this.setMapBlock();
this.level = 50 + this.posX - this.posY * 3;
this.node.zIndex = this.level;
console.log("方块层级", this.node.zIndex);
//console.log("方块层级", this.node.zIndex);
this.node.x = mapBlock.x + 65;
this.node.y = mapBlock.y - 60;

View File

@ -93,27 +93,27 @@ export default class GameManager extends cc.Component {
const path2 = 'prefab/wall';
cc.resources.loadDir(path, cc.Prefab, (err, assets: cc.Prefab[]) => {
if (err) {
console.log('动态加载 block 失败:', err);
//console.log('动态加载 block 失败:', err);
cc.director.loadScene("LoadScene");
return;
}
// 将加载的 Prefab 赋值给 Block_Array
this.Block_Array = assets;
console.log('方块加载成功,共加载了', this.Block_Array.length, '个方块');
//console.log('方块加载成功,共加载了', this.Block_Array.length, '个方块');
this.setSort();
this.load1 = true;
});
cc.resources.loadDir(path2, cc.Prefab, (err, assets: cc.Prefab[]) => {
if (err) {
console.log('动态加载 wall 失败:', err);
//console.log('动态加载 wall 失败:', err);
cc.director.loadScene("LoadScene");
return;
}
// 将加载的 Prefab 赋值给 Block_Array
this.Wall_Prefab = assets;
this.load2 = true;
console.log('墙加载成功,共加载了', this.Wall_Prefab.length, '个墙');
//console.log('墙加载成功,共加载了', this.Wall_Prefab.length, '个墙');
this.setWallPrefabSort();
});
}, 100);
@ -177,7 +177,7 @@ export default class GameManager extends cc.Component {
// // 加载失败时仍尝试进入 HomeScene
// cc.director.loadScene("HomeScene");
// } else {
// console.log('music bundle 加载成功');
// //console.log('music bundle 加载成功');
// }
// cc.director.loadScene("HomeScene");
// });
@ -185,7 +185,7 @@ export default class GameManager extends cc.Component {
if (err) {
console.error('加载 shop 失败:', err);
} else {
console.log('shop加载成功');
//console.log('shop加载成功');
// 加载成功后进入 HomeScene
cc.assetManager.loadBundle('music', (err, bundle) => {
if (err) {
@ -193,7 +193,7 @@ export default class GameManager extends cc.Component {
// 加载失败时仍尝试进入 HomeScene
cc.director.loadScene("HomeScene");
} else {
console.log('music bundle 加载成功');
//console.log('music bundle 加载成功');
}
cc.director.loadScene("HomeScene");
});
@ -236,53 +236,85 @@ export default class GameManager extends cc.Component {
if (typeof wx !== 'undefined' && wx !== null) {
MiniGameSdk.API.shushu_Init();
this.nowTime = Date.now();
console.log("开始读取用户信息的时间:", this.nowTime);
Utils.getUserInfo((data) => {
console.log("登录成功时间耗时:", Date.now() - this.nowTime);
console.log("登陆成功_____________", data);
console.log("uid", data.data.onlyId);
if (data.data._id) {
cc.fx.GameConfig.GM_INFO.uid = data.data._id;
cc.fx.StorageMessage.setStorage("uid", data.data._id);
}
if (data.data.onlyId) {
console.log(":应该进入这里");
console.log("_______________Uid:", data.data.onlyId);
cc.fx.GameConfig.GM_INFO.userId = data.data.onlyId;
}
if (data.data.outTradeNo.length > 0) {
console.log("设置补发数据", data.data.outTradeNo);
cc.fx.GameConfig.GM_INFO.allOutTradeNo = [];
cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.data.outTradeNo;
console.log("______________________________有未发放奖励", cc.fx.GameConfig.GM_INFO.allOutTradeNo);
}
if (data.data.shareLv) {
if (data.data.shareLvl.length > 0) {
console.log("设置分享等级", data.data.shareLv);
cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv;
}
}
this.setUserPower(data);
this.setmonth(data);
this.setRevive(data)
let levelInfo = cc.fx.StorageMessage.getStorage("level");
//旧的读取数据设置数据方法,以强联网为主
if (levelInfo == undefined || levelInfo == "" || levelInfo == null) {
this.oldReadData(retryCount);
}
//新的读取数据设置方法,以本地为主
else {
this.newReadData();
}
//console.log("开始读取用户信息的时间:", this.nowTime);
console.log("即将读取体力值");
cc.fx.GameTool.getHealth((data) => {
console.log("体力值完成进入游戏");
this.load5 = true;
console.log("获取体力值成功时间耗时:", Date.now() - this.nowTime);
const MAX_RETRIES = 15;
// 延迟时间数组,按照 1 秒 3 次、2 秒 5 次、5 秒 6 次、15 秒 5 次的规则生成
const delays = [
...Array(3).fill(1000),
...Array(5).fill(2000),
...Array(6).fill(5000),
...Array(5).fill(15000)
];
const attemptUserInfo = () => {
Utils.getUserInfo((data) => {
if (data.code == 1) { // 假设返回数据中有 success 字段表示成功
//console.log("登录成功时间耗时:", Date.now() - this.nowTime);
console.log("登陆成功_____________");
console.log(data);
//console.log("uid", data.data.onlyId);
if (data.data._id) {
cc.fx.GameConfig.GM_INFO.uid = data.data._id;
cc.fx.StorageMessage.setStorage("uid", data.data._id);
}
if (data.data.onlyId) {
//console.log(":应该进入这里");
//console.log("_______________Uid:", data.data.onlyId);
cc.fx.GameConfig.GM_INFO.userId = data.data.onlyId;
}
if (data.data.outTradeNo.length > 0) {
//console.log("设置补发数据", data.data.outTradeNo);
cc.fx.GameConfig.GM_INFO.allOutTradeNo = [];
cc.fx.GameConfig.GM_INFO.allOutTradeNo = data.data.outTradeNo;
//console.log("______________________________有未发放奖励", cc.fx.GameConfig.GM_INFO.allOutTradeNo);
}
if (data.data.shareLv) {
console.log("有补发信息", data.data.shareLv)
if (data.data.shareLv.length > 0) {
console.log(data.data.shareLv[0]);
console.log("设置分享等级", data.data.shareLv[0].lv);
cc.fx.GameConfig.GM_INFO.helpLevel = data.data.shareLv[0].lv;
}
}
this.setUserPower(data);
this.setmonth(data);
this.setRevive(data)
let levelInfo = cc.fx.StorageMessage.getStorage("level");
//旧的读取数据设置数据方法,以强联网为主
if (levelInfo == undefined || levelInfo == "" || levelInfo == null) {
this.oldReadData(retryCount);
}
//新的读取数据设置方法,以本地为主
else {
this.newReadData();
}
//console.log("即将读取体力值");
cc.fx.GameTool.getHealth((data) => {
//console.log("体力值完成进入游戏");
this.load5 = true;
//console.log("获取体力值成功时间耗时:", Date.now() - this.nowTime);
});
this.load6 = true;
}
else {
if (retryCount < MAX_RETRIES && retryCount < delays.length) {
const delay = delays[retryCount];
console.error(`获取用户信息失败,第 ${retryCount + 1} 次重试,将在 ${delay / 1000} 秒后重试`);
setTimeout(() => {
retryCount++;
attemptUserInfo();
}, delay);
} else {
console.error('获取用户信息失败,达到最大重试次数,退出游戏');
// 退出游戏
cc.game.end();
}
}
});
this.load6 = true;
});
};
attemptUserInfo();
}
else {
this.load3 = true;
@ -313,10 +345,10 @@ export default class GameManager extends cc.Component {
//新用户,有本地缓存读取配置
newReadData() {
console.log("读取新信息2");
//console.log("读取新信息2");
let openid = cc.fx.StorageMessage.getStorage("openid");
if (openid == null || openid == "" || openid == undefined) {
console.log("没有openid");
//console.log("没有openid");
//@ts-ignore
wx.cloud.callFunction({
name: 'userData',
@ -324,7 +356,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) {
@ -360,39 +392,47 @@ export default class GameManager extends cc.Component {
const timestamp = Date.now();
let levelInfo = cc.fx.StorageMessage.getStorage("level");
if (data.result.code == 404 && data.result.message == "未找到关卡数据") {
// console.log("没有等级信息,从用户接口拿到数据");
// //console.log("没有等级信息,从用户接口拿到数据");
if (levelInfo.level) {
cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level);
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1;
console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
if ((cc.fx.GameConfig.GM_INFO.level) > 323) {
cc.fx.GameConfig.GM_INFO.level = 323;
}
//console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
}
}
this.load4 = true;
levelInfo.level = cc.fx.GameConfig.GM_INFO.level;
levelInfo.timestamp = timestamp;
cc.fx.StorageMessage.setStorage("level", levelInfo);
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
//console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
cc.fx.GameTool.setUserLevel((data) => {
});
}
else if (data.result.code == 200) {
// console.log("有等级信息,从关卡接口拿到数据",data.result.data);
// //console.log("有等级信息,从关卡接口拿到数据",data.result.data);
//游戏前端存储 新于服务器端,以游戏前端信息为主,放服务器存储
let temp = data.result.timestamp - levelInfo.timestamp;
console.log("等级时间差:", temp);
//console.log("等级时间差:", temp);
if ((data.result.timestamp - levelInfo.timestamp) < 10000 && levelInfo.level >= data.result.data) {
if (levelInfo.level) {
console.log("以游戏前端等级为准", data.result.data);
//console.log("以游戏前端等级为准", data.result.data);
cc.fx.GameConfig.GM_INFO.level = levelInfo.level;
console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level);
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1;
console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
if ((cc.fx.GameConfig.GM_INFO.level) > 323) {
cc.fx.GameConfig.GM_INFO.level = 323;
}
//console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
}
levelInfo.level = cc.fx.GameConfig.GM_INFO.level;
levelInfo.timestamp = timestamp;
cc.fx.StorageMessage.setStorage("level", levelInfo);
// console.log("等级为:",cc.fx.GameConfig.GM_INFO.level);
// //console.log("等级为:",cc.fx.GameConfig.GM_INFO.level);
cc.fx.GameTool.setUserLevel((data) => {
});
}
@ -400,15 +440,15 @@ export default class GameManager extends cc.Component {
}
//服务器端存储时间新于游戏端,以服务器端为主,往前端存储
else {
console.log("以服务器等级为准", data.result.data);
//console.log("以服务器等级为准", data.result.data);
cc.fx.GameConfig.GM_INFO.level = data.result.data;
levelInfo.level = cc.fx.GameConfig.GM_INFO.level;
levelInfo.timestamp = timestamp;
// console.log("1111111存储关卡数据:",cc.fx.GameConfig.GM_INFO.level);
// //console.log("1111111存储关卡数据:",cc.fx.GameConfig.GM_INFO.level);
cc.fx.StorageMessage.setStorage("level", levelInfo);
}
this.load4 = true;
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
//console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
}
});
//金币信息
@ -418,43 +458,43 @@ export default class GameManager extends cc.Component {
if (data.result.code == 404 && data.result.message == "未找到金币数据") {
if (coinInfo.coin)
cc.fx.GameConfig.GM_INFO.coin = coinInfo.coin;
console.log("没有金币信息,从用户接口拿到数据", cc.fx.GameConfig.GM_INFO.coin);
console.log("金币成功时间耗时:", Date.now() - this.nowTime);
//console.log("没有金币信息,从用户接口拿到数据", cc.fx.GameConfig.GM_INFO.coin);
//console.log("金币成功时间耗时:", Date.now() - this.nowTime);
this.load3 = true;
cc.fx.GameTool.setUserCoin((data) => {
});
}
else if (data.result.code == 200) {
// console.log("有金币信息,从金币接口拿到数据",data.result.data);
// //console.log("有金币信息,从金币接口拿到数据",data.result.data);
//游戏前端存储 新于服务器端,以游戏前端信息为主,放服务器存储
let temp = data.result.timestamp - coinInfo.timestamp;
console.log("金币时间差:", temp);
//console.log("金币时间差:", temp);
if ((data.result.timestamp - coinInfo.timestamp) < 10000) {
console.log("以前端金幣为准:", coinInfo);
//console.log("以前端金幣为准:", coinInfo);
if (coinInfo.coin)
cc.fx.GameConfig.GM_INFO.coin = coinInfo.coin;
else {
cc.fx.GameConfig.GM_INFO.coin = data.result.data;
coinInfo.coin = cc.fx.GameConfig.GM_INFO.coin;
coinInfo.timestamp = timestamp;
console.log("11111111111");
//console.log("11111111111");
cc.fx.StorageMessage.setStorage("coin", coinInfo);
}
console.log("改变后金币:", cc.fx.GameConfig.GM_INFO.coin);
//console.log("改变后金币:", cc.fx.GameConfig.GM_INFO.coin);
cc.fx.GameTool.setUserCoin((data) => {
});
}
//服务器端存储时间新于游戏端,以服务器端为主,往前端存储
else {
console.log("以服务器金幣为准:", data.result.data);
//console.log("以服务器金幣为准:", data.result.data);
cc.fx.GameConfig.GM_INFO.coin = data.result.data;
coinInfo.coin = cc.fx.GameConfig.GM_INFO.coin;
coinInfo.timestamp = timestamp;
console.log("2222222222");
//console.log("2222222222");
cc.fx.StorageMessage.setStorage("coin", coinInfo);
}
this.load3 = true;
console.log("金币成功时间耗时:", Date.now() - this.nowTime);
//console.log("金币成功时间耗时:", Date.now() - this.nowTime);
}
});
//道具信息
@ -462,9 +502,9 @@ export default class GameManager extends cc.Component {
const timestamp = Date.now();
let propInfo = cc.fx.StorageMessage.getStorage("prop");
if (data.result.code == 404 && data.result.message == "未找到道具数据") {
console.log("没有道具信息,从用户接口拿到数据", propInfo);
//console.log("没有道具信息,从用户接口拿到数据", propInfo);
if (propInfo.freezeAmount == undefined || propInfo.hammerAmount == undefined || propInfo.magicAmount == undefined) {
console.log("____________________道具数据异常");
//console.log("____________________道具数据异常");
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmoun = 3;
@ -474,11 +514,11 @@ export default class GameManager extends cc.Component {
"magicAmount": cc.fx.GameConfig.GM_INFO.magicAmoun,
"timestamp": timestamp
}
console.log("_______________1111上传道具信息:", propInfoNew);
//console.log("_______________1111上传道具信息:", propInfoNew);
cc.fx.StorageMessage.setStorage("prop", propInfoNew);
}
else {
console.log("_______________________道具数据正常", propInfo);
//console.log("_______________________道具数据正常", propInfo);
// cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze;
// cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer;
// cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand;
@ -490,11 +530,11 @@ export default class GameManager extends cc.Component {
});
}
else if (data.result.code == 200) {
console.log("本地时间戳", propInfo.timestamp, "服务器时间戳", data.result.timestamp);
//console.log("本地时间戳", propInfo.timestamp, "服务器时间戳", data.result.timestamp);
if ((data.result.timestamp - propInfo.timestamp) < 10000) {
console.log("以前端道具为主:", propInfo);
//console.log("以前端道具为主:", propInfo);
if (propInfo.freezeAmount == undefined || propInfo.hammerAmount == undefined || propInfo.magicAmount == undefined) {
console.log("111111道具数据异常", data.result.data);
//console.log("111111道具数据异常", data.result.data);
cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze;
cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer;
cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand;
@ -504,11 +544,11 @@ export default class GameManager extends cc.Component {
"magicAmount": cc.fx.GameConfig.GM_INFO.magicAmount,
"timestamp": timestamp
}
console.log("333333上传道具信息:", propInfoNew);
//console.log("333333上传道具信息:", propInfoNew);
cc.fx.StorageMessage.setStorage("prop", propInfoNew);
}
else {
console.log("道具数据正常");
//console.log("道具数据正常");
cc.fx.GameConfig.GM_INFO.freezeAmount = propInfo.freezeAmount;
cc.fx.GameConfig.GM_INFO.hammerAmount = propInfo.hammerAmount;
cc.fx.GameConfig.GM_INFO.magicAmount = propInfo.magicAmount;
@ -527,7 +567,7 @@ export default class GameManager extends cc.Component {
"magicAmount": cc.fx.GameConfig.GM_INFO.magicAmount,
"timestamp": timestamp
}
console.log("22222222上传道具信息:", propInfoNew, data.result);
//console.log("22222222上传道具信息:", propInfoNew, data.result);
cc.fx.StorageMessage.setStorage("prop", propInfoNew);
}
}
@ -535,7 +575,7 @@ export default class GameManager extends cc.Component {
}
//旧用户,无本地缓存读取配置
oldReadData(retryCount: number) {
console.log("________读取旧信息");
//console.log("________读取旧信息");
const MAX_RETRIES = 15;
const timestamp = Date.now();
// 读取用户数据
@ -546,28 +586,28 @@ export default class GameManager extends cc.Component {
action: 'read'
},
success: res => {
console.log('11111111读取用户数据成功', res.result)
//console.log('11111111读取用户数据成功', res.result)
if (res.result.code == 404 && res.result.message == "未找到用户数据") {
if (res.result.openid) {
console.log("用户从未进入过第一次设置openid:");
console.log(res.result.openid);
//console.log("用户从未进入过第一次设置openid:");
//console.log(res.result.openid);
cc.fx.GameConfig.GM_INFO.openid = res.result.openid
}
else {
console.log("用户此一次进入游戏为正确获取openid");
//console.log("用户此一次进入游戏为正确获取openid");
}
cc.fx.GameTool.getUserLevel((data) => {
if (data.result.code == 404 && data.result.message == "未找到关卡数据") {
console.log("没有等级信息,从用户接口拿到数据");
//console.log("没有等级信息,从用户接口拿到数据");
cc.fx.GameConfig.GM_INFO.first = true;
console.log("金币成功时间耗时:", Date.now() - this.nowTime);
//console.log("金币成功时间耗时:", Date.now() - this.nowTime);
this.load3 = true;
this.load4 = true;
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
//console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
let levelInfo = { "level": 0, "timestamp": timestamp };
cc.fx.StorageMessage.setStorage("level", levelInfo);
let coinInfo = { "coin": 0, "timestamp": timestamp };
console.log("33333333333");
//console.log("33333333333");
cc.fx.StorageMessage.setStorage("coin", coinInfo);
let propInfo = {
"freezeAmount": 3,
@ -575,7 +615,7 @@ export default class GameManager extends cc.Component {
"magicAmount": 3,
"timestamp": timestamp,
}
console.log("最新上传道具信息——————————:", propInfo);
//console.log("最新上传道具信息——————————:", propInfo);
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmount = 3;
@ -583,7 +623,7 @@ export default class GameManager extends cc.Component {
cc.fx.GameTool.setUserInfo((data) => {
if (data.result.code == 200) {
console.log("上传用户信息成功", data);
//console.log("上传用户信息成功", data);
//@ts-ignore
wx.cloud.callFunction({
name: 'userData',
@ -591,7 +631,7 @@ export default class GameManager extends cc.Component {
action: 'read'
},
success: res => {
console.log("上传后,读取用户信息,为上报注册时间")
//console.log("上传后,读取用户信息,为上报注册时间")
if (res.result.code == 200) {
const time = res.result.data.register_time;
MiniGameSdk.API.shushu_userSet(time);
@ -604,7 +644,7 @@ export default class GameManager extends cc.Component {
})
}
});
console.log("服务器也没有金币信息", cc.fx.GameConfig.GM_INFO.coin);
//console.log("服务器也没有金币信息", cc.fx.GameConfig.GM_INFO.coin);
cc.fx.GameTool.setUserCoin(cc.fx.GameConfig.GM_INFO.coin, (data) => {
});
@ -617,7 +657,7 @@ export default class GameManager extends cc.Component {
cc.fx.GameTool.setUserProp(0, 0, (data) => {
if (data.result.code == 200) {
console.log("1111111上传道具信息成功", data);
//console.log("1111111上传道具信息成功", data);
}
else {
MiniGameSdk.API.showToast("网络异常,正在努力加载");
@ -629,7 +669,7 @@ export default class GameManager extends cc.Component {
}, 0);
}
else if (data.result.code == 200) {
console.log("有等级信息,从关卡接口拿到数据", data.result.data);
//console.log("有等级信息,从关卡接口拿到数据", data.result.data);
this.readSever(timestamp);
}
})
@ -678,7 +718,7 @@ export default class GameManager extends cc.Component {
setUserData() {
cc.fx.GameConfig.GameTool((data) => {
console.log("上传", data);
//console.log("上传", data);
})
}
@ -775,12 +815,12 @@ export default class GameManager extends cc.Component {
cc.fx.GameConfig.GM_INFO.hp_Max = 5;
cc.fx.GameConfig.GM_INFO.doubleCoin = 1;
}
console.log(cc.fx.GameConfig.GM_INFO.hp_Max, "00000000000");
//console.log(cc.fx.GameConfig.GM_INFO.hp_Max, "00000000000");
}
//复活购买次数初始化
setRevive(data) {
cc.fx.GameConfig.GM_INFO.revive = data.data.rebornGiftCount;
console.log(data.data.rebornGiftCount, cc.fx.GameConfig.GM_INFO.revive, "🔥🔥🔥🔥🔥🔥🔥🔥")
//console.log(data.data.rebornGiftCount, cc.fx.GameConfig.GM_INFO.revive, "🔥🔥🔥🔥🔥🔥🔥🔥")
}
readSever(timestamp) {
@ -791,57 +831,61 @@ export default class GameManager extends cc.Component {
let coinInfo = { "coin": 0, "timestamp": timestamp };
cc.fx.GameConfig.GM_INFO.coin = 0;
cc.fx.StorageMessage.setStorage("coin", coinInfo);
console.log("没有金币信息,从用户接口拿到数据", cc.fx.GameConfig.GM_INFO.coin);
//console.log("没有金币信息,从用户接口拿到数据", cc.fx.GameConfig.GM_INFO.coin);
cc.fx.GameTool.setUserCoin((data) => {
// console.log("上传",data);
// //console.log("上传",data);
this.load3 = true;
console.log("金币成功时间耗时:", Date.now() - this.nowTime);
//console.log("金币成功时间耗时:", Date.now() - this.nowTime);
});
}
else if (data.result.code == 200) {
// console.log("有金币信息,从金币接口拿到数据",data.result.data);
// //console.log("有金币信息,从金币接口拿到数据",data.result.data);
cc.fx.GameConfig.GM_INFO.coin = data.result.data;
let coinInfo = { "coin": cc.fx.GameConfig.GM_INFO.coin, "timestamp": timestamp };
console.log("存储金币信息:", cc.fx.GameConfig.GM_INFO.coin);
console.log("4444444444");
//console.log("存储金币信息:", cc.fx.GameConfig.GM_INFO.coin);
//console.log("4444444444");
cc.fx.StorageMessage.setStorage("coin", coinInfo);
this.load3 = true;
console.log("金币成功时间耗时:", Date.now() - this.nowTime);
//console.log("金币成功时间耗时:", Date.now() - this.nowTime);
}
})
}, 500);
cc.fx.GameTool.getUserLevel((data) => {
if (data.result.code == 404 && data.result.message == "未找到关卡数据") {
console.log("没有等级信息,从用户接口拿到数据");
//console.log("没有等级信息,从用户接口拿到数据");
let levelInfo = { "level": 0, "timestamp": timestamp };
// console.log("333333存储关卡数据:",levelInfo);
// //console.log("333333存储关卡数据:",levelInfo);
cc.fx.GameConfig.GM_INFO.level = 0;
cc.fx.StorageMessage.setStorage("level", levelInfo);
cc.fx.GameTool.setUserLevel((data) => {
console.log("拿到的数据", data);
//console.log("拿到的数据", data);
this.load4 = true;
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
//console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
});
}
else if (data.result.code == 200) {
console.log("有等级信息,从关卡接口拿到数据", data.result.data);
//console.log("有等级信息,从关卡接口拿到数据", data.result.data);
cc.fx.GameConfig.GM_INFO.level = data.result.data;
console.log(cc.fx.GameConfig.GM_INFO.helpLevel, "___________________", cc.fx.GameConfig.GM_INFO.level);
if (cc.fx.GameConfig.GM_INFO.helpLevel == (cc.fx.GameConfig.GM_INFO.level + 1)) {
cc.fx.GameConfig.GM_INFO.level += 1;
console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
if ((cc.fx.GameConfig.GM_INFO.level) > 323) {
cc.fx.GameConfig.GM_INFO.level = 323;
}
//console.log("好友帮助通过第" + cc.fx.GameConfig.GM_INFO.helpLevel + "关");
}
let levelInfo = { "level": cc.fx.GameConfig.GM_INFO.level, "timestamp": timestamp };
// console.log("444444存储关卡信息:",levelInfo);
// //console.log("444444存储关卡信息:",levelInfo);
cc.fx.StorageMessage.setStorage("level", levelInfo);
this.load4 = true;
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
//console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
}
})
setTimeout(() => {
cc.fx.GameTool.getUserProp((data) => {
if (data.result.code == 404 && data.result.message == "未找到道具数据") {
console.log("没有道具信息,从用户接口拿到数据");
//console.log("没有道具信息,从用户接口拿到数据");
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmount = 3;
@ -851,13 +895,13 @@ export default class GameManager extends cc.Component {
"magicAmount": 3,
"timestamp": timestamp,
}
console.log("上传道具信息44444444:", propInfo);
//console.log("上传道具信息44444444:", propInfo);
cc.fx.StorageMessage.setStorage("prop", propInfo);
cc.fx.GameTool.setUserProp(0, 0, (data) => {
});
}
else if (data.result.code == 200) {
console.log("有道具信息,从道具接口拿到数据", data.result.data);
//console.log("有道具信息,从道具接口拿到数据", data.result.data);
cc.fx.GameConfig.GM_INFO.freezeAmount = data.result.data.freeze || 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = data.result.data.hammer || 3;
cc.fx.GameConfig.GM_INFO.magicAmount = data.result.data.magic_wand || 3;
@ -867,7 +911,7 @@ export default class GameManager extends cc.Component {
"magicAmount": cc.fx.GameConfig.GM_INFO.magicAmount,
"timestamp": timestamp,
}
console.log("上传道具信息6666666:", propInfo);
//console.log("上传道具信息6666666:", propInfo);
cc.fx.StorageMessage.setStorage("prop", propInfo);
}
@ -887,17 +931,17 @@ export default class GameManager extends cc.Component {
const uid = query.uid;
cc.fx.GameConfig.GM_INFO.otherUid = uid;
cc.fx.GameConfig.GM_INFO.otherLevel = level;
console.log('从分享链接获取到的关卡信息:', level);
console.log('从分享链接获取到的 UID:', uid);
//console.log('从分享链接获取到的关卡信息:', level);
//console.log('从分享链接获取到的 UID:', uid);
// 可以在这里处理关卡信息和 UID
}
}
}
update(dt) {
//console.log("加载1:", this.load1, "加载2:", this.load2, "加载3:", this.load3, "加载4:", this.load4, "加载5:", this.load5, "加载6:", this.load6, "时间:", this.timeNumber);
////console.log("加载1:", this.load1, "加载2:", this.load2, "加载3:", this.load3, "加载4:", this.load4, "加载5:", this.load5, "加载6:", this.load6, "时间:", this.timeNumber);
if (this.load1 && this.load2 && this.load3 && this.load4 && this.load5 && this.load6 == true && this.timeNumber <= 0) {
console.log("进入游戏_______________");
//console.log("进入游戏_______________");
this.load1 = this.load2 = false;
MiniGameSdk.API.shushu_Login();
MiniGameSdk.API.yinli_Init();

View File

@ -80,6 +80,7 @@ export default class JiaZai extends cc.Component {
// LIFE-CYCLE CALLBACKS:
onLoad() {
this.closeLoad();
this.checkShare();
console.log("进入首页获取的share", cc.fx.GameConfig.GM_INFO.otherUid, cc.fx.GameConfig.GM_INFO.otherLevel);
if (cc.fx.GameConfig.GM_INFO.otherUid != "") {
@ -150,6 +151,7 @@ export default class JiaZai extends cc.Component {
return;
}
else {
// this.closeLoad();
cc.fx.GameConfig.LEVEL_INFO_init(true, 1000);
}
}
@ -884,28 +886,28 @@ export default class JiaZai extends cc.Component {
}
//获取月卡有效期距离今天的天数
getMonthlyCardValidityDays(): Promise<number> {
return new Promise((resolve, reject) => {
Utils.getMonthlyCard((data) => {
if (data.code === 1) {
const validityTime = data.data.monthCardTime; // 后端返回的到期时间戳(毫秒)
const today = new Date();
today.setHours(0, 0, 0, 0);
const todayMidnight = today.getTime();
const expiryDate = new Date(validityTime);
expiryDate.setHours(0, 0, 0, 0);
const expiryMidnight = expiryDate.getTime();
const diffMs = expiryMidnight - todayMidnight;
const days = Math.floor(diffMs / 86400000);
const remainingDays = Math.max(0, days);
cc.fx.GameConfig.GM_INFO.monthTime = remainingDays;
resolve(remainingDays);
} else {
resolve(0); // 或 reject(data) 根据需要
}
getMonthlyCardValidityDays(): Promise<number> {
return new Promise((resolve, reject) => {
Utils.getMonthlyCard((data) => {
if (data.code === 1) {
const validityTime = data.data.monthCardTime; // 后端返回的到期时间戳(毫秒)
const today = new Date();
today.setHours(0, 0, 0, 0);
const todayMidnight = today.getTime();
const expiryDate = new Date(validityTime);
expiryDate.setHours(0, 0, 0, 0);
const expiryMidnight = expiryDate.getTime();
const diffMs = expiryMidnight - todayMidnight;
const days = Math.floor(diffMs / 86400000);
const remainingDays = Math.max(0, days);
cc.fx.GameConfig.GM_INFO.monthTime = remainingDays;
resolve(remainingDays);
} else {
resolve(0); // 或 reject(data) 根据需要
}
});
});
});
}
}
//获取有没有分享信息
getShareInfo() {
@ -917,10 +919,14 @@ export default class JiaZai extends cc.Component {
if (query.level && query.uid) {
const level = parseInt(query.level, 10);
const uid = query.uid;
cc.fx.GameConfig.GM_INFO.otherUid = uid;
cc.fx.GameConfig.GM_INFO.otherLevel = level;
console.log('从分享链接获取到的关卡信息:', level);
console.log('从分享链接获取到的 UID:', uid);
if (uid != cc.fx.GameConfig.GM_INFO.uid) {
cc.fx.GameConfig.GM_INFO.otherUid = uid;
cc.fx.GameConfig.GM_INFO.otherLevel = level;
console.log('从分享链接获取到的关卡信息:', level);
console.log('从分享链接获取到的 UID:', uid);
this.openLoad();
}
// 可以在这里处理关卡信息和 UID
}
}
@ -969,25 +975,29 @@ export default class JiaZai extends cc.Component {
//检测当日是否有分享行为,用不用主动获取分享关卡信息
checkShare() {
const otherInfo = cc.fx.StorageMessage.getStorage("otherLevel");
if (otherInfo && otherInfo.timeStamp && otherInfo.otherLevel) {
console.log("分享信息:", otherInfo);
if (otherInfo != null && otherInfo != undefined && otherInfo != "") {
const currentTime = Date.now();
const timeDifference = currentTime - otherInfo.timeStamp;
const oneDayInMilliseconds = 24 * 60 * 60 * 1000;
console.log("计入时间计算");
if (timeDifference > oneDayInMilliseconds || cc.fx.GameConfig.GM_INFO.level >= otherInfo.otherLevel) {
console.log("检查分享信息过期或已获取过,清除存储信息");
console.log("_______________检查分享信息过期或已获取过,清除存储信息");
cc.fx.StorageMessage.setStorage("otherLevel", null);
}
else {
if ((cc.fx.GameConfig.GM_INFO.level + 1) == otherInfo.otherLevel) {
console.log("有分享信息,并且符合条件");
Utils.getShareLevel((res) => {
if (res.code == 1) {
// if ((cc.fx.GameConfig.GM_INFO.level + 1) == otherInfo.otherLevel) {
console.log("_______________有分享信息,并且符合条件");
Utils.getShareLevel((res) => {
if (res.code == 1) {
if ((cc.fx.GameConfig.GM_INFO.level + 1) == res.data[0].lv) {
let title = "好友帮助通过第" + otherInfo.otherLevel + "关";
console.log(title);
MiniGameSdk.API.showToast(title);
cc.fx.GameConfig.GM_INFO.level = otherInfo.otherLevel;
if ((cc.fx.GameConfig.GM_INFO.level) > 323) {
cc.fx.GameConfig.GM_INFO.level = 323;
}
const timestamp = Date.now();
const levelInfo = {
level: cc.fx.GameConfig.GM_INFO.level, // 关卡
@ -999,9 +1009,11 @@ export default class JiaZai extends cc.Component {
});
}
})
}
}
})
// }
}
}
else {

View File

@ -1778,7 +1778,7 @@ export default class MapConroler extends cc.Component {
this.timeNumber = 21;
this.add_Time += 20;
}
NumberToImage.getTimeMargin(20, 50, "time_", this.timeLabel)
// NumberToImage.getTimeMargin(20, 50, "time_", this.timeLabel)
this.blockNum = this.blocks.length;
if (this.blockNum == 0) this.nextLevel();
@ -3190,7 +3190,7 @@ export default class MapConroler extends cc.Component {
let level = cc.fx.GameConfig.GM_INFO.otherLevel;
let uid = cc.fx.GameConfig.GM_INFO.otherUid;
Utils.shareLevel(level, uid, (data) => {
console.log("分享结果:", data);
});
}
}

View File

@ -439,7 +439,7 @@ export default class SceneManager extends cc.Component {
let timeStamp = Date.now();
let otherInfo = {
timeStamp: timeStamp,
otherLevel: cc.fx.GameConfig.GM_INFO.otherLevel,
otherLevel: (cc.fx.GameConfig.GM_INFO.level + 1),
}
cc.fx.StorageMessage.setStorage("otherLevel", otherInfo);
MiniGameSdk.API.shareGame();

View File

@ -1350,13 +1350,17 @@ export namespace MiniGameSdk {
//分享
static shareGame() {
if (typeof wx !== 'undefined' && wx !== null) {
let helpLevel = cc.fx.GameConfig.GM_INFO.level + 1;
if (helpLevel > 324) {
helpLevel = 324;
}
// 获取关卡信息和 UID
const level = cc.fx.GameConfig.GM_INFO.level + 1;
const level = helpLevel;
const uid = cc.fx.GameConfig.GM_INFO.uid;
// const title =
// 构建分享参数
const shareParams = {
title: '快来和我一起玩游戏吧!', // 分享标题
title: '如果你突然打了个喷嚏,那一定是我在等你帮忙过关!', // 分享标题
path: `/pages/index/index?level=${level}&uid=${uid}`, // 分享路径,带上关卡信息和 UID
imageUrl: 'https://example.com/share-image.png' // 分享图片链接
};

View File

@ -1034,7 +1034,7 @@ var GameTool = {
cc.fx.GameTool.changeCoin(5000);
coin = 5000;
price = 1800;
this.setUserPowerTime(20);
this.setUserPowerTime(1800);
// MiniGameSdk.API.showToast("获得无限体力小组合包");
rewardData = [
{ type: "coin", count: coin },

View File

@ -17,7 +17,7 @@
"__id__": 2
},
{
"__id__": 5
"__id__": 6
}
],
"_active": false,
@ -191,7 +191,7 @@
"ctor": "Float64Array",
"array": [
-97.164,
-284.062,
-417.143,
0,
0,
0,
@ -217,18 +217,12 @@
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_name": "bg",
"_objFlags": 0,
"_parent": {
"__id__": 1
"__id__": 6
},
"_children": [
{
"__id__": 6
},
{
"__id__": 9
},
{
"__id__": 4
},
@ -267,6 +261,78 @@
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "b7i0z42uZCe6L6/4fdasjO"
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 7
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 10
},
{
"__id__": 11
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1080,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
@ -301,16 +367,16 @@
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 5
"__id__": 6
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 7
"__id__": 8
},
{
"__id__": 8
"__id__": 9
}
],
"_prefab": null,
@ -366,7 +432,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 7
},
"_enabled": true,
"_cullingMask": 4294967295,
@ -402,114 +468,34 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 7
},
"_enabled": true,
"_id": "82rBHh8bJIGKuGw03a3Yrd"
},
{
"__type__": "cc.Node",
"_name": "bg",
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"_parent": {
"__id__": 5
"node": {
"__id__": 6
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 10
},
{
"__id__": 11
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 1080,
"height": 1920
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "b7i0z42uZCe6L6/4fdasjO"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "c09e129e-5195-4054-b8a5-65e1bd675c3f"
},
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "9cjtfCxPNC9qtsarnIvaIV"
"_fitWidth": true,
"_fitHeight": false,
"_id": "59Cd0ovbdF4byw5sbjJDx7"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 9
"__id__": 6
},
"_enabled": true,
"alignMode": 1,
@ -527,9 +513,9 @@
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1080,
"_originalHeight": 2340,
"_id": "c0sWn10ZdBD6+shoZmPwoN"
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "29zXboiXFBKoIV4PQ2liTe"
},
{
"__type__": "cc.Node",
@ -569,7 +555,7 @@
"ctor": "Float64Array",
"array": [
83.039,
-284.062,
-417.143,
0,
0,
0,
@ -663,7 +649,7 @@
"ctor": "Float64Array",
"array": [
-6.077,
-284.062,
-417.143,
0,
0,
0,
@ -720,21 +706,36 @@
"_id": "d6csD0iDBH4LhhASlK5PWc"
},
{
"__type__": "cc.Canvas",
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 1080,
"height": 1920
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "c09e129e-5195-4054-b8a5-65e1bd675c3f"
},
"_fitWidth": true,
"_fitHeight": false,
"_id": "59Cd0ovbdF4byw5sbjJDx7"
"_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "9cjtfCxPNC9qtsarnIvaIV"
},
{
"__type__": "cc.Widget",
@ -759,9 +760,9 @@
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "29zXboiXFBKoIV4PQ2liTe"
"_originalWidth": 1080,
"_originalHeight": 2340,
"_id": "c0sWn10ZdBD6+shoZmPwoN"
},
{
"__type__": "cc.Sprite",

View File

@ -11,7 +11,17 @@
"disablePlugins": [],
"outputPath": ""
},
"useCompilerPlugins": false
"useCompilerPlugins": false,
"compileWorklet": false,
"uploadWithSourceMap": true,
"packNpmManually": false,
"minifyWXSS": true,
"minifyWXML": true,
"localPlugins": false,
"disableUseStrict": false,
"condition": false,
"swc": false,
"disableSWC": true
},
"compileType": "game",
"simulatorPluginLibVersion": {},
@ -21,5 +31,6 @@
},
"isGameTourist": false,
"appid": "wxdd145ced49158a1e",
"editorSetting": {}
"editorSetting": {},
"libVersion": "3.8.10"
}

View File

@ -9,6 +9,14 @@
"preloadBackgroundData": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"compileHotReLoad": true
"compileHotReLoad": true,
"useApiHook": true,
"useApiHostProcess": true,
"useStaticServer": false,
"useLanDebug": false,
"showES6CompileOption": false,
"checkInvalidKey": true,
"ignoreDevUnusedFiles": true,
"bigPackageSizeSupport": false
}
}