昨日更新

This commit is contained in:
YZ\249929363 2025-07-29 10:43:30 +08:00
parent 60d0add8af
commit ae5627532b
4 changed files with 80 additions and 29 deletions

View File

@ -173,13 +173,13 @@ export default class JiaZai extends cc.Component {
this.updatePower();
cc.fx.GameTool.getHealth(null);
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);
setTimeout(() => {
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);
this.setHealthInfo(true);
}, 0);
});
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);
if (cc.fx.GameConfig.GM_INFO.gameState) {
this.node.getChildByName("zhuanchang").active = true;
setTimeout(() => {
@ -274,7 +274,6 @@ export default class JiaZai extends cc.Component {
}
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.hp, 40, 20, "time_", this.heath, true);
} else {
cc.fx.GameConfig.GM_INFO.min_Time -= 0;
let timeTemp = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
if (timeLabelNode) {
NumberToImage.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time, 50, "time_", timeLabelNode);
@ -305,9 +304,10 @@ export default class JiaZai extends cc.Component {
if (cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
MiniGameSdk.API.showToast("恢复一点体力");
cc.fx.GameTool.setUserHealth(1, (data) => {
cc.fx.GameTool.getHealth(null);
cc.fx.GameTool.getHealth((data) => {
this.setHealthInfo(true);
})
});
}, true)
}
}

View File

@ -649,19 +649,37 @@ export default class MapConroler extends cc.Component {
let turn = 0;
if (type == "wall") opacity = 255;
if (type == "turn") opacity = 250;
if (this.mapBlocksWall[pointA.x][pointA.y].opacity == 249 && this.mapBlocksWall[pointB.x][pointB.y].opacity == 249) {
console.log("缺角", pointA, pointB);
return null;
}
else if (this.mapBlocksWall[pointA.x][pointA.y].opacity == 249 && this.mapBlocksWall[pointC.x][pointC.y].opacity == 249) {
console.log("缺角", pointA, pointC);
return null;
}
else if (this.mapBlocksWall[pointA.x][pointA.y].opacity == 249 && this.mapBlocksWall[pointD.x][pointD.y].opacity == 249) {
console.log("缺角", pointA, pointD);
return null;
}
else if (this.mapBlocksWall[pointA.x][pointA.y].opacity == 249 && this.mapBlocksWall[pointE.x][pointE.y].opacity == 249) {
console.log("缺角", pointA, pointE);
return null;
}
if (pointB.x < this.mapWidth) {
if (this.mapBlocksWall[pointB.x][pointB.y].opacity == opacity) {
if (type == "turn" && this.mapBlocksWall[pointB.x][pointB.y].getComponent("MapBlock").direction == "right") {
}
else dir.push("right");
else {
dir.push("right");
}
}
else if (type == "turn") {
if (this.mapBlocksWall[pointB.x][pointB.y].opacity == 249) {
dir.push("right");
turn += 1;
console.log("从转角处增加", turn);
turn++;
// console.log("right从转角处增加", pointB.x, pointB.y);
}
}
}
@ -670,13 +688,15 @@ export default class MapConroler extends cc.Component {
if (type == "turn" && this.mapBlocksWall[pointC.x][pointC.y].getComponent("MapBlock").direction == "left") {
}
else dir.push("left");
else {
dir.push("left");
}
}
else if (type == "turn") {
if (this.mapBlocksWall[pointC.x][pointC.y].opacity == 249) {
dir.push("left");
turn += 1;
console.log("从转角处增加", turn);
turn++;
// console.log("left从转角处增加", turn);
}
}
}
@ -685,13 +705,15 @@ export default class MapConroler extends cc.Component {
if (type == "turn" && this.mapBlocksWall[pointD.x][pointD.y].getComponent("MapBlock").direction == "up") {
}
else dir.push("up");
else {
dir.push("up");
}
}
else if (type == "turn") {
if (this.mapBlocksWall[pointD.x][pointD.y].opacity == 249) {
dir.push("up");
turn += 1;
console.log("从转角处增加", turn);
turn++;
// console.log("up从转角处增加", turn);
}
}
}
@ -700,17 +722,19 @@ export default class MapConroler extends cc.Component {
if (type == "turn" && this.mapBlocksWall[pointE.x][pointE.y].getComponent("MapBlock").direction == "down") {
}
else dir.push("down");
else {
dir.push("down");
}
}
else if (type == "turn") {
if (this.mapBlocksWall[pointE.x][pointE.y].opacity == 249) {
dir.push("down");
turn += 1;
console.log("从转角处增加", turn);
turn++;
// console.log("down从转角处增加", turn);
}
}
}
if (dir.length > 2 || turn > 1) {
if (dir.length > 2) {
return null;
}
if (dir.length == 1) {
@ -1527,7 +1551,7 @@ export default class MapConroler extends cc.Component {
console.log("恢复一点体力", cc.fx.GameConfig.GM_INFO.level);
if (!this.powerState) {
cc.fx.GameTool.setUserHealth(1, (data) => {
})
}, false)
}
this.powerState = false;
}

View File

@ -553,13 +553,12 @@ var GameTool = {
else {
console.log("有存储过体力值:", health);
cc.fx.GameConfig.GM_INFO.hp = health.health;
if (callback) {
console.log("体力值读取完毕");
callback();
}
console.log("体力值读取完毕", cc.fx.GameConfig.GM_INFO.hp);
if (health.health < 0) {
console.log("体力值异常,归零");
cc.fx.GameConfig.GM_INFO.hp = 0;
cc.fx.GameConfig.GM_INFO.min_Time = 0;
cc.fx.GameTool.setUserHealth(0, () => {
if (callback) callback();
});
@ -572,17 +571,36 @@ var GameTool = {
const recoveredHealth = Math.min(cc.fx.GameConfig.GM_INFO.hp_Max - health.health, Math.floor(elapsedTime / thirtyMinutes));
if (recoveredHealth > 0) {
health.health += recoveredHealth;
// 更新 health.timestamp
health.timestamp += recoveredHealth * thirtyMinutes;
cc.fx.GameTool.setUserHealth(recoveredHealth, () => {
if (callback) callback();
});
}, true);
MiniGameSdk.API.showToast("恢复1点体力值");
console.log(`体力值恢复 ${recoveredHealth} 点,当前体力值: ${cc.fx.GameConfig.GM_INFO.hp}`);
// 如果体力增加后仍未满,更新计时
if (cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
const remainingTime = Math.ceil((thirtyMinutes - ((timestamp - health.timestamp) % thirtyMinutes)) / 1000);
cc.fx.GameConfig.GM_INFO.min_Time = remainingTime;
// 更新本地存储的体力信息
let healthInfo = {
"health": cc.fx.GameConfig.GM_INFO.hp,
"timestamp": health.timestamp
}
cc.fx.StorageMessage.setStorage("health", healthInfo);
}
} else {
// 计算距离下一次恢复的剩余时间
const remainingTime = Math.ceil((thirtyMinutes - (elapsedTime % thirtyMinutes)) / 1000);
console.log(`体力值未满,待恢复,距离下一次恢复还剩 ${remainingTime}`);
cc.fx.GameConfig.GM_INFO.min_Time = remainingTime;
if (callback) callback();
}
}
else {
console.log("体力值已满");
if (callback) callback();
}
}
},
@ -615,10 +633,13 @@ var GameTool = {
},
//设置用户体力值 有可能加,有可能定时器减
setUserHealth(health, callback) {
setUserHealth(health, callback, update) {
if (health > 0) {
if (cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
cc.fx.GameConfig.GM_INFO.hp += health;
if (cc.fx.GameConfig.GM_INFO.hp > cc.fx.GameConfig.GM_INFO.hp_Max) {
cc.fx.GameConfig.GM_INFO.hp = cc.fx.GameConfig.GM_INFO.hp_Max;
}
}
}
else {
@ -642,14 +663,20 @@ var GameTool = {
"timestamp": oldTime
}
}
// 体力为满的health没变化则刷新体力时间为0
else if (cc.fx.GameConfig.GM_INFO.hp == cc.fx.GameConfig.GM_INFO.hp_Max && health == 0) {
healthInfo = {
"health": cc.fx.GameConfig.GM_INFO.hp,
"timestamp": 0
}
}
// 增加体力,且增加后体力未满
else if (health > 0 && cc.fx.GameConfig.GM_INFO.hp != cc.fx.GameConfig.GM_INFO.hp_Max) {
let oldTime = cc.fx.StorageMessage.getStorage("health").timestamp;
if (update) {
oldTime = timestamp;
}
healthInfo = {
"health": cc.fx.GameConfig.GM_INFO.hp,
"timestamp": oldTime

View File

@ -334,7 +334,7 @@ export default class NewClass extends cc.Component {
cc.fx.GameTool.setUserHealth(1, (data) => {
cc.fx.GameTool.getHealth(null);
this.setHealthInfo(true);
})
}, true)
}
else {
if (this.node.parent.getComponent("JiaZai")) {