# Conflicts:
#	assets/Scene/GameScene.fire
#	assets/TextureBlock/block/down.png.meta
This commit is contained in:
YZ\249929363 2025-07-22 18:31:59 +08:00
commit 232663a79c
4 changed files with 2662 additions and 2350 deletions

File diff suppressed because it is too large Load Diff

View File

@ -457,6 +457,7 @@ export default class Block extends cc.Component {
// console.log("方块层级",this.node.zIndex);
this.node.x = mapBlock.x + 65;
this.node.y = mapBlock.y - 60;
if (this.type == 9) {
if (this.block_Info.node) {
this.block_Info.node.x = this.node.x - this.adhesive.x;
@ -746,25 +747,130 @@ export default class Block extends cc.Component {
eliminate() {
//锤子状态消失
MapConroler._instance.pause = true;
if (MapConroler._instance.hammer == true) MapConroler._instance.hammer = false;
//如果方块是有特殊状态,则特殊处理
if (this.type == BlockType.) {
console.log(this.node.x, this.node.y, 'weizhi', this.node)
if (MapConroler._instance.ishammer || MapConroler._instance.ismagic) {
}
if (MapConroler._instance.ishammer == true) {
let parentSize = this.node.getContentSize();
console.log("锤子状态消除", this.node.position);
let pos = cc.v3(0, 0, 0)
if (this.node.anchorX == 1) {
pos = cc.v3(this.node.position.x - parentSize.width / 2,
this.node.position.y + parentSize.height / 2, 0)
} else if (this.node.anchorX == 0.5) {
pos = cc.v3(this.node.position.x,
this.node.position.y + parentSize.height / 2, 0)
} else if (this.node.anchorX == 0.33) {
pos = cc.v3(this.node.position.x + parentSize.width / 4,
this.node.position.y + parentSize.height / 2, 0)
} else if (this.node.anchorX == 0.66) {
pos = cc.v3(this.node.position.x - parentSize.width / 6,
this.node.position.y + parentSize.height / 2, 0)
}
MapConroler._instance.startHammer(pos);
setTimeout(() => {
if (this.type == BlockType.) {
this.node.getChildByName("freeze").getComponent("Freeze").reduce(2);
MapConroler._instance.ishammer = false;
return;
}
else if (this.type == BlockType.) {
MapConroler._instance.ishammer = false;
this.node.getChildByName("lock").getComponent("Lock").reduce();
return;
}
}, 1800);
}
if (MapConroler._instance.ismagic) {
setTimeout(() => {
// 记录添加magic时的锚点
this.node.anchorX = 0.5;
this.node.anchorY = 0.5;
this.node.addChild(new cc.Node("magic"));
let effectNode = this.node.getChildByName("magic");
effectNode.setPosition(0, 0);
// 改锚点后修正magic的位置
this.node.anchorX = 1;
this.node.anchorY = 0;
// 重新设置magic的位置使其视觉上不变
let parentSize = this.node.getContentSize();
effectNode.setPosition(
effectNode.x + parentSize.width * (0.5 - 1),
effectNode.y + parentSize.height * (0.5 - 0)
);
switch (this.node.name) {
case "block14":
this.node.anchorX = 0.66;
this.node.anchorY = 0;
effectNode.setPosition(-50, 120);
break;
case "block18":
this.node.anchorX = 0.66;
this.node.anchorY = 0;
effectNode.setPosition(-50, 200);
break;
case "block10":
effectNode.setPosition(0, 200);
break;
case "block21":
effectNode.setPosition(0, 130);
break;
case "block16":
effectNode.setPosition(0, 180);
break;
default:
break;
}
effectNode.zIndex = 1000;
effectNode.addComponent(sp.Skeleton);
effectNode.getComponent(sp.Skeleton).skeletonData = this.magic_SkeletonData;
effectNode.getComponent(sp.Skeleton).setAnimation(0, "play", false);
if (this.type == BlockType.) {
this.node.getChildByName("freeze").getComponent("Freeze").reduce(2);
MapConroler._instance.ismagic = false;
return;
}
else if (this.type == BlockType.) {
MapConroler._instance.ismagic = false;
this.node.getChildByName("lock").getComponent("Lock").reduce();
return;
}
}, 1800);
}
if (this.type == BlockType. && (!MapConroler._instance.ishammer && !MapConroler._instance.ismagic)) {
this.node.getChildByName("freeze").getComponent("Freeze").reduce(2);
return;
}
else if (this.type == BlockType.) {
else if (this.type == BlockType. && (!MapConroler._instance.ishammer && !MapConroler._instance.ismagic)) {
this.node.getChildByName("lock").getComponent("Lock").reduce();
return;
}
//如果方块可以消除
MapConroler._instance.blockNum -= 1;
MapConroler._instance.special_Treatment(this.node);
var self = this;
this.removeMapBlock();
MapConroler._instance.judgeWin(1);
//如果方块是有特殊状态,则特殊处理
let time = 1200;
let time2 = 2000;
let tim = 200;
if (MapConroler._instance.ishammer) {
tim = time
} else if (MapConroler._instance.ismagic) {
tim = time2
}
if (MapConroler._instance.hammer == true) MapConroler._instance.hammer = false;
setTimeout(() => {
//如果方块可以消除
MapConroler._instance.blockNum -= 1;
MapConroler._instance.special_Treatment(this.node);
var self = this;
this.removeMapBlock();
MapConroler._instance.judgeWin(1);
let pos = this.node.getPosition();
if (self.type == BlockType.) {
let scaleX = self.node.scaleX;
@ -786,63 +892,11 @@ export default class Block extends cc.Component {
this.node.active = false;
this.node.removeFromParent();
//如果是锤子状态消除
MapConroler._instance.ishammer = false;
MapConroler._instance.ismagic = false;
}, tim);
}, 200);
// console.log("消除", this.node.name, this.node.children);
// //延时1.8秒
// setTimeout(() => {
// if (!MapConroler._instance.ishammer) {
// // 记录添加magic时的锚点
// this.node.anchorX = 0.5;
// this.node.anchorY = 0.5;
// this.node.addChild(new cc.Node("magic"));
// let effectNode = this.node.getChildByName("magic");
// effectNode.setPosition(0, 0);
// // 改锚点后修正magic的位置
// this.node.anchorX = 1;
// this.node.anchorY = 0;
// // 重新设置magic的位置使其视觉上不变
// let parentSize = this.node.getContentSize();
// effectNode.setPosition(
// effectNode.x + parentSize.width * (0.5 - 1),
// effectNode.y + parentSize.height * (0.5 - 0)
// );
// switch (this.node.name) {
// case "block14":
// this.node.anchorX = 0.66;
// this.node.anchorY = 0;
// effectNode.setPosition(-50, 120);
// break;
// case "block18":
// this.node.anchorX = 0.66;
// this.node.anchorY = 0;
// effectNode.setPosition(-50, 200);
// break;
// case "block10":
// effectNode.setPosition(0, 200);
// break;
// case "block21":
// effectNode.setPosition(0, 130);
// break;
// case "block16":
// effectNode.setPosition(0, 180);
// break;
// default:
// break;
// }
// effectNode.addComponent(sp.Skeleton);
// effectNode.getComponent(sp.Skeleton).skeletonData = this.magic_SkeletonData;
// effectNode.getComponent(sp.Skeleton).setAnimation(0, "play", false);
// }
// }, 1800);
// MapConroler._instance.ishammer = false;
}
setVibrate(type, count) {
@ -955,6 +1009,7 @@ export default class Block extends cc.Component {
initBlocks() {
this.allBlocks = [];
switch (this.block_Info.block) {
case 0:
let pos = cc.v2(0, 0);

View File

@ -68,8 +68,11 @@ export default class ItemGuide extends cc.Component {
// if (this.itemGuide.active == true) {
cc.tween(this.itemGuide)
.to(1.3, { scale: 0.3, position: pos }) // 同时执行
.call(() => { this.node.active = false; })
.to(0.9, { scale: 0.3, position: pos }) // 同时执行
.call(() => {
MapConroler._instance.setPropNum();
this.node.active = false;
})
.start();
// }

View File

@ -82,6 +82,8 @@ export default class MapConroler extends cc.Component {
freezeMask: cc.Node = null;
@property(cc.Node)
guideNode: cc.Node = null;
@property(cc.Node)
hammerAni: cc.Node = null;
@property(cc.Node)
coinPop: cc.Node = null;
@ -118,6 +120,7 @@ export default class MapConroler extends cc.Component {
pause: boolean = false;//暂停状态
hammer: boolean = false;//锤子状态
ishammer: boolean = false;//魔法棒与锤子区分
ismagic: boolean = false;//魔法棒状态
freezeArray: any; //冻结
loackArray: any; //上锁
particleEffects: cc.ParticleAsset[];
@ -358,6 +361,7 @@ export default class MapConroler extends cc.Component {
this.pause = false;
this.hammer = false;
this.ishammer = false;
this.ismagic = false;
this.wallNum = 0;
this.setMapInfo();
this.blocks = [];
@ -2160,15 +2164,282 @@ export default class MapConroler extends cc.Component {
magicBtn.getComponent("btnControl").setTouch(true);
}, 1000);
// this.magics.active = true;
// this.magics.getComponent(sp.Skeleton).setAnimation(1, "play", false);
// //监听播放完后节点隐藏
// this.magics.getComponent(sp.Skeleton).setCompleteListener((entry) => {
// if (entry.animation.name === "play") {
// // 动画播放结束后执行的逻辑
// this.magics.active = false;
// }
// });
//魔法棒
this.ismagic = true;
this.magics.active = true;
const path = [
{
"x": -522.8444229452174,
"y": -758.2125792877125,
"z": 0
},
{
"x": -499.7565369594692,
"y": -775.5284937770236,
"z": 0
},
{
"x": -488.2125939665951,
"y": -784.1864510216792,
"z": 0
},
{
"x": -447.8087934915357,
"y": -789.9584225181162,
"z": 0
},
{
"x": -407.4049930164763,
"y": -798.6163797627719,
"z": 0
},
{
"x": -355.4572495485428,
"y": -810.1603227556459,
"z": 0
},
{
"x": -271.76366285020555,
"y": -821.70426574852,
"z": 0
},
{
"x": -199.61401914474237,
"y": -821.70426574852,
"z": 0
},
{
"x": -101.49050370531245,
"y": -821.70426574852,
"z": 0
},
{
"x": -23.568888503412154,
"y": -821.70426574852,
"z": 0
},
{
"x": 37.0368122091769,
"y": -815.932294252083,
"z": 0
},
{
"x": 88.9845556771104,
"y": -801.5023655109903,
"z": 0
},
{
"x": 129.38835615216976,
"y": -775.5284937770236,
"z": 0
},
{
"x": 178.4501138718847,
"y": -752.4406077912754,
"z": 0
},
{
"x": 215.9679285987255,
"y": -738.0106790501827,
"z": 0
},
{
"x": 244.82778608091087,
"y": -723.5807503090901,
"z": 0
},
{
"x": 267.915672066659,
"y": -703.3788500715605,
"z": 0
},
{
"x": 316.97742978637405,
"y": -683.1769498340307,
"z": 0
},
{
"x": 348.72327301677785,
"y": -662.9750495965011,
"z": 0
},
{
"x": 360.26721600965186,
"y": -648.5451208554084,
"z": 0
},
{
"x": 374.69714475074454,
"y": -625.4572348696602,
"z": 0
},
{
"x": 386.24108774361866,
"y": -605.2553346321305,
"z": 0
},
{
"x": 389.1270734918372,
"y": -587.9394201428194,
"z": 0
},
{
"x": 394.8990449882742,
"y": -561.9655484088526,
"z": 0
},
{
"x": 400.67101648471134,
"y": -521.5617479337932,
"z": 0
},
{
"x": 406.44298798114835,
"y": -478.2719617105153,
"z": 0
},
{
"x": 406.44298798114835,
"y": -434.98217548723744,
"z": 0
},
{
"x": 406.44298798114835,
"y": -397.4643607603965,
"z": 0
},
{
"x": 403.5570022329298,
"y": -359.9465460335557,
"z": 0
},
{
"x": 394.8990449882742,
"y": -328.2007028031519,
"z": 0
},
{
"x": 386.24108774361866,
"y": -299.34084532096665,
"z": 0
},
{
"x": 377.5831304989631,
"y": -264.7090163423443,
"z": 0
},
{
"x": 360.26721600965186,
"y": -227.19120161550347,
"z": 0
},
{
"x": 340.0653157721222,
"y": -198.33134413331823,
"z": 0
},
{
"x": 308.31947254171837,
"y": -163.69951515469586,
"z": 0
},
{
"x": 270.80165781487756,
"y": -137.72564342072906,
"z": 0
},
{
"x": 236.1698288362552,
"y": -126.18170042785505,
"z": 0
},
{
"x": 187.10807111654026,
"y": -117.52374318319937,
"z": 0
},
{
"x": 138.04631339682533,
"y": -117.52374318319937,
"z": 0
},
{
"x": 112.07244166285852,
"y": -117.52374318319937,
"z": 0
},
{
"x": 94.7565271735474,
"y": -117.52374318319937,
"z": 0
},
{
"x": 83.21258418067328,
"y": -126.18170042785505,
"z": 0
},
{
"x": 54.35272669848803,
"y": -146.38360066538473,
"z": 0
},
{
"x": 39.922797957395346,
"y": -155.0415579100403,
"z": 0
},
{
"x": 28.378854964521338,
"y": -169.47148665113286,
"z": 0
},
{
"x": 19.72089771986566,
"y": -189.67338688866255,
"z": 0
},
{
"x": 13.948926223428657,
"y": -215.64725862262935,
"z": 0
},
{
"x": 13.948926223428657,
"y": -232.96317311194048,
"z": 0
},
{
"x": 13.948926223428657,
"y": -253.16507334947016,
"z": 0
}
]
// 转换为 cc.v3 数组
const pts = path.map(point => cc.v3(point.x, point.y, point.z));
const totalDur = 0.9; // 总时长
const smoothPts = this.getSmoothPath(pts, 10); // 40像素圆滑半径可调整
this.magics.setPosition(smoothPts[0]);
let totalLen = 0;
let lens: number[] = [];
for (let i = 1; i < smoothPts.length; i++) {
const len = smoothPts[i].sub(smoothPts[i - 1]).mag();
lens.push(len);
totalLen += len;
}
let t = cc.tween(this.magics);
for (let i = 1; i < smoothPts.length; i++) {
const segDur = totalDur * (lens[i - 1] / totalLen);
t = t.to(segDur, { position: smoothPts[i] });
}
t.
delay(0.5).call(() => { this.magics.active = false; }) // 播完隐藏
.start();
cc.fx.GameConfig.GM_INFO.magicAmount -= 1;
if (cc.fx.GameConfig.GM_INFO.magicAmount < 0)
@ -2419,6 +2690,41 @@ export default class MapConroler extends cc.Component {
}
}
getSmoothPath(pts: cc.Vec3[], radius = 10): cc.Vec3[] {
if (pts.length < 3) return pts.slice();
const smoothPts: cc.Vec3[] = [pts[0]];
for (let i = 1; i < pts.length - 1; i++) {
const prev = pts[i - 1];
const curr = pts[i];
const next = pts[i + 1];
// 方向向量
const dir1 = curr.sub(prev).normalize();
const dir2 = next.sub(curr).normalize();
// 计算前后过渡点
const before = curr.sub(dir1.mul(radius));
const after = curr.add(dir2.mul(radius));
smoothPts.push(before);
smoothPts.push(curr);
smoothPts.push(after);
}
smoothPts.push(pts[pts.length - 1]);
return smoothPts;
}
startHammer(pos: cc.Vec3) {
this.hammerAni.active = true;
this.hammerAni.scale = 0.5;
this.hammerAni.position = cc.v3(-116, -800);
this.hammerAni.setPosition(this.hammerAni.position);
this.hammerAni.zIndex = 1000;
cc.tween(this.hammerAni)
.to(0.9, { position: pos, scale: 1.2 })
.call(() => {
this.hammerAni.active = false;
this.hammerAni.scale = 0.5;
})
.start();
}
update(dt) {