更新BUG

This commit is contained in:
YZ\249929363 2025-08-07 20:18:24 +08:00
parent 7fa2297b81
commit d5ab6e2611
11 changed files with 127 additions and 101 deletions

View File

@ -2170,7 +2170,7 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 160.12,
"width": 0,
"height": 50.4
},
"_anchorPoint": {

View File

@ -1593,7 +1593,7 @@ export default class Block extends cc.Component {
effectNode.zIndex = 9999;
// 添加到 Canvas 节点下
canvas.addChild(effectNode);
MapConroler._instance.node.parent.addChild(effectNode);
this.playMagicAnimation(skeletonComponent, index);

View File

@ -191,7 +191,9 @@ export default class JiaZai extends cc.Component {
this.onHideListener = () => {
this.onGameHide();
};
//@ts-ignore
wx.onShow(this.onShowListener);
//@ts-ignore
wx.onHide(this.onHideListener);
}
@ -205,7 +207,7 @@ export default class JiaZai extends cc.Component {
}
onGameShow() {
console.log("执行开始游戏gameshow")
cc.fx.GameTool.getHealth((data) => {
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
@ -260,6 +262,7 @@ export default class JiaZai extends cc.Component {
// //打开heath弹窗
// this.openHeath();
this.uploadToCloud(cc.fx.GameConfig.GM_INFO.level + 1);
console.log("________________1");
this.getMonthlyCardValidityDays();
this.rewarded();
console.log('月卡剩余天数 (零点刷新):', cc.fx.GameConfig.GM_INFO.monthTime);
@ -468,7 +471,26 @@ export default class JiaZai extends cc.Component {
setHealthInfo(type) {
if (cc.fx.GameConfig.GM_INFO.hp >= cc.fx.GameConfig.GM_INFO.hp_Max) {
this.Stamina.getChildByName("man").active = true;
if (cc.fx.GameConfig.GM_INFO.userPowerTime != 0) {
let nowTime = Math.floor(Date.now() / 1000);
if (cc.fx.GameConfig.GM_INFO.userPowerTime > nowTime) {
this.stopPowerTime();
this.startPowerTime();
console.log("还有无限体力时间_____________", (cc.fx.GameConfig.GM_INFO.userPowerTime - nowTime));
this.Stamina.getChildByName("skyLine").active = true;
this.Stamina.getChildByName("time").opacity = 0;
this.Stamina.getChildByName("man").active = false;
}
else {
this.Stamina.getChildByName("skyLine").active = false;
console.log("无限体力时间已过期");
this.Stamina.getChildByName("man").active = true;
}
}
else {
this.Stamina.getChildByName("man").active = true;
}
this.Stamina.getChildByName("health").active = true;
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.hp, 25, 15, "hp_", this.Stamina.getChildByName("health"), false);
this.Stamina.getChildByName("time").active = false;
@ -503,8 +525,11 @@ export default class JiaZai extends cc.Component {
return;
}
if (typeof wx !== 'undefined') {
console.log("执行开始游戏start")
//@ts-ignore
wx.offShow(this.onShowListener);
//@ts-ignore
wx.offHide(this.onHideListener);
}
@ -568,11 +593,12 @@ export default class JiaZai extends cc.Component {
this.shopNode.getComponent("shop").init();
}
if (typeof wx !== 'undefined') {
console.log("执行开始游戏shop")
//@ts-ignore
wx.offShow(this.onShowListener);
//@ts-ignore
wx.offHide(this.onHideListener);
}
// //console.log("shopNode parent:", this.shopNode.parent);
}
openRewardWindow(data, month?: number) {
@ -616,8 +642,10 @@ export default class JiaZai extends cc.Component {
this.monthlyCardNode.getComponent("monthlyCard").juwai = true;
}
if (typeof wx !== 'undefined') {
console.log("执行开始游戏monthlyCard")
//@ts-ignore
wx.offShow(this.onShowListener);
//@ts-ignore
wx.offHide(this.onHideListener);
}
}
@ -968,22 +996,29 @@ export default class JiaZai extends cc.Component {
//获取月卡有效期距离今天的天数
getMonthlyCardValidityDays(): Promise<number> {
console.log("________________2");
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 {
console.log("月卡返回时间:", data);
if (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) 根据需要
}
}
else {
resolve(0); // 或 reject(data) 根据需要
}
});

View File

@ -109,10 +109,14 @@ export default class NewClass extends cc.Component {
};
});
let img = "https://mmocgame.qpic.cn/wechatgame/OiaWk33I6QjgWiatrb5YVUq2p0QRmQgO6rLUWxEQDZ4ib9Ny4Pr8iaHnHI6WdxibY2nPL/0";
if (Math.random() < 0.5) {
img = "https://mmocgame.qpic.cn/wechatgame/CG5xBibollws251aYD4msEPWCiafrcn4Fgtic4T2wME6sWmdfAUtfibgsWoxm59VadDD/0";
}
wx.showShareMenu(() => {
return {
title: '你想玩上怎样的游戏?',
imageUrl: '',
imageUrl: img,
query: ''
};
});

View File

@ -49,13 +49,13 @@ export default class NumberToImage extends cc.Component {
for (let i = 0; i < digitNodes.length; i++) {
const node = digitNodes[i];
node.x = startX + i * width;
node.parent = targetNode;
if (targetNode) node.parent = targetNode;
}
} else {
for (let i = 0; i < digitNodes.length; i++) {
const node = digitNodes[i];
node.x = i * width + cha;
node.parent = targetNode;
if (targetNode) node.parent = targetNode;
}
}
}
@ -100,7 +100,7 @@ export default class NumberToImage extends cc.Component {
// 将节点添加到目标节点下
node.x = i * width;
if (i > 1) node.x += 35;
node.parent = targetNode;
if (targetNode) node.parent = targetNode;
}
}
@ -166,7 +166,7 @@ export default class NumberToImage extends cc.Component {
node.x = startX + i * width;
if (i > 1) node.x += 20;
if (i > 3) node.x += 20;
node.parent = targetNode;
if (targetNode) node.parent = targetNode;
}
} else {
for (let i = 0; i < digitNodes.length; i++) {
@ -174,7 +174,7 @@ export default class NumberToImage extends cc.Component {
node.x = i * width;
if (i > 1) node.x += 20;
if (i > 3) node.x += 20;
node.parent = targetNode;
if (targetNode) node.parent = targetNode;
}
}
}

View File

@ -181,6 +181,7 @@ export default class Revive extends cc.Component {
let shopComp = shop.getComponent("shop");
if (shopComp) {
shopComp.openShop();
shopComp.init();
}
}
cc.fx.GameConfig.GM_INFO.revive = 1;
@ -392,6 +393,7 @@ export default class Revive extends cc.Component {
// 移除 wx.onShow 监听器
if (cc.sys.platform === cc.sys.WECHAT_GAME && this.onShowListener) {
console.log("复活移除监听");
//@ts-ignore
wx.offShow(this.onShowListener);
console.log("🔥🔥🔥🔥🔥🔥🔥🔥")

View File

@ -105,7 +105,7 @@ export default class Reward extends cc.Component {
const createNodeWithDelay = (row: number, col: number) => {
setTimeout(() => {
const rewardNode = cc.instantiate(this.rewardNode);
rewardNode.parent = this.node;
if (this.node) rewardNode.parent = this.node;
// 计算当前行的总宽度
// let startX = 0;
// if (row === 0) {

View File

@ -77,6 +77,7 @@ export default class NewClass extends cc.Component {
}
cc.fx.GameTool.shushu_Track("resource_cost", data);
cc.fx.GameConfig.GM_INFO.hp = cc.fx.GameConfig.GM_INFO.hp_Max;
cc.fx.GameConfig.GM_INFO.min_Time = 0;
const parentNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
if (parentNode) {
const jiazaiComp = parentNode.getComponent(JiaZai);

View File

@ -147,12 +147,12 @@ export default class Utils {
Utils.POST("wx/getOrderReward", { outTradeNo: orderTemp }, res => {
//console.log("告知服务器发货:", res);
if (res.code === 1) {
//console.log("告知服务器发货成功:", res);
console.log("告知服务器发货成功:", res);
// 请求成功,调用回调并返回结果
callBack(res);
} else {
// 请求失败,增加重试次数并设置下一次请求的延迟
//console.log("告知服务器发货失败:", res);
console.log("告知服务器发货失败:", res);
attempt++;
if (attempt <= delays.length) {
setTimeout(sendRequest, delays[attempt - 1]);

View File

@ -176,7 +176,7 @@ export default class NewClass extends cc.Component {
//购买月卡
buyMonthCard(id) {
Utils.setMonthlyCard(0, (data) => {
console.log("购买月卡'✅ ", data.code);
console.log("购买月卡", data.code);
if (data.code == 1) {
// let rewardData = [
// { type: "coin", count: 6000 },
@ -188,11 +188,13 @@ export default class NewClass extends cc.Component {
// cc.fx.GameTool.changeCoin(6000);
const jiazaiNode = cc.find("Canvas"); // 假设 JiaZai 挂在 Canvas 节点
const jiazaiComp = jiazaiNode.getComponent(JiaZai);
jiazaiComp.getMonthlyCardValidityDays().then(days => {
cc.fx.GameConfig.GM_INFO.monthTime = days;
NumberToImage.numberToImageNodes(days, 35, 20, "month_", this.monthCardTime, true);
});
if (jiazaiComp) {
console.log("获取到JiaZai组件", jiazaiComp);
jiazaiComp.getMonthlyCardValidityDays().then(days => {
cc.fx.GameConfig.GM_INFO.monthTime = days;
NumberToImage.numberToImageNodes(days, 35, 20, "month_", this.monthCardTime, true);
});
setTimeout(() => {
jiazaiComp.setHealthInfo(false);
jiazaiComp.startTimeCutDown();
@ -207,46 +209,6 @@ export default class NewClass extends cc.Component {
this.monthCardBtn2.active = true;
this.monthCardTime.active = true;
cc.fx.GameConfig.GM_INFO.doubleCoin = 2;
// if (this.juwai == true) {
// if (jiazaiComp) {
// setTimeout(() => {
// jiazaiComp.openRewardWindow(rewardData, 1);
// }, 300);
// }
// console.log("月卡奖励juwai");
// } else {
// // 尝试获取SceneManager组件
// const jiazaiComp1 = jiazaiNode.getComponent(SceneManager);
// if (jiazaiComp1) {
// setTimeout(() => {
// jiazaiComp1.updateCoin();
// // 确保openRewardWindow方法存在
// if (typeof jiazaiComp1.openRewardWindow === 'function') {
// jiazaiComp1.openRewardWindow(rewardData);
// } else {
// console.error("SceneManager组件中没有openRewardWindow方法");
// // 尝试使用JiaZai组件的openRewardWindow方法作为备选
// const jiazaiComp2 = jiazaiNode.getComponent(JiaZai);
// if (jiazaiComp2 && typeof jiazaiComp2.openRewardWindow === 'function') {
// jiazaiComp2.openRewardWindow(rewardData);
// }
// }
// }, 300);
// console.log("月卡奖励junei");
// } else {
// console.log("无法获取SceneManager组件尝试获取JiaZai组件");
// // 尝试获取JiaZai组件作为备选
// const jiazaiComp2 = jiazaiNode.getComponent(JiaZai);
// if (jiazaiComp2) {
// setTimeout(() => {
// jiazaiComp2.updateCoin();
// jiazaiComp2.openRewardWindow(rewardData);
// }, 300);
// } else {
// console.error("无法获取JiaZai组件和SceneManager组件");
// }
// }
// }
cc.fx.GameTool.setUserHealth(0, (data) => {
cc.fx.GameTool.getHealth(null);
})
@ -270,6 +232,7 @@ export default class NewClass extends cc.Component {
let shopComp = shop.getComponent("shop");
if (shopComp) {
shopComp.openShop();
shopComp.init();
}
}

View File

@ -58,19 +58,21 @@ export default class NewClass extends cc.Component {
start() {
this.btn_Touch = true;
this.openShop();
this.init();
}
init() {
let flag = cc.fx.GameTool.getSetScreenResolutionFlag();
if (flag) {
this.node.getChildByName("itemcontent").getChildByName("view").height = 1500;
console.log("shop设置分辨率");
if (this.node.getChildByName("itemcontent"))
this.node.getChildByName("itemcontent").getChildByName("view").height = 1500;
}
this.onShowListener = null;
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
// 定义监听函数
console.log("shop添加监听");
this.onShowListener = () => {
console.log("回到前台");
console.log("回到前台,shop");
this.onShow();
};
//@ts-ignore
@ -163,7 +165,7 @@ export default class NewClass extends cc.Component {
closeShop(data, currentCoin) {
// 移除 wx.onShow 监听器
if (cc.sys.platform === cc.sys.WECHAT_GAME && this.onShowListener) {
console.log("!!!!!!!!!!移除onshow");
console.log("shop移除onshow");
console.log(currentCoin);
//@ts-ignore
wx.offShow(this.onShowListener);
@ -194,10 +196,6 @@ export default class NewClass extends cc.Component {
onShow() {
console.log("从后台进入前台 onShow");
//如果月卡打开就return
if (this.monthCard) {
return;
}
const systemInfo = wx.getSystemInfoSync();
if (systemInfo.platform === 'ios') {
if (cc.sys.platform === cc.sys.WECHAT_GAME) {
@ -227,10 +225,7 @@ export default class NewClass extends cc.Component {
}
cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + iosID;
let version = cc.fx.GameTool.getWechatGameVersion();
if (version == "正式版") {
MiniGameSdk.API.yinli_Pay(iosAmount, iosOutTradeNo, name)
}
MiniGameSdk.API.yinli_Pay(iosAmount, iosOutTradeNo, name)
Utils.setPayInfo(
(res) => {
@ -329,19 +324,42 @@ export default class NewClass extends cc.Component {
this.Stamina.getChildByName("time").active = false;
}
else {
const winCOIN = cc.find("Canvas"); // 假设 Canvas 节点
if (winCOIN) {
const wincoin = winCOIN.getComponent(SceneManager);
if (wincoin) {
MapConroler._instance.setPropNum();
console.log("局内");
cc.fx.GameTool.getHealth((data) => {
this.Stamina.getChildByName("time").active = true;
if (cc.fx.GameConfig.GM_INFO.min_Time != 0) {
let time = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
this.Stamina.getChildByName("time").getComponent(cc.Label).string = time;
let power = cc.fx.GameTool.getUserPowerTime();
if (!power) this.Stamina.getChildByName("time").opacity = 255;
else this.Stamina.getChildByName("time").opacity = 0;
this.stopTimeCutDown();
this.startTimeCutDown();
}
});
} else {
this.Stamina.getChildByName("time").active = true;
if (cc.fx.GameConfig.GM_INFO.min_Time != 0) {
let time = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
this.Stamina.getChildByName("time").getComponent(cc.Label).string = time;
let power = cc.fx.GameTool.getUserPowerTime();
if (!power) this.Stamina.getChildByName("time").opacity = 255;
else this.Stamina.getChildByName("time").opacity = 0;
this.stopTimeCutDown();
this.startTimeCutDown();
}
}
}
this.Stamina.getChildByName("man").active = false;
this.Stamina.getChildByName("health").active = true;
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.hp, 25, 15, "hp_", this.Stamina.getChildByName("health"), false);
this.Stamina.getChildByName("time").active = true;
if (cc.fx.GameConfig.GM_INFO.min_Time != 0) {
let time = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
this.Stamina.getChildByName("time").getComponent(cc.Label).string = time;
let power = cc.fx.GameTool.getUserPowerTime();
if (!power) this.Stamina.getChildByName("time").opacity = 255;
else this.Stamina.getChildByName("time").opacity = 0;
this.stopTimeCutDown();
this.startTimeCutDown();
}
}
}
@ -551,17 +569,16 @@ export default class NewClass extends cc.Component {
}
cc.fx.GameTool.shushu_Track("payment", dataSuccess);
let name = "购买金币道具:" + productId;
let version = cc.fx.GameTool.getWechatGameVersion();
if (version == "正式版") {
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name);
}
MiniGameSdk.API.yinli_Pay(price, Utils.outTradeNo, name);
console.log("7.14_______________充值成功,轮训成功,准备发货");
Utils.setPayInfo(
(res) => {
console.log("设置轮训结果:", res);
if (res.code === 1) {
console.log("7.14_________正式发货");
console.log("7.14_________正式发货", Utils.outTradeNo);
MiniGameSdk.API.showToast("充值成功");
cc.fx.GameTool.shopBuy(productId, false);
if (productId == "unlimited_health_bundle_10" ||
@ -698,7 +715,11 @@ export default class NewClass extends cc.Component {
}
}
openmonthCard() {
if (cc.sys.platform === cc.sys.WECHAT_GAME && this.onShowListener) {
console.log("shop移除onshow11111");
//@ts-ignore
wx.offShow(this.onShowListener);
}
const winCOIN = cc.find("Canvas"); // 假设 Canvas 节点
if (winCOIN) {
const wincoin = winCOIN.getComponent(SceneManager);