Compare commits

...

9 Commits

Author SHA1 Message Date
YZ\249929363 7d17b6559d 更新 2025-08-04 10:41:10 +08:00
YZ\249929363 101417464b Merge branch 'main' of https://git.sparkus.cn/yangzhao/cb 2025-08-01 16:35:43 +08:00
YZ\249929363 461612e00b 暂存 2025-08-01 16:33:13 +08:00
YZ\249929363 a7cc1e5475 Merge branch 'main' of https://git.sparkus.cn/yangzhao/cb 2025-08-01 15:43:48 +08:00
YZ\249929363 6f2571068d 暂存 2025-08-01 15:43:41 +08:00
YZ\249929363 0222378540 Merge branch 'main' of https://git.sparkus.cn/yangzhao/cb 2025-08-01 15:21:53 +08:00
YZ\249929363 6f1368f836 暂存 2025-08-01 15:21:41 +08:00
YZ\249929363 2de1357398 Merge branch 'main' of https://git.sparkus.cn/yangzhao/cb 2025-08-01 10:46:36 +08:00
YZ\249929363 21cf30a5ce 暂存 2025-08-01 10:46:32 +08:00
14 changed files with 1481 additions and 960 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 243 KiB

File diff suppressed because it is too large Load Diff

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

@ -60,6 +60,7 @@ export default class GameManager extends cc.Component {
this.load1 = this.load2 = this.load3 = this.load4 = this.load5 = this.load6 = false;
setTimeout(() => {
this.readUserData();
this.getShareInfo();
}, 200);
@ -92,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);
@ -169,8 +170,6 @@ export default class GameManager extends cc.Component {
startGame() {
console.log("进入场景之前_____________", cc.fx.GameConfig.GM_INFO.first);
console.log(cc.fx.GameConfig.GM_INFO.level);
// 加载成功后进入 HomeScene
// cc.assetManager.loadBundle('music', (err, bundle) => {
// if (err) {
@ -178,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");
// });
@ -186,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) {
@ -194,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");
});
@ -237,47 +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);
}
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;
@ -308,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',
@ -319,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) {
@ -355,25 +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;
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;
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
levelInfo.level = cc.fx.GameConfig.GM_INFO.level;
levelInfo.timestamp = timestamp;
cc.fx.StorageMessage.setStorage("level", levelInfo);
//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);
if ((data.result.timestamp - levelInfo.timestamp) < 10000) {
//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.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;
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);
cc.fx.GameTool.setUserLevel((data) => {
});
}
@ -381,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);
}
});
//金币信息
@ -399,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);
}
});
//道具信息
@ -443,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;
@ -455,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;
@ -471,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;
@ -485,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;
@ -508,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);
}
}
@ -516,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();
// 读取用户数据
@ -527,85 +586,93 @@ 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.GameConfig.GM_INFO.first = true;
console.log("金币成功时间耗时:", Date.now() - this.nowTime);
this.load3 = true;
this.load4 = true;
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");
cc.fx.StorageMessage.setStorage("coin", coinInfo);
let propInfo = {
"freezeAmount": 3,
"hammerAmount": 3,
"magicAmount": 3,
"timestamp": timestamp,
}
console.log("最新上传道具信息——————————:", propInfo);
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmount = 3;
cc.fx.StorageMessage.setStorage("prop", propInfo);
cc.fx.GameTool.getUserLevel((data) => {
if (data.result.code == 404 && data.result.message == "未找到关卡数据") {
//console.log("没有等级信息,从用户接口拿到数据");
cc.fx.GameConfig.GM_INFO.first = true;
//console.log("金币成功时间耗时:", Date.now() - this.nowTime);
this.load3 = true;
this.load4 = true;
//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");
cc.fx.StorageMessage.setStorage("coin", coinInfo);
let propInfo = {
"freezeAmount": 3,
"hammerAmount": 3,
"magicAmount": 3,
"timestamp": timestamp,
}
//console.log("最新上传道具信息——————————:", propInfo);
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmount = 3;
cc.fx.StorageMessage.setStorage("prop", propInfo);
cc.fx.GameTool.setUserInfo((data) => {
if (data.result.code == 200) {
//console.log("上传用户信息成功", data);
//@ts-ignore
wx.cloud.callFunction({
name: 'userData',
data: {
action: 'read'
},
success: res => {
//console.log("上传后,读取用户信息,为上报注册时间")
if (res.result.code == 200) {
const time = res.result.data.register_time;
MiniGameSdk.API.shushu_userSet(time);
}
}
})
cc.fx.GameTool.setUserInfo((data) => {
if (data.result.code == 200) {
console.log("上传用户信息成功", data);
//@ts-ignore
wx.cloud.callFunction({
name: 'userData',
data: {
action: 'read'
},
success: res => {
console.log("上传后,读取用户信息,为上报注册时间")
if (res.result.code == 200) {
const time = res.result.data.register_time;
MiniGameSdk.API.shushu_userSet(time);
}
//laf云函数
Utils.getUserData((data) => {
})
}
})
});
//console.log("服务器也没有金币信息", cc.fx.GameConfig.GM_INFO.coin);
cc.fx.GameTool.setUserCoin(cc.fx.GameConfig.GM_INFO.coin, (data) => {
//laf云函数
Utils.getUserData((data) => {
})
});
cc.fx.GameTool.setUserLevel((data) => {
});
setTimeout(() => {
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmount = 3;
cc.fx.GameTool.setUserProp(0, 0, (data) => {
if (data.result.code == 200) {
//console.log("1111111上传道具信息成功", data);
}
else {
MiniGameSdk.API.showToast("网络异常,正在努力加载");
setTimeout(() => {
this.oldReadData(0);
}, 1000);
}
});
}, 0);
}
});
console.log("服务器也没有金币信息", cc.fx.GameConfig.GM_INFO.coin);
cc.fx.GameTool.setUserCoin(cc.fx.GameConfig.GM_INFO.coin, (data) => {
});
cc.fx.GameTool.setUserLevel((data) => {
});
setTimeout(() => {
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmount = 3;
cc.fx.GameTool.setUserProp(0, 0, (data) => {
if (data.result.code == 200) {
console.log("1111111上传道具信息成功", data);
}
else {
MiniGameSdk.API.showToast("网络异常,正在努力加载");
setTimeout(() => {
this.oldReadData(0);
}, 1000);
}
});
}, 0);
else if (data.result.code == 200) {
//console.log("有等级信息,从关卡接口拿到数据", data.result.data);
this.readSever(timestamp);
}
})
}
else if (res.result.code == 200) {
if (res.result.data) {
@ -621,91 +688,7 @@ export default class GameManager extends cc.Component {
const register_time = res.result.data.register_time;
MiniGameSdk.API.shushu_userSet(register_time);
}
setTimeout(() => {
cc.fx.GameTool.getUserCoin((data) => {
if (data.result.code == 404 && data.result.message == "未找到金币数据") {
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);
cc.fx.GameTool.setUserCoin((data) => {
// console.log("上传",data);
this.load3 = true;
console.log("金币成功时间耗时:", Date.now() - this.nowTime);
});
}
else if (data.result.code == 200) {
// 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");
cc.fx.StorageMessage.setStorage("coin", coinInfo);
this.load3 = true;
console.log("金币成功时间耗时:", Date.now() - this.nowTime);
}
})
}, 500);
cc.fx.GameTool.getUserLevel((data) => {
if (data.result.code == 404 && data.result.message == "未找到关卡数据") {
console.log("没有等级信息,从用户接口拿到数据");
let levelInfo = { "level": 0, "timestamp": timestamp };
// 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);
this.load4 = true;
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
});
}
else if (data.result.code == 200) {
console.log("有等级信息,从关卡接口拿到数据", data.result.data);
cc.fx.GameConfig.GM_INFO.level = data.result.data;
let levelInfo = { "level": cc.fx.GameConfig.GM_INFO.level, "timestamp": timestamp };
// console.log("444444存储关卡信息:",levelInfo);
cc.fx.StorageMessage.setStorage("level", levelInfo);
this.load4 = true;
console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
}
})
setTimeout(() => {
cc.fx.GameTool.getUserProp((data) => {
if (data.result.code == 404 && data.result.message == "未找到道具数据") {
console.log("没有道具信息,从用户接口拿到数据");
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmount = 3;
let propInfo = {
"freezeAmount": 3,
"hammerAmount": 3,
"magicAmount": 3,
"timestamp": timestamp,
}
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);
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;
let propInfo = {
"freezeAmount": cc.fx.GameConfig.GM_INFO.freezeAmount,
"hammerAmount": cc.fx.GameConfig.GM_INFO.hammerAmount,
"magicAmount": cc.fx.GameConfig.GM_INFO.magicAmount,
"timestamp": timestamp,
}
console.log("上传道具信息6666666:", propInfo);
cc.fx.StorageMessage.setStorage("prop", propInfo);
}
})
}, 0);
this.readSever(timestamp);
}
@ -716,7 +699,7 @@ export default class GameManager extends cc.Component {
console.error(`读取用户数据失败,第 ${retryCount + 1} 次重试,错误信息:`, err);
// 延迟 2 秒后重试
setTimeout(() => {
this.readUserData(retryCount + 1);
this.oldReadData(retryCount + 1);
}, 2000);
} else {
console.error('读取用户数据失败,达到最大重试次数,退出游戏', err);
@ -735,7 +718,7 @@ export default class GameManager extends cc.Component {
setUserData() {
cc.fx.GameConfig.GameTool((data) => {
console.log("上传", data);
//console.log("上传", data);
})
}
@ -832,19 +815,133 @@ 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, "🔥🔥🔥🔥🔥🔥🔥🔥")
cc.fx.GameConfig.GM_INFO.revive = data.data.rebornGiftCount;
//console.log(data.data.rebornGiftCount, cc.fx.GameConfig.GM_INFO.revive, "🔥🔥🔥🔥🔥🔥🔥🔥")
}
readSever(timestamp) {
setTimeout(() => {
cc.fx.GameTool.getUserCoin((data) => {
if (data.result.code == 404 && data.result.message == "未找到金币数据") {
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);
cc.fx.GameTool.setUserCoin((data) => {
// //console.log("上传",data);
this.load3 = true;
//console.log("金币成功时间耗时:", Date.now() - this.nowTime);
});
}
else if (data.result.code == 200) {
// //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");
cc.fx.StorageMessage.setStorage("coin", coinInfo);
this.load3 = true;
//console.log("金币成功时间耗时:", Date.now() - this.nowTime);
}
})
}, 500);
cc.fx.GameTool.getUserLevel((data) => {
if (data.result.code == 404 && data.result.message == "未找到关卡数据") {
//console.log("没有等级信息,从用户接口拿到数据");
let levelInfo = { "level": 0, "timestamp": timestamp };
// //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);
this.load4 = true;
//console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
});
}
else if (data.result.code == 200) {
//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;
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);
cc.fx.StorageMessage.setStorage("level", levelInfo);
this.load4 = true;
//console.log("关卡等级成功时间耗时:", Date.now() - this.nowTime);
}
})
setTimeout(() => {
cc.fx.GameTool.getUserProp((data) => {
if (data.result.code == 404 && data.result.message == "未找到道具数据") {
//console.log("没有道具信息,从用户接口拿到数据");
cc.fx.GameConfig.GM_INFO.freezeAmount = 3;
cc.fx.GameConfig.GM_INFO.hammerAmount = 3;
cc.fx.GameConfig.GM_INFO.magicAmount = 3;
let propInfo = {
"freezeAmount": 3,
"hammerAmount": 3,
"magicAmount": 3,
"timestamp": timestamp,
}
//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);
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;
let propInfo = {
"freezeAmount": cc.fx.GameConfig.GM_INFO.freezeAmount,
"hammerAmount": cc.fx.GameConfig.GM_INFO.hammerAmount,
"magicAmount": cc.fx.GameConfig.GM_INFO.magicAmount,
"timestamp": timestamp,
}
//console.log("上传道具信息6666666:", propInfo);
cc.fx.StorageMessage.setStorage("prop", propInfo);
}
})
}, 0);
}
//获取有没有分享信息
getShareInfo() {
// 检查微信小游戏启动参数
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
//@ts-ignore
const launchOptions = wx.getLaunchOptionsSync();
const query = launchOptions.query;
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);
// 可以在这里处理关卡信息和 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,7 +80,13 @@ export default class JiaZai extends cc.Component {
// LIFE-CYCLE CALLBACKS:
onLoad() {
this.getShareInfo();
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 != "") {
this.getShareInfo();
}
cc.game.setFrameRate(63);
LQCollideSystem.is_enable = true;
// //console.log("加载关卡配置2");
@ -145,6 +151,7 @@ export default class JiaZai extends cc.Component {
return;
}
else {
// this.closeLoad();
cc.fx.GameConfig.LEVEL_INFO_init(true, 1000);
}
}
@ -879,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() {
@ -912,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 - 1;
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
}
}
@ -961,5 +972,54 @@ export default class JiaZai extends cc.Component {
cc.fx.GameTool.shushu_Track("resource_get", dataTemp);
}
//检测当日是否有分享行为,用不用主动获取分享关卡信息
checkShare() {
const otherInfo = cc.fx.StorageMessage.getStorage("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("_______________检查分享信息过期或已获取过清除存储信息");
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) == 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, // 关卡
timestamp: timestamp, // 时间戳
};
cc.fx.StorageMessage.setStorage("level", levelInfo);
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
cc.fx.GameTool.setUserLevel((data) => {
});
}
}
})
// }
}
}
else {
console.log("没有分享信息");
}
}
// update (dt) {}
}

View File

@ -12,6 +12,7 @@ import SceneManager from "./SceneManager";
import { MiniGameSdk } from "./Sdk/MiniGameSdk";
import Animation = cc.Animation;
import Revive from "./Revive";
import Utils from "./module/Pay/Utils";
const { ccclass, property } = cc._decorator;
@ -365,7 +366,11 @@ export default class MapConroler extends cc.Component {
this.updateCoin();
// var timeTemp = cc.fx.GameTool.getTimeMargin(this.timeNumber);
// this.timeLabel.string = timeTemp.toString();
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 45, 0, "level_", this.levelLabel, true)
let levelName = (cc.fx.GameConfig.GM_INFO.level + 1);
if (cc.fx.GameConfig.GM_INFO.otherLevel) {
levelName = cc.fx.GameConfig.GM_INFO.otherLevel;
}
NumberToImage.numberToImageNodes(levelName, 45, 0, "level_", this.levelLabel, true)
console.log("当前关卡", cc.fx.GameConfig.GM_INFO.level + 1);
//this.startTimeCutDown();
@ -1576,7 +1581,10 @@ export default class MapConroler extends cc.Component {
cc.fx.GameTool.shushu_Track("resource_get", data);
let overTime = Date.now();
this.count_Time = overTime - this.count_Time;
cc.fx.GameTool.addLevel(this.count_Time, this.add_Time);
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
}
else cc.fx.GameTool.addLevel(this.count_Time, this.add_Time);
const winCOIN = cc.find("Canvas"); // 假设 Canvas 节点
if (winCOIN) {
const wincoin = winCOIN.getComponent(SceneManager);
@ -1770,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();
@ -1898,10 +1906,15 @@ export default class MapConroler extends cc.Component {
time = 2000;
}
setTimeout(() => {
this.node.parent.parent.getChildByName("Lose").active = true;
this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = true;
this.revive.getComponent(Revive).init();
this.node.parent.parent.getChildByName("Lose").getChildByName("Boom").active = false;
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
this.node.parent.parent.getChildByName("Lose").getChildByName("share").active = false;
}
else this.node.parent.parent.getChildByName("Lose").getChildByName("share").active = true;
if (type) {
if (type == "time") {
this.node.parent.parent.getChildByName("Lose").getChildByName("Time").active = true;
@ -3023,6 +3036,7 @@ export default class MapConroler extends cc.Component {
coins4.active = false;
caidai.active = false;
console.log(this.arr, "this.arr");
// 第一步:播放 title - 果冻弹跳效果
@ -3065,23 +3079,6 @@ export default class MapConroler extends cc.Component {
.to(0.3, { position: cc.v3(this.arr[6][0], this.arr[6][1], this.arr[6][2]) })
.start();
cc.tween(nextBtn)
.delay(0.1)
.to(0, { position: cc.v3(0, -880, 0), scale: 0 })
.call(() => {
nextBtn.active = true;
})
.to(0.15, { scale: 1.25 }, { easing: 'backOut' })
.to(0.08, { scale: 0.9 }, { easing: 'quadIn' })
.to(0.06, { scale: 1.15 }, { easing: 'quadOut' })
.to(0.04, { scale: 1 }, { easing: 'quadIn' })
.call(() => {
this.playDecorationGroup();
})
.to(0.3, { position: cc.v3(this.arr[5][0], this.arr[5][1], this.arr[5][2]) })
.start();
// tiaodik 动画(再延迟一点
cc.tween(tiaodik)
.delay(0.2)
@ -3095,6 +3092,31 @@ export default class MapConroler extends cc.Component {
.to(0.04, { scale: 1 }, { easing: 'quadIn' })
.to(0.3, { position: cc.v3(this.arr[4][0], this.arr[4][1], this.arr[4][2]) })
.start();
cc.tween(nextBtn)
.delay(0.1)
.to(0, { position: cc.v3(0, -880, 0), scale: 0 })
.call(() => {
if (cc.fx.GameConfig.GM_INFO.otherLevel == 0) {
nextBtn.active = true;
}
else {
cc.fx.GameConfig.GM_INFO.otherLevel = 0;
cc.fx.GameConfig.GM_INFO.otherUid = "";
}
})
.to(0.15, { scale: 1.25 }, { easing: 'backOut' })
.to(0.08, { scale: 0.9 }, { easing: 'quadIn' })
.to(0.06, { scale: 1.15 }, { easing: 'quadOut' })
.to(0.04, { scale: 1 }, { easing: 'quadIn' })
.call(() => {
this.playDecorationGroup();
})
.to(0.3, { position: cc.v3(this.arr[5][0], this.arr[5][1], this.arr[5][2]) })
.start();
}
// 播放装饰元素动画
@ -3164,12 +3186,17 @@ export default class MapConroler extends cc.Component {
}
setOtherLevel() {
if (cc.fx.GameConfig.GM_INFO.otherLevel == 1) {
cc.fx.GameConfig.GM_INFO.level = 2;
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
let level = cc.fx.GameConfig.GM_INFO.otherLevel;
let uid = cc.fx.GameConfig.GM_INFO.otherUid;
Utils.shareLevel(level, uid, (data) => {
console.log("分享结果:", data);
});
}
}
update(dt) {
}

View File

@ -142,8 +142,11 @@ export default class SceneManager extends cc.Component {
}
this.node.getChildByName("Game").getChildByName("bg").getComponent(cc.Sprite).spriteFrame = spriteFrame;
})
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
let levelName = (cc.fx.GameConfig.GM_INFO.level + 1);
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
levelName = cc.fx.GameConfig.GM_INFO.otherLevel;
}
NumberToImage.numberToImageNodes(levelName, 43, 15, "level_", this.level, true);
//time金币数量
NumberToImage.numberToImageNodes(1000, 25, 15, "button_", this.timeCoin, false);
}
@ -431,6 +434,17 @@ export default class SceneManager extends cc.Component {
this.RewardNode.zIndex = 1001;
}
shareFriend() {
console.log("设置分享链接");
let timeStamp = Date.now();
let otherInfo = {
timeStamp: timeStamp,
otherLevel: (cc.fx.GameConfig.GM_INFO.level + 1),
}
cc.fx.StorageMessage.setStorage("otherLevel", otherInfo);
MiniGameSdk.API.shareGame();
}
update(dt) {
}

View File

@ -1348,15 +1348,19 @@ export namespace MiniGameSdk {
}
//分享
shareGame() {
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

@ -109,7 +109,8 @@ export class GameConfig {
monthTime: number; //月卡时间
revive: number; //复活礼包购买次数
otherUid: string; //其他被帮助用户id
otherLevel: number;
otherLevel: number; //其他被帮助用户等级
helpLevel: number;
};
@ -120,6 +121,7 @@ export class GameConfig {
//游戏内信息
static get Instance() {
@ -266,6 +268,7 @@ export class GameConfig {
revive: 0, //复活礼包购买次数
otherUid: "", //其他被帮助用户id
otherLevel: 0, //其他被帮助用户等级
helpLevel: 0, //帮助用户等级
};
// this.setCode(this.getKey("scode"));
// this.GM_INFO.level = 0;
@ -308,7 +311,7 @@ export class GameConfig {
let name = "Json/level" + (cc.fx.GameConfig.GM_INFO.level + 1);
if (cc.fx.GameConfig.GM_INFO.otherLevel > 0) {
console.log("进入特殊帮助关卡,可越过自己关卡等级");
name = "Json/level" + (cc.fx.GameConfig.GM_INFO.otherLevel + 1);
name = "Json/level" + cc.fx.GameConfig.GM_INFO.otherLevel;
}
// //console.log("关卡名称:",name);
// name = "Json/level" + 68;

View File

@ -959,6 +959,65 @@ export default class Utils {
}
}
//设置分享成功信息,帮别人成功
static shareLevel(otherLevel, uid, callBack) {
let otheruid = uid || "";
let level = otherLevel || 0;
let data = {
uid: otheruid,
otherUid: cc.fx.GameConfig.GM_INFO.uid,
shareLv: level,
};
// 延迟时间数组,按照 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)
];
let attempt = 0; // 轮询次数
const poll = () => {
if (attempt >= delays.length) {
MiniGameSdk.API.showToast("网络异常,分享数据提交失败");
callBack({ code: 0, data: null, message: '轮询超时' });
return;
}
Utils.POST("shareLvSuccess", data, res => {
console.log("获得shareLvSuccess数据:", res);
if (res.code === 1) {
console.log("服务器:分享帮助通过关卡数据成功", res);
callBack(res);
} else {
attempt++;
setTimeout(poll, delays[attempt - 1]);
}
});
};
poll();
}
//获取分享信息
static getShareLevel(callBack) {
let data = {
uid: cc.fx.GameConfig.GM_INFO.uid
};
if (typeof wx !== 'undefined' && wx !== null) {
Utils.POST("getShareLv", data, res => {
console.log("获得shareLvSuccess数据:", res);
if (res.code === 1) {
console.log("服务器:分享帮助通过关卡数据成功", res);
if (callBack) callBack(res);
} else {
if (callBack) callBack(res);
}
});
}
}
// const propName={
//   gold_1: "金币包1",
//   gold_2: "金币包2",

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 },
@ -1397,7 +1397,7 @@ var GameTool = {
})
}
},
//判断是否有无限体力//返回true有false没有
getUserPowerTime() {
if (cc.fx.GameConfig.GM_INFO.userPowerTime > 0) {
let nowTime = Math.floor(Date.now() / 1000);
@ -1417,5 +1417,14 @@ var GameTool = {
}
}
//判断本地缓存关卡等级是否大于服务器存储
//返回true本地缓存大于服务器存储false本地缓存小于等于服务器存储
// compareLevel() {
// if (cc.fx.GameConfig.GM_INFO.level < cc.fx.StorageMessage.getStorage("level")) {
// }
// }
};
export { GameTool };

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
}
}