日常更新

This commit is contained in:
COMPUTER\EDY 2026-01-09 14:35:17 +08:00
parent efb8885190
commit b747bac58b
9 changed files with 171 additions and 153 deletions

View File

@ -230,40 +230,17 @@ export default class Block extends cc.Component {
this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this); this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this);
this.node['_touchListener'].setSwallowTouches(false); this.node['_touchListener'].setSwallowTouches(false);
setTimeout(() => { setTimeout(() => {
if (this.type == BlockType. && this.block_Info.node) {
this.createNianHe(createAd);
}
else {
if (this.type == BlockType.) { if (this.type == BlockType.) {
// 计算位置偏移 setTimeout(() => {
const posOffset = cc.v2( this.createNianHe(createAd);
this.node.x - this.block_Info.node.x, }, 200);
this.node.y - this.block_Info.node.y
);
const targetNames = ['top', 'down', 'left', 'right'];
this.block_Info.node.children.forEach(child => {
if (child instanceof cc.Node && targetNames.includes(child.name) && child.getComponent("lq_collide").data_string != "-1") {
const clonedChild = cc.instantiate(child);
clonedChild.getComponent("lq_collide").data_string = "-1";
clonedChild.parent = this.node;
// 获取子节点相对于父节点的位置
const relativePos = child.getPosition();
// 调整子节点位置以保证相对位置不变
clonedChild.setPosition(
relativePos.x - posOffset.x,
relativePos.y - posOffset.y
);
} }
});
if (createAd) {
this.block_Info.node.getComponent("Block").adhesive = cc.v2(-posOffset.x, -posOffset.y);
if (this.node.zIndex >= this.block_Info.node.zIndex)
this.createAdhesive();
else
this.block_Info.node.getComponent("Block").createAdhesive();
} }
this.adhesive = posOffset; }, 200);
}
else if (this.type == BlockType.) {
}
}, 100);
@ -306,6 +283,36 @@ export default class Block extends cc.Component {
} }
} }
createNianHe(createAd) {
const posOffset = cc.v2(
this.node.x - this.block_Info.node.x,
this.node.y - this.block_Info.node.y
);
const targetNames = ['top', 'down', 'left', 'right'];
this.block_Info.node.children.forEach(child => {
if (child instanceof cc.Node && targetNames.includes(child.name) && child.getComponent("lq_collide").data_string != "-1") {
const clonedChild = cc.instantiate(child);
clonedChild.getComponent("lq_collide").data_string = "-1";
clonedChild.parent = this.node;
// 获取子节点相对于父节点的位置
const relativePos = child.getPosition();
// 调整子节点位置以保证相对位置不变
clonedChild.setPosition(
relativePos.x - posOffset.x,
relativePos.y - posOffset.y
);
}
});
if (createAd) {
this.block_Info.node.getComponent("Block").adhesive = cc.v2(-posOffset.x, -posOffset.y);
if (this.node.zIndex >= this.block_Info.node.zIndex)
this.createAdhesive();
else
this.block_Info.node.getComponent("Block").createAdhesive();
}
this.adhesive = posOffset;
}
//初始化方块类型 //初始化方块类型

View File

@ -588,6 +588,7 @@ export default class JiaZai extends cc.Component {
if (!this.AvatarNode) { if (!this.AvatarNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.AvatarNode = cc.instantiate(JiaZai.cachedAvatarPrefab); this.AvatarNode = cc.instantiate(JiaZai.cachedAvatarPrefab);
if (this.node && this.AvatarNode)
this.node.addChild(this.AvatarNode); this.node.addChild(this.AvatarNode);
this.AvatarNode.getComponent("Avatar").init(); this.AvatarNode.getComponent("Avatar").init();
} else { } else {
@ -602,6 +603,7 @@ export default class JiaZai extends cc.Component {
if (!this.AvatarNode) { if (!this.AvatarNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.AvatarNode = cc.instantiate(JiaZai.cachedAvatarPrefab); this.AvatarNode = cc.instantiate(JiaZai.cachedAvatarPrefab);
if (this.node && this.AvatarNode)
this.node.addChild(this.AvatarNode); this.node.addChild(this.AvatarNode);
this.AvatarNode.getComponent("Avatar").init(); this.AvatarNode.getComponent("Avatar").init();
} else { } else {
@ -661,6 +663,7 @@ export default class JiaZai extends cc.Component {
cc.fx.GameTool.shushu_Track("interface_exposure", dataInfo); cc.fx.GameTool.shushu_Track("interface_exposure", dataInfo);
let health = cc.instantiate(this.health); let health = cc.instantiate(this.health);
if (this.node && health)
this.node.addChild(health); this.node.addChild(health);
let heathPop = health.getComponent("heathnum").heatht; let heathPop = health.getComponent("heathnum").heatht;
this.heath = heathPop; // 保存heath预制体引用 this.heath = heathPop; // 保存heath预制体引用
@ -1031,6 +1034,7 @@ export default class JiaZai extends cc.Component {
if (!this.shopNode) { if (!this.shopNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.shopNode = cc.instantiate(JiaZai.cachedShopPrefab); this.shopNode = cc.instantiate(JiaZai.cachedShopPrefab);
if (this.node && this.shopNode)
this.node.addChild(this.shopNode); this.node.addChild(this.shopNode);
this.shopNode.getComponent("shop").init((res.data.shopDouble)); this.shopNode.getComponent("shop").init((res.data.shopDouble));
} else { } else {
@ -1058,6 +1062,7 @@ export default class JiaZai extends cc.Component {
if (!this.RewardNode) { if (!this.RewardNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.RewardNode = cc.instantiate(JiaZai.cachedRewardPrefab); this.RewardNode = cc.instantiate(JiaZai.cachedRewardPrefab);
if (this.node && this.RewardNode)
this.node.addChild(this.RewardNode); this.node.addChild(this.RewardNode);
this.RewardNode.getComponent("Reward").init(data); this.RewardNode.getComponent("Reward").init(data);
} }
@ -1065,6 +1070,7 @@ export default class JiaZai extends cc.Component {
this.RewardNode.destroy(); this.RewardNode.destroy();
this.RewardNode = null; this.RewardNode = null;
this.RewardNode = cc.instantiate(JiaZai.cachedRewardPrefab); this.RewardNode = cc.instantiate(JiaZai.cachedRewardPrefab);
if (this.node && this.RewardNode)
this.node.addChild(this.RewardNode); this.node.addChild(this.RewardNode);
this.RewardNode.getComponent("Reward").init(data); this.RewardNode.getComponent("Reward").init(data);
} }
@ -1099,6 +1105,7 @@ export default class JiaZai extends cc.Component {
if (!this.monthlyCardNode) { if (!this.monthlyCardNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.monthlyCardNode = cc.instantiate(JiaZai.cachedMonthlyCardPrefab); this.monthlyCardNode = cc.instantiate(JiaZai.cachedMonthlyCardPrefab);
if (this.node && this.monthlyCardNode)
this.node.addChild(this.monthlyCardNode); this.node.addChild(this.monthlyCardNode);
this.monthlyCardNode.active = true; this.monthlyCardNode.active = true;
this.monthlyCardNode.getComponent("monthlyCard").init(); this.monthlyCardNode.getComponent("monthlyCard").init();
@ -1181,6 +1188,7 @@ export default class JiaZai extends cc.Component {
if (!this.dailyQuestsNode) { if (!this.dailyQuestsNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.dailyQuestsNode = cc.instantiate(JiaZai.cachedDailyQuestsPrefab); this.dailyQuestsNode = cc.instantiate(JiaZai.cachedDailyQuestsPrefab);
if (this.node && this.dailyQuestsNode)
this.node.addChild(this.dailyQuestsNode); this.node.addChild(this.dailyQuestsNode);
this.dailyQuestsNode.active = true; this.dailyQuestsNode.active = true;
this.dailyQuestsNode.getComponent("DailyQuests").init(data.data.task); this.dailyQuestsNode.getComponent("DailyQuests").init(data.data.task);
@ -1504,6 +1512,7 @@ export default class JiaZai extends cc.Component {
if (!this.actionpNode) { if (!this.actionpNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.actionpNode = cc.instantiate(JiaZai.cachedActionPrefab); this.actionpNode = cc.instantiate(JiaZai.cachedActionPrefab);
if (this.node && this.actionpNode)
this.node.addChild(this.actionpNode); this.node.addChild(this.actionpNode);
this.actionpNode.zIndex = 2; this.actionpNode.zIndex = 2;
this.actionpNode.getComponent("NewbieGift").init(true); this.actionpNode.getComponent("NewbieGift").init(true);
@ -1522,6 +1531,7 @@ export default class JiaZai extends cc.Component {
if (!this.actionpNode) { if (!this.actionpNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.actionpNode = cc.instantiate(JiaZai.cachedActionPrefab); this.actionpNode = cc.instantiate(JiaZai.cachedActionPrefab);
if (this.node && this.actionpNode)
this.node.addChild(this.actionpNode); this.node.addChild(this.actionpNode);
this.actionpNode.zIndex = 2; this.actionpNode.zIndex = 2;
this.actionpNode.getComponent("NewbieGift").init(true); this.actionpNode.getComponent("NewbieGift").init(true);
@ -2024,6 +2034,7 @@ export default class JiaZai extends cc.Component {
if (!this.winStreakNode) { if (!this.winStreakNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.winStreakNode = cc.instantiate(JiaZai.cachedWinStreakPrefab); this.winStreakNode = cc.instantiate(JiaZai.cachedWinStreakPrefab);
if (this.node && this.winStreakNode)
this.node.addChild(this.winStreakNode); this.node.addChild(this.winStreakNode);
this.winStreakNode.getComponent("WinStreak").init(); this.winStreakNode.getComponent("WinStreak").init();
} else { } else {
@ -2038,6 +2049,7 @@ export default class JiaZai extends cc.Component {
if (!this.winStreakNode) { if (!this.winStreakNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.winStreakNode = cc.instantiate(JiaZai.cachedWinStreakPrefab); this.winStreakNode = cc.instantiate(JiaZai.cachedWinStreakPrefab);
if (this.node && this.winStreakNode)
this.node.addChild(this.winStreakNode); this.node.addChild(this.winStreakNode);
this.winStreakNode.active = true; this.winStreakNode.active = true;
this.winStreakNode.getComponent("WinStreak").init(); this.winStreakNode.getComponent("WinStreak").init();
@ -2179,6 +2191,7 @@ export default class JiaZai extends cc.Component {
if (!this.passCheckNode || !cc.isValid(this.passCheckNode)) { if (!this.passCheckNode || !cc.isValid(this.passCheckNode)) {
// 节点不存在或已被销毁,需要重新创建 // 节点不存在或已被销毁,需要重新创建
this.passCheckNode = cc.instantiate(JiaZai.cachedPassCheckPrefab); this.passCheckNode = cc.instantiate(JiaZai.cachedPassCheckPrefab);
if (this.node && this.passCheckNode)
this.node.addChild(this.passCheckNode); this.node.addChild(this.passCheckNode);
this.passCheckNode.getComponent("passCheck").setInfo(passCheck); this.passCheckNode.getComponent("passCheck").setInfo(passCheck);
const hmScale = cc.fx.GameTool.adaptation(); const hmScale = cc.fx.GameTool.adaptation();
@ -2898,6 +2911,7 @@ export default class JiaZai extends cc.Component {
} }
openRedeemCode() { openRedeemCode() {
let reddemCodeNode = cc.instantiate(this.reddemCodeNode); let reddemCodeNode = cc.instantiate(this.reddemCodeNode);
if (this.node && reddemCodeNode)
this.node.addChild(reddemCodeNode); this.node.addChild(reddemCodeNode);
} }

View File

@ -44,7 +44,7 @@ export default class RippleShrink extends cc.Component {
} }
update(dt: number) { update(dt: number) {
if (!this.shouldShow && !this.running) { if (!this.shouldShow && !this.running && this.node) {
// 如果不需要显示且当前没有运行中的动画,则隐藏节点 // 如果不需要显示且当前没有运行中的动画,则隐藏节点
if (this.node.active) { if (this.node.active) {
this.node.active = false; this.node.active = false;

View File

@ -474,6 +474,7 @@ export default class SceneManager extends cc.Component {
if (!this.shopNode) { if (!this.shopNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.shopNode = cc.instantiate(SceneManager.cachedShopPrefab); this.shopNode = cc.instantiate(SceneManager.cachedShopPrefab);
if (this.node && this.shopNode)
this.node.addChild(this.shopNode); this.node.addChild(this.shopNode);
this.shopNode.getComponent("shop").init(res.data.shopDouble); this.shopNode.getComponent("shop").init(res.data.shopDouble);
} else { } else {
@ -513,6 +514,7 @@ export default class SceneManager extends cc.Component {
if (!this.monthlyCardNode) { if (!this.monthlyCardNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.monthlyCardNode = cc.instantiate(SceneManager.cachedMonthlyCardPrefab); this.monthlyCardNode = cc.instantiate(SceneManager.cachedMonthlyCardPrefab);
if (this.node && this.monthlyCardNode)
this.node.addChild(this.monthlyCardNode); this.node.addChild(this.monthlyCardNode);
this.monthlyCardNode.getComponent("monthlyCard").init(); this.monthlyCardNode.getComponent("monthlyCard").init();
this.monthlyCardNode.getComponent("monthlyCard").juwai = false; this.monthlyCardNode.getComponent("monthlyCard").juwai = false;
@ -562,6 +564,7 @@ export default class SceneManager extends cc.Component {
if (!this.RewardNode) { if (!this.RewardNode) {
// 第一次使用,创建节点 // 第一次使用,创建节点
this.RewardNode = cc.instantiate(SceneManager.cachedRewardPrefab); this.RewardNode = cc.instantiate(SceneManager.cachedRewardPrefab);
if (this.node && this.RewardNode)
this.node.addChild(this.RewardNode); this.node.addChild(this.RewardNode);
this.RewardNode.zIndex = 99; this.RewardNode.zIndex = 99;
this.RewardNode.getComponent("Reward").init(data, callBack); this.RewardNode.getComponent("Reward").init(data, callBack);
@ -570,6 +573,7 @@ export default class SceneManager extends cc.Component {
this.RewardNode.destroy(); this.RewardNode.destroy();
this.RewardNode = null; this.RewardNode = null;
this.RewardNode = cc.instantiate(SceneManager.cachedRewardPrefab); this.RewardNode = cc.instantiate(SceneManager.cachedRewardPrefab);
if (this.node && this.RewardNode)
this.node.addChild(this.RewardNode); this.node.addChild(this.RewardNode);
this.RewardNode.zIndex = 99; this.RewardNode.zIndex = 99;
this.RewardNode.getComponent("Reward").init(data, callBack); this.RewardNode.getComponent("Reward").init(data, callBack);

View File

@ -195,7 +195,7 @@ export class LQCollide extends Component {
private checkDebugDrawValid() { private checkDebugDrawValid() {
if (!this._debugDrawer || !this._debugDrawer.isValid) { if (!this._debugDrawer || !this._debugDrawer.isValid) {
let node = this.node.getChildByName('Collide'); let node = this.node.getChildByName('Collide');
if (!node) { if (!node && this.node) {
node = new Node('Collide'); node = new Node('Collide');
node.zIndex = macro.MAX_ZINDEX; node.zIndex = macro.MAX_ZINDEX;
this.node.addChild(node); this.node.addChild(node);

View File

@ -171,7 +171,7 @@ export default class DailyQuests extends cc.Component {
}, 1000); }, 1000);
} }
//购买月卡 //領取獎勵
openReward(name, res) { openReward(name, res) {
let data = null; let data = null;
if (name == "levelPass") { if (name == "levelPass") {
@ -392,96 +392,96 @@ export default class DailyQuests extends cc.Component {
} }
getAllReward() { getAllReward() {
if (this.touchStart == false) { // if (this.touchStart == false) {
return; // return;
} // }
this.touchStart = false; // this.touchStart = false;
this.reward = true; // this.reward = true;
let shuju = []; // let shuju = [];
for (let i = 0; i < this.content.children.length; i++) { // for (let i = 0; i < this.content.children.length; i++) {
let dataNode = this.content.children[i]; // let dataNode = this.content.children[i];
if (dataNode.getChildByName("get").active == true) { // if (dataNode.getChildByName("get").active == true) {
shuju.push(dataNode.name); // shuju.push(dataNode.name);
} // }
} // }
console.log("准备上传的任务", shuju); // console.log("准备上传的任务", shuju);
Utils.getDailyQuestReward(shuju, (res) => { // Utils.getDailyQuestReward(shuju, (res) => {
this.touchStart = true; // this.touchStart = true;
this.reward = false; // this.reward = false;
if (res.code == 1) { // if (res.code == 1) {
let data = [ // let data = [
{ type: "coin", count: 0 }, // { type: "coin", count: 0 },
{ type: "freeze", count: 0 }, // { type: "freeze", count: 0 },
{ type: "hammer", count: 0 }, // { type: "hammer", count: 0 },
{ type: "magic", count: 0 }, // { type: "magic", count: 0 },
{ type: "infinite_health", count: 0 }, // { type: "infinite_health", count: 0 },
] // ]
for (let i = 0; i < this.content.children.length; i++) { // for (let i = 0; i < this.content.children.length; i++) {
let dataNode = this.content.children[i]; // let dataNode = this.content.children[i];
if (dataNode.getChildByName("get").active == true) { // if (dataNode.getChildByName("get").active == true) {
dataNode.getChildByName("get").active = false; // dataNode.getChildByName("get").active = false;
if (dataNode.name == "levelPass") { // if (dataNode.name == "levelPass") {
data[0].count += 100; // data[0].count += 100;
data[1].count += 2; // data[1].count += 2;
let data2 = { // let data2 = {
id: 0, // id: 0,
status: "claim" // status: "claim"
} // }
cc.fx.GameTool.shushu_Track("daily_task", data2); // cc.fx.GameTool.shushu_Track("daily_task", data2);
} // }
else if (dataNode.name == "useProp") { // else if (dataNode.name == "useProp") {
data[2].count += 1; // data[2].count += 1;
let data2 = { // let data2 = {
id: 3, // id: 3,
status: "claim" // status: "claim"
} // }
cc.fx.GameTool.shushu_Track("daily_task", data2); // cc.fx.GameTool.shushu_Track("daily_task", data2);
} // }
else if (dataNode.name == "useEnergy") { // else if (dataNode.name == "useEnergy") {
data[0].count += 100; // data[0].count += 100;
data[3].count += 1; // data[3].count += 1;
let data2 = { // let data2 = {
id: 2, // id: 2,
status: "claim" // status: "claim"
} // }
cc.fx.GameTool.shushu_Track("daily_task", data2); // cc.fx.GameTool.shushu_Track("daily_task", data2);
} // }
else if (dataNode.name == "share") { // else if (dataNode.name == "share") {
data[4].count += 900; // data[4].count += 900;
let data2 = { // let data2 = {
id: 1, // id: 1,
status: "claim" // status: "claim"
} // }
cc.fx.GameTool.shushu_Track("daily_task", data2); // cc.fx.GameTool.shushu_Track("daily_task", data2);
} // }
cc.tween(dataNode) // cc.tween(dataNode)
.to(0.4, { x: dataNode.x - 1000, opacity: 50 }) // .to(0.4, { x: dataNode.x - 1000, opacity: 50 })
.call(() => { // .call(() => {
this.touchStart = true; // this.touchStart = true;
dataNode.removeFromParent(); // dataNode.removeFromParent();
this.content.getComponent(cc.Layout).updateLayout(); // this.content.getComponent(cc.Layout).updateLayout();
this.checkGetReward(); // this.checkGetReward();
}) // })
.start(); // .start();
} // }
} // }
for (let j = 0; j < data.length; j++) { // for (let j = 0; j < data.length; j++) {
if (data[j].count == 0) { // if (data[j].count == 0) {
data.splice(j, 1); // data.splice(j, 1);
j--; // j--;
} // }
} // }
this.openReward("all", data); // this.openReward("all", data);
} // }
else { // else {
MiniGameSdk.API.showToast("网络异常,领取奖励失败"); // MiniGameSdk.API.showToast("网络异常,领取奖励失败");
} // }
}) // })
setTimeout(() => { // setTimeout(() => {
if (this.reward == true && this.touchStart == false) { // if (this.reward == true && this.touchStart == false) {
this.touchStart = true; // this.touchStart = true;
} // }
}, 5000); // }, 5000);
} }
checkGetReward() { checkGetReward() {
@ -505,7 +505,7 @@ export default class DailyQuests extends cc.Component {
//@ts-ignore //@ts-ignore
if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) { if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) {
const num = 0; const num = 0;
//console.log("_________道具增加的数量为:", num); console.log("_________道具增加的数量为:", num);
cc.fx.GameConfig.GM_INFO.freezeAmount += propData.freeze; cc.fx.GameConfig.GM_INFO.freezeAmount += propData.freeze;
cc.fx.GameConfig.GM_INFO.hammerAmount += propData.hammer; cc.fx.GameConfig.GM_INFO.hammerAmount += propData.hammer;
cc.fx.GameConfig.GM_INFO.magicAmount += propData.magic_wand; cc.fx.GameConfig.GM_INFO.magicAmount += propData.magic_wand;
@ -539,7 +539,4 @@ export default class DailyQuests extends cc.Component {
} }
update() {
}
} }

View File

@ -535,7 +535,5 @@ export default class NewbieGift extends cc.Component {
} }
update() {
} }
}

View File

@ -155,7 +155,5 @@ export default class WinStreak extends cc.Component {
} }
} }
update() {
} }
}

View File

@ -709,7 +709,7 @@ export default class passCheck extends cc.Component {
butActivate.getComponent("buyActivate").init(() => { butActivate.getComponent("buyActivate").init(() => {
this.onBuyActivate(); this.onBuyActivate();
}, timeStr); }, timeStr);
if (this.node && butActivate)
this.node.addChild(butActivate); this.node.addChild(butActivate);
} }
} }