diff --git a/assets/Script/Block.ts b/assets/Script/Block.ts index 1c67d5a..709055a 100644 --- a/assets/Script/Block.ts +++ b/assets/Script/Block.ts @@ -230,40 +230,17 @@ export default class Block extends cc.Component { this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this); this.node['_touchListener'].setSwallowTouches(false); setTimeout(() => { - if (this.type == BlockType.粘合块) { - // 计算位置偏移 - 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(); + if (this.type == BlockType.粘合块 && this.block_Info.node) { + this.createNianHe(createAd); + } + else { + if (this.type == BlockType.粘合块) { + setTimeout(() => { + this.createNianHe(createAd); + }, 200); } - this.adhesive = posOffset; } - else if (this.type == BlockType.三连粘合块) { - - } - }, 100); + }, 200); @@ -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; + } + //初始化方块类型 diff --git a/assets/Script/JiaZai.ts b/assets/Script/JiaZai.ts index 4dd6d13..74a328c 100644 --- a/assets/Script/JiaZai.ts +++ b/assets/Script/JiaZai.ts @@ -588,7 +588,8 @@ export default class JiaZai extends cc.Component { if (!this.AvatarNode) { // 第一次使用,创建节点 this.AvatarNode = cc.instantiate(JiaZai.cachedAvatarPrefab); - this.node.addChild(this.AvatarNode); + if (this.node && this.AvatarNode) + this.node.addChild(this.AvatarNode); this.AvatarNode.getComponent("Avatar").init(); } else { // 非第一次使用,直接激活节点 @@ -602,7 +603,8 @@ export default class JiaZai extends cc.Component { if (!this.AvatarNode) { // 第一次使用,创建节点 this.AvatarNode = cc.instantiate(JiaZai.cachedAvatarPrefab); - this.node.addChild(this.AvatarNode); + if (this.node && this.AvatarNode) + this.node.addChild(this.AvatarNode); this.AvatarNode.getComponent("Avatar").init(); } else { // 非第一次使用,直接激活节点 @@ -661,7 +663,8 @@ export default class JiaZai extends cc.Component { cc.fx.GameTool.shushu_Track("interface_exposure", dataInfo); let health = cc.instantiate(this.health); - this.node.addChild(health); + if (this.node && health) + this.node.addChild(health); let heathPop = health.getComponent("heathnum").heatht; this.heath = heathPop; // 保存heath预制体引用 let swichs = health.getComponent("heathnum").switchNode; @@ -1031,7 +1034,8 @@ export default class JiaZai extends cc.Component { if (!this.shopNode) { // 第一次使用,创建节点 this.shopNode = cc.instantiate(JiaZai.cachedShopPrefab); - this.node.addChild(this.shopNode); + if (this.node && this.shopNode) + this.node.addChild(this.shopNode); this.shopNode.getComponent("shop").init((res.data.shopDouble)); } else { // 非第一次使用,直接激活节点 @@ -1058,14 +1062,16 @@ export default class JiaZai extends cc.Component { if (!this.RewardNode) { // 第一次使用,创建节点 this.RewardNode = cc.instantiate(JiaZai.cachedRewardPrefab); - this.node.addChild(this.RewardNode); + if (this.node && this.RewardNode) + this.node.addChild(this.RewardNode); this.RewardNode.getComponent("Reward").init(data); } else { this.RewardNode.destroy(); this.RewardNode = null; this.RewardNode = cc.instantiate(JiaZai.cachedRewardPrefab); - this.node.addChild(this.RewardNode); + if (this.node && this.RewardNode) + this.node.addChild(this.RewardNode); this.RewardNode.getComponent("Reward").init(data); } this.RewardNode.zIndex = 1001; @@ -1099,7 +1105,8 @@ export default class JiaZai extends cc.Component { if (!this.monthlyCardNode) { // 第一次使用,创建节点 this.monthlyCardNode = cc.instantiate(JiaZai.cachedMonthlyCardPrefab); - this.node.addChild(this.monthlyCardNode); + if (this.node && this.monthlyCardNode) + this.node.addChild(this.monthlyCardNode); this.monthlyCardNode.active = true; this.monthlyCardNode.getComponent("monthlyCard").init(); this.monthlyCardNode.getComponent("monthlyCard").juwai = true; @@ -1181,7 +1188,8 @@ export default class JiaZai extends cc.Component { if (!this.dailyQuestsNode) { // 第一次使用,创建节点 this.dailyQuestsNode = cc.instantiate(JiaZai.cachedDailyQuestsPrefab); - this.node.addChild(this.dailyQuestsNode); + if (this.node && this.dailyQuestsNode) + this.node.addChild(this.dailyQuestsNode); this.dailyQuestsNode.active = true; this.dailyQuestsNode.getComponent("DailyQuests").init(data.data.task); } else { @@ -1504,7 +1512,8 @@ export default class JiaZai extends cc.Component { if (!this.actionpNode) { // 第一次使用,创建节点 this.actionpNode = cc.instantiate(JiaZai.cachedActionPrefab); - this.node.addChild(this.actionpNode); + if (this.node && this.actionpNode) + this.node.addChild(this.actionpNode); this.actionpNode.zIndex = 2; this.actionpNode.getComponent("NewbieGift").init(true); this.actionpNode.getChildByName("time").active = false; @@ -1522,7 +1531,8 @@ export default class JiaZai extends cc.Component { if (!this.actionpNode) { // 第一次使用,创建节点 this.actionpNode = cc.instantiate(JiaZai.cachedActionPrefab); - this.node.addChild(this.actionpNode); + if (this.node && this.actionpNode) + this.node.addChild(this.actionpNode); this.actionpNode.zIndex = 2; this.actionpNode.getComponent("NewbieGift").init(true); } else { @@ -2024,7 +2034,8 @@ export default class JiaZai extends cc.Component { if (!this.winStreakNode) { // 第一次使用,创建节点 this.winStreakNode = cc.instantiate(JiaZai.cachedWinStreakPrefab); - this.node.addChild(this.winStreakNode); + if (this.node && this.winStreakNode) + this.node.addChild(this.winStreakNode); this.winStreakNode.getComponent("WinStreak").init(); } else { // 非第一次使用,直接激活节点 @@ -2038,7 +2049,8 @@ export default class JiaZai extends cc.Component { if (!this.winStreakNode) { // 第一次使用,创建节点 this.winStreakNode = cc.instantiate(JiaZai.cachedWinStreakPrefab); - this.node.addChild(this.winStreakNode); + if (this.node && this.winStreakNode) + this.node.addChild(this.winStreakNode); this.winStreakNode.active = true; this.winStreakNode.getComponent("WinStreak").init(); } else { @@ -2179,7 +2191,8 @@ export default class JiaZai extends cc.Component { if (!this.passCheckNode || !cc.isValid(this.passCheckNode)) { // 节点不存在或已被销毁,需要重新创建 this.passCheckNode = cc.instantiate(JiaZai.cachedPassCheckPrefab); - this.node.addChild(this.passCheckNode); + if (this.node && this.passCheckNode) + this.node.addChild(this.passCheckNode); this.passCheckNode.getComponent("passCheck").setInfo(passCheck); const hmScale = cc.fx.GameTool.adaptation(); if (hmScale == 1) return; @@ -2898,7 +2911,8 @@ export default class JiaZai extends cc.Component { } openRedeemCode() { let reddemCodeNode = cc.instantiate(this.reddemCodeNode); - this.node.addChild(reddemCodeNode); + if (this.node && reddemCodeNode) + this.node.addChild(reddemCodeNode); } update(dt) { diff --git a/assets/Script/RippleShrink.ts b/assets/Script/RippleShrink.ts index 573a4c1..4d3e06e 100644 --- a/assets/Script/RippleShrink.ts +++ b/assets/Script/RippleShrink.ts @@ -44,7 +44,7 @@ export default class RippleShrink extends cc.Component { } update(dt: number) { - if (!this.shouldShow && !this.running) { + if (!this.shouldShow && !this.running && this.node) { // 如果不需要显示且当前没有运行中的动画,则隐藏节点 if (this.node.active) { this.node.active = false; diff --git a/assets/Script/SceneManager.ts b/assets/Script/SceneManager.ts index 0842bfc..b1b462c 100644 --- a/assets/Script/SceneManager.ts +++ b/assets/Script/SceneManager.ts @@ -474,7 +474,8 @@ export default class SceneManager extends cc.Component { if (!this.shopNode) { // 第一次使用,创建节点 this.shopNode = cc.instantiate(SceneManager.cachedShopPrefab); - this.node.addChild(this.shopNode); + if (this.node && this.shopNode) + this.node.addChild(this.shopNode); this.shopNode.getComponent("shop").init(res.data.shopDouble); } else { // 非第一次使用,直接激活节点 @@ -513,7 +514,8 @@ export default class SceneManager extends cc.Component { if (!this.monthlyCardNode) { // 第一次使用,创建节点 this.monthlyCardNode = cc.instantiate(SceneManager.cachedMonthlyCardPrefab); - this.node.addChild(this.monthlyCardNode); + if (this.node && this.monthlyCardNode) + this.node.addChild(this.monthlyCardNode); this.monthlyCardNode.getComponent("monthlyCard").init(); this.monthlyCardNode.getComponent("monthlyCard").juwai = false; } else { @@ -562,7 +564,8 @@ export default class SceneManager extends cc.Component { if (!this.RewardNode) { // 第一次使用,创建节点 this.RewardNode = cc.instantiate(SceneManager.cachedRewardPrefab); - this.node.addChild(this.RewardNode); + if (this.node && this.RewardNode) + this.node.addChild(this.RewardNode); this.RewardNode.zIndex = 99; this.RewardNode.getComponent("Reward").init(data, callBack); } @@ -570,7 +573,8 @@ export default class SceneManager extends cc.Component { this.RewardNode.destroy(); this.RewardNode = null; this.RewardNode = cc.instantiate(SceneManager.cachedRewardPrefab); - this.node.addChild(this.RewardNode); + if (this.node && this.RewardNode) + this.node.addChild(this.RewardNode); this.RewardNode.zIndex = 99; this.RewardNode.getComponent("Reward").init(data, callBack); } diff --git a/assets/Script/lq_collide_system/lq_collide.ts b/assets/Script/lq_collide_system/lq_collide.ts index 2d5578b..6c2bd88 100644 --- a/assets/Script/lq_collide_system/lq_collide.ts +++ b/assets/Script/lq_collide_system/lq_collide.ts @@ -195,7 +195,7 @@ export class LQCollide extends Component { private checkDebugDrawValid() { if (!this._debugDrawer || !this._debugDrawer.isValid) { let node = this.node.getChildByName('Collide'); - if (!node) { + if (!node && this.node) { node = new Node('Collide'); node.zIndex = macro.MAX_ZINDEX; this.node.addChild(node); diff --git a/assets/action_bundle/script/DailyQuests.ts b/assets/action_bundle/script/DailyQuests.ts index dadae8e..e59da10 100644 --- a/assets/action_bundle/script/DailyQuests.ts +++ b/assets/action_bundle/script/DailyQuests.ts @@ -171,7 +171,7 @@ export default class DailyQuests extends cc.Component { }, 1000); } - //购买月卡 + //領取獎勵 openReward(name, res) { let data = null; if (name == "levelPass") { @@ -392,96 +392,96 @@ export default class DailyQuests extends cc.Component { } getAllReward() { - if (this.touchStart == false) { - return; - } - this.touchStart = false; - this.reward = true; - let shuju = []; - for (let i = 0; i < this.content.children.length; i++) { - let dataNode = this.content.children[i]; - if (dataNode.getChildByName("get").active == true) { - shuju.push(dataNode.name); - } - } - console.log("准备上传的任务", shuju); - Utils.getDailyQuestReward(shuju, (res) => { - this.touchStart = true; - this.reward = false; - if (res.code == 1) { - let data = [ - { type: "coin", count: 0 }, - { type: "freeze", count: 0 }, - { type: "hammer", count: 0 }, - { type: "magic", count: 0 }, - { type: "infinite_health", count: 0 }, - ] - for (let i = 0; i < this.content.children.length; i++) { - let dataNode = this.content.children[i]; - if (dataNode.getChildByName("get").active == true) { - dataNode.getChildByName("get").active = false; - if (dataNode.name == "levelPass") { - data[0].count += 100; - data[1].count += 2; - let data2 = { - id: 0, - status: "claim" - } - cc.fx.GameTool.shushu_Track("daily_task", data2); - } - else if (dataNode.name == "useProp") { - data[2].count += 1; - let data2 = { - id: 3, - status: "claim" - } - cc.fx.GameTool.shushu_Track("daily_task", data2); - } - else if (dataNode.name == "useEnergy") { - data[0].count += 100; - data[3].count += 1; - let data2 = { - id: 2, - status: "claim" - } - cc.fx.GameTool.shushu_Track("daily_task", data2); - } - else if (dataNode.name == "share") { - data[4].count += 900; - let data2 = { - id: 1, - status: "claim" - } - cc.fx.GameTool.shushu_Track("daily_task", data2); - } - cc.tween(dataNode) - .to(0.4, { x: dataNode.x - 1000, opacity: 50 }) - .call(() => { - this.touchStart = true; - dataNode.removeFromParent(); - this.content.getComponent(cc.Layout).updateLayout(); - this.checkGetReward(); - }) - .start(); - } - } - for (let j = 0; j < data.length; j++) { - if (data[j].count == 0) { - data.splice(j, 1); - j--; - } - } - this.openReward("all", data); - } - else { - MiniGameSdk.API.showToast("网络异常,领取奖励失败"); - } - }) - setTimeout(() => { - if (this.reward == true && this.touchStart == false) { - this.touchStart = true; - } - }, 5000); + // if (this.touchStart == false) { + // return; + // } + // this.touchStart = false; + // this.reward = true; + // let shuju = []; + // for (let i = 0; i < this.content.children.length; i++) { + // let dataNode = this.content.children[i]; + // if (dataNode.getChildByName("get").active == true) { + // shuju.push(dataNode.name); + // } + // } + // console.log("准备上传的任务", shuju); + // Utils.getDailyQuestReward(shuju, (res) => { + // this.touchStart = true; + // this.reward = false; + // if (res.code == 1) { + // let data = [ + // { type: "coin", count: 0 }, + // { type: "freeze", count: 0 }, + // { type: "hammer", count: 0 }, + // { type: "magic", count: 0 }, + // { type: "infinite_health", count: 0 }, + // ] + // for (let i = 0; i < this.content.children.length; i++) { + // let dataNode = this.content.children[i]; + // if (dataNode.getChildByName("get").active == true) { + // dataNode.getChildByName("get").active = false; + // if (dataNode.name == "levelPass") { + // data[0].count += 100; + // data[1].count += 2; + // let data2 = { + // id: 0, + // status: "claim" + // } + // cc.fx.GameTool.shushu_Track("daily_task", data2); + // } + // else if (dataNode.name == "useProp") { + // data[2].count += 1; + // let data2 = { + // id: 3, + // status: "claim" + // } + // cc.fx.GameTool.shushu_Track("daily_task", data2); + // } + // else if (dataNode.name == "useEnergy") { + // data[0].count += 100; + // data[3].count += 1; + // let data2 = { + // id: 2, + // status: "claim" + // } + // cc.fx.GameTool.shushu_Track("daily_task", data2); + // } + // else if (dataNode.name == "share") { + // data[4].count += 900; + // let data2 = { + // id: 1, + // status: "claim" + // } + // cc.fx.GameTool.shushu_Track("daily_task", data2); + // } + // cc.tween(dataNode) + // .to(0.4, { x: dataNode.x - 1000, opacity: 50 }) + // .call(() => { + // this.touchStart = true; + // dataNode.removeFromParent(); + // this.content.getComponent(cc.Layout).updateLayout(); + // this.checkGetReward(); + // }) + // .start(); + // } + // } + // for (let j = 0; j < data.length; j++) { + // if (data[j].count == 0) { + // data.splice(j, 1); + // j--; + // } + // } + // this.openReward("all", data); + // } + // else { + // MiniGameSdk.API.showToast("网络异常,领取奖励失败"); + // } + // }) + // setTimeout(() => { + // if (this.reward == true && this.touchStart == false) { + // this.touchStart = true; + // } + // }, 5000); } checkGetReward() { @@ -505,7 +505,7 @@ export default class DailyQuests extends cc.Component { //@ts-ignore if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) { const num = 0; - //console.log("_________道具增加的数量为:", num); + console.log("_________道具增加的数量为:", num); cc.fx.GameConfig.GM_INFO.freezeAmount += propData.freeze; cc.fx.GameConfig.GM_INFO.hammerAmount += propData.hammer; cc.fx.GameConfig.GM_INFO.magicAmount += propData.magic_wand; @@ -539,7 +539,4 @@ export default class DailyQuests extends cc.Component { } - update() { - - } } diff --git a/assets/action_bundle/script/NewbieGift.ts b/assets/action_bundle/script/NewbieGift.ts index dc8ab62..bf6951d 100644 --- a/assets/action_bundle/script/NewbieGift.ts +++ b/assets/action_bundle/script/NewbieGift.ts @@ -535,7 +535,5 @@ export default class NewbieGift extends cc.Component { } - update() { - } } diff --git a/assets/action_bundle/script/WinStreak.ts b/assets/action_bundle/script/WinStreak.ts index 8290bfd..1c5079e 100644 --- a/assets/action_bundle/script/WinStreak.ts +++ b/assets/action_bundle/script/WinStreak.ts @@ -155,7 +155,5 @@ export default class WinStreak extends cc.Component { } } - update() { - } } diff --git a/assets/shop/script/passCheck.ts b/assets/shop/script/passCheck.ts index ad7129e..d1ce0fb 100644 --- a/assets/shop/script/passCheck.ts +++ b/assets/shop/script/passCheck.ts @@ -709,8 +709,8 @@ export default class passCheck extends cc.Component { butActivate.getComponent("buyActivate").init(() => { this.onBuyActivate(); }, timeStr); - - this.node.addChild(butActivate); + if (this.node && butActivate) + this.node.addChild(butActivate); } }