昨日更新
This commit is contained in:
parent
60d0add8af
commit
ae5627532b
|
@ -173,13 +173,13 @@ export default class JiaZai extends cc.Component {
|
||||||
this.updatePower();
|
this.updatePower();
|
||||||
|
|
||||||
|
|
||||||
cc.fx.GameTool.getHealth(null);
|
cc.fx.GameTool.getHealth((data) => {
|
||||||
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);
|
|
||||||
setTimeout(() => {
|
|
||||||
NumberToImage.numberToImageNodes((cc.fx.GameConfig.GM_INFO.level + 1), 43, 15, "level_", this.level, true);
|
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);
|
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.coin, 30, 15, "coin_", this.coin, true);
|
||||||
this.setHealthInfo(true);
|
this.setHealthInfo(true);
|
||||||
}, 0);
|
});
|
||||||
|
// cc.fx.GameConfig.LEVEL_INFO_init(false,0);
|
||||||
|
|
||||||
if (cc.fx.GameConfig.GM_INFO.gameState) {
|
if (cc.fx.GameConfig.GM_INFO.gameState) {
|
||||||
this.node.getChildByName("zhuanchang").active = true;
|
this.node.getChildByName("zhuanchang").active = true;
|
||||||
setTimeout(() => {
|
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);
|
NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.hp, 40, 20, "time_", this.heath, true);
|
||||||
} else {
|
} else {
|
||||||
cc.fx.GameConfig.GM_INFO.min_Time -= 0;
|
|
||||||
let timeTemp = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
|
let timeTemp = cc.fx.GameTool.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time);
|
||||||
if (timeLabelNode) {
|
if (timeLabelNode) {
|
||||||
NumberToImage.getTimeMargin(cc.fx.GameConfig.GM_INFO.min_Time, 50, "time_", 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) {
|
if (cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
|
||||||
MiniGameSdk.API.showToast("恢复一点体力");
|
MiniGameSdk.API.showToast("恢复一点体力");
|
||||||
cc.fx.GameTool.setUserHealth(1, (data) => {
|
cc.fx.GameTool.setUserHealth(1, (data) => {
|
||||||
cc.fx.GameTool.getHealth(null);
|
cc.fx.GameTool.getHealth((data) => {
|
||||||
this.setHealthInfo(true);
|
this.setHealthInfo(true);
|
||||||
})
|
});
|
||||||
|
}, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -649,19 +649,37 @@ export default class MapConroler extends cc.Component {
|
||||||
let turn = 0;
|
let turn = 0;
|
||||||
if (type == "wall") opacity = 255;
|
if (type == "wall") opacity = 255;
|
||||||
if (type == "turn") opacity = 250;
|
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 (pointB.x < this.mapWidth) {
|
||||||
if (this.mapBlocksWall[pointB.x][pointB.y].opacity == opacity) {
|
if (this.mapBlocksWall[pointB.x][pointB.y].opacity == opacity) {
|
||||||
if (type == "turn" && this.mapBlocksWall[pointB.x][pointB.y].getComponent("MapBlock").direction == "right") {
|
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") {
|
else if (type == "turn") {
|
||||||
if (this.mapBlocksWall[pointB.x][pointB.y].opacity == 249) {
|
if (this.mapBlocksWall[pointB.x][pointB.y].opacity == 249) {
|
||||||
dir.push("right");
|
dir.push("right");
|
||||||
turn += 1;
|
turn++;
|
||||||
console.log("从转角处增加", 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") {
|
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") {
|
else if (type == "turn") {
|
||||||
if (this.mapBlocksWall[pointC.x][pointC.y].opacity == 249) {
|
if (this.mapBlocksWall[pointC.x][pointC.y].opacity == 249) {
|
||||||
dir.push("left");
|
dir.push("left");
|
||||||
turn += 1;
|
turn++;
|
||||||
console.log("从转角处增加", 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") {
|
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") {
|
else if (type == "turn") {
|
||||||
if (this.mapBlocksWall[pointD.x][pointD.y].opacity == 249) {
|
if (this.mapBlocksWall[pointD.x][pointD.y].opacity == 249) {
|
||||||
dir.push("up");
|
dir.push("up");
|
||||||
turn += 1;
|
turn++;
|
||||||
console.log("从转角处增加", 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") {
|
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") {
|
else if (type == "turn") {
|
||||||
if (this.mapBlocksWall[pointE.x][pointE.y].opacity == 249) {
|
if (this.mapBlocksWall[pointE.x][pointE.y].opacity == 249) {
|
||||||
dir.push("down");
|
dir.push("down");
|
||||||
turn += 1;
|
turn++;
|
||||||
console.log("从转角处增加", turn);
|
// console.log("down从转角处增加", turn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dir.length > 2 || turn > 1) {
|
if (dir.length > 2) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (dir.length == 1) {
|
if (dir.length == 1) {
|
||||||
|
@ -1527,7 +1551,7 @@ export default class MapConroler extends cc.Component {
|
||||||
console.log("恢复一点体力", cc.fx.GameConfig.GM_INFO.level);
|
console.log("恢复一点体力", cc.fx.GameConfig.GM_INFO.level);
|
||||||
if (!this.powerState) {
|
if (!this.powerState) {
|
||||||
cc.fx.GameTool.setUserHealth(1, (data) => {
|
cc.fx.GameTool.setUserHealth(1, (data) => {
|
||||||
})
|
}, false)
|
||||||
}
|
}
|
||||||
this.powerState = false;
|
this.powerState = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -553,13 +553,12 @@ var GameTool = {
|
||||||
else {
|
else {
|
||||||
console.log("有存储过体力值:", health);
|
console.log("有存储过体力值:", health);
|
||||||
cc.fx.GameConfig.GM_INFO.hp = health.health;
|
cc.fx.GameConfig.GM_INFO.hp = health.health;
|
||||||
if (callback) {
|
console.log("体力值读取完毕", cc.fx.GameConfig.GM_INFO.hp);
|
||||||
console.log("体力值读取完毕");
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
if (health.health < 0) {
|
if (health.health < 0) {
|
||||||
console.log("体力值异常,归零");
|
console.log("体力值异常,归零");
|
||||||
cc.fx.GameConfig.GM_INFO.hp = 0;
|
cc.fx.GameConfig.GM_INFO.hp = 0;
|
||||||
|
cc.fx.GameConfig.GM_INFO.min_Time = 0;
|
||||||
cc.fx.GameTool.setUserHealth(0, () => {
|
cc.fx.GameTool.setUserHealth(0, () => {
|
||||||
if (callback) callback();
|
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));
|
const recoveredHealth = Math.min(cc.fx.GameConfig.GM_INFO.hp_Max - health.health, Math.floor(elapsedTime / thirtyMinutes));
|
||||||
if (recoveredHealth > 0) {
|
if (recoveredHealth > 0) {
|
||||||
health.health += recoveredHealth;
|
health.health += recoveredHealth;
|
||||||
|
// 更新 health.timestamp
|
||||||
|
health.timestamp += recoveredHealth * thirtyMinutes;
|
||||||
cc.fx.GameTool.setUserHealth(recoveredHealth, () => {
|
cc.fx.GameTool.setUserHealth(recoveredHealth, () => {
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
}, true);
|
||||||
|
MiniGameSdk.API.showToast("恢复1点体力值");
|
||||||
console.log(`体力值恢复 ${recoveredHealth} 点,当前体力值: ${cc.fx.GameConfig.GM_INFO.hp}`);
|
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 {
|
} else {
|
||||||
// 计算距离下一次恢复的剩余时间
|
// 计算距离下一次恢复的剩余时间
|
||||||
const remainingTime = Math.ceil((thirtyMinutes - (elapsedTime % thirtyMinutes)) / 1000);
|
const remainingTime = Math.ceil((thirtyMinutes - (elapsedTime % thirtyMinutes)) / 1000);
|
||||||
console.log(`体力值未满,待恢复,距离下一次恢复还剩 ${remainingTime} 秒`);
|
console.log(`体力值未满,待恢复,距离下一次恢复还剩 ${remainingTime} 秒`);
|
||||||
cc.fx.GameConfig.GM_INFO.min_Time = 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 (health > 0) {
|
||||||
if (cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
|
if (cc.fx.GameConfig.GM_INFO.hp < cc.fx.GameConfig.GM_INFO.hp_Max) {
|
||||||
cc.fx.GameConfig.GM_INFO.hp += health;
|
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 {
|
else {
|
||||||
|
@ -642,14 +663,20 @@ var GameTool = {
|
||||||
"timestamp": oldTime
|
"timestamp": oldTime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 体力为满的,health没变化,则刷新体力时间为0
|
||||||
else if (cc.fx.GameConfig.GM_INFO.hp == cc.fx.GameConfig.GM_INFO.hp_Max && health == 0) {
|
else if (cc.fx.GameConfig.GM_INFO.hp == cc.fx.GameConfig.GM_INFO.hp_Max && health == 0) {
|
||||||
healthInfo = {
|
healthInfo = {
|
||||||
"health": cc.fx.GameConfig.GM_INFO.hp,
|
"health": cc.fx.GameConfig.GM_INFO.hp,
|
||||||
"timestamp": 0
|
"timestamp": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 增加体力,且增加后体力未满
|
||||||
else if (health > 0 && cc.fx.GameConfig.GM_INFO.hp != cc.fx.GameConfig.GM_INFO.hp_Max) {
|
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;
|
let oldTime = cc.fx.StorageMessage.getStorage("health").timestamp;
|
||||||
|
if (update) {
|
||||||
|
oldTime = timestamp;
|
||||||
|
}
|
||||||
healthInfo = {
|
healthInfo = {
|
||||||
"health": cc.fx.GameConfig.GM_INFO.hp,
|
"health": cc.fx.GameConfig.GM_INFO.hp,
|
||||||
"timestamp": oldTime
|
"timestamp": oldTime
|
||||||
|
|
|
@ -334,7 +334,7 @@ export default class NewClass extends cc.Component {
|
||||||
cc.fx.GameTool.setUserHealth(1, (data) => {
|
cc.fx.GameTool.setUserHealth(1, (data) => {
|
||||||
cc.fx.GameTool.getHealth(null);
|
cc.fx.GameTool.getHealth(null);
|
||||||
this.setHealthInfo(true);
|
this.setHealthInfo(true);
|
||||||
})
|
}, true)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.node.parent.getComponent("JiaZai")) {
|
if (this.node.parent.getComponent("JiaZai")) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user