|
@@ -247,12 +247,11 @@ export class LevelAction extends Component {
|
|
await this.pourAnimation(
|
|
await this.pourAnimation(
|
|
originCup.node,
|
|
originCup.node,
|
|
targetNode,
|
|
targetNode,
|
|
- color,
|
|
|
|
undefined,
|
|
undefined,
|
|
targetIsTemp
|
|
targetIsTemp
|
|
);
|
|
);
|
|
|
|
|
|
- originCup.fillWater();
|
|
|
|
|
|
+ originCup.pourWater();
|
|
// 更新目标杯
|
|
// 更新目标杯
|
|
if (targetIsTemp) {
|
|
if (targetIsTemp) {
|
|
const tempCupComp = targetNode.getComponent(TempCup)!;
|
|
const tempCupComp = targetNode.getComponent(TempCup)!;
|
|
@@ -294,30 +293,38 @@ export class LevelAction extends Component {
|
|
for (const tempCup of filledCups) {
|
|
for (const tempCup of filledCups) {
|
|
const originalPos = tempCup.node.position.clone();
|
|
const originalPos = tempCup.node.position.clone();
|
|
const colors = tempCup.getColors();
|
|
const colors = tempCup.getColors();
|
|
- let hasProcessed = false; // 标记是否有处理过颜色
|
|
|
|
|
|
|
|
for (const color of colors) {
|
|
for (const color of colors) {
|
|
const targetCup = this.findTargetCupInOutArea(color);
|
|
const targetCup = this.findTargetCupInOutArea(color);
|
|
if (!targetCup) {
|
|
if (!targetCup) {
|
|
- console.log(`颜色${WaterColors[color]}未找到可用调酒杯`);
|
|
|
|
|
|
+ // console.log(`颜色${WaterColors[color]}未找到可用调酒杯`);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
await this.pourAnimation(
|
|
await this.pourAnimation(
|
|
tempCup.node,
|
|
tempCup.node,
|
|
targetCup.node,
|
|
targetCup.node,
|
|
- color,
|
|
|
|
originalPos,
|
|
originalPos,
|
|
true
|
|
true
|
|
);
|
|
);
|
|
|
|
|
|
|
|
+ tempCup.pour();
|
|
const cocktailCup = targetCup.comp;
|
|
const cocktailCup = targetCup.comp;
|
|
await cocktailCup.addLayer();
|
|
await cocktailCup.addLayer();
|
|
- hasProcessed = true; // 标记已处理
|
|
|
|
- }
|
|
|
|
- // 仅当有处理过颜色时才重置暂存杯
|
|
|
|
- if (hasProcessed) {
|
|
|
|
- tempCup.reset();
|
|
|
|
|
|
+
|
|
|
|
+ await GameUtil.delay(0.2);
|
|
|
|
+ // 返回到暂存区初始位置
|
|
|
|
+ if (originalPos) {
|
|
|
|
+ await new Promise(resolve => {
|
|
|
|
+ tween(tempCup.node)
|
|
|
|
+ .to(0.3, { position: originalPos })
|
|
|
|
+ .call(() => {
|
|
|
|
+ tempCup.reset();
|
|
|
|
+ resolve(true);
|
|
|
|
+ })
|
|
|
|
+ .start();
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
} finally {
|
|
@@ -381,11 +388,15 @@ export class LevelAction extends Component {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //倒水移动动画
|
|
|
|
|
|
+ /** 倒水移动动画
|
|
|
|
+ * @param origin 原杯子
|
|
|
|
+ * @param target 目标杯子
|
|
|
|
+ * @param originalPos 原始位置
|
|
|
|
+ * @param isTempCup 是否是暂存区杯子
|
|
|
|
+ */
|
|
private async pourAnimation(
|
|
private async pourAnimation(
|
|
origin: Node,
|
|
origin: Node,
|
|
target: Node,
|
|
target: Node,
|
|
- color: WaterColors,
|
|
|
|
originalPos?: Vec3,
|
|
originalPos?: Vec3,
|
|
isTempCup: boolean = false
|
|
isTempCup: boolean = false
|
|
) {
|
|
) {
|
|
@@ -403,9 +414,6 @@ export class LevelAction extends Component {
|
|
localPos.y += 100;
|
|
localPos.y += 100;
|
|
}
|
|
}
|
|
|
|
|
|
- //播放动画
|
|
|
|
- origin.getComponent(OriginCup)?.playAnimation(OriginCupState.Up);
|
|
|
|
-
|
|
|
|
// 移动动画到目标位置
|
|
// 移动动画到目标位置
|
|
await new Promise<void>(resolve => {
|
|
await new Promise<void>(resolve => {
|
|
tween(origin)
|
|
tween(origin)
|
|
@@ -413,26 +421,6 @@ export class LevelAction extends Component {
|
|
.call(resolve)
|
|
.call(resolve)
|
|
.start();
|
|
.start();
|
|
});
|
|
});
|
|
-
|
|
|
|
- // 返回到暂存区初始位置
|
|
|
|
- if (isTempCup && originalPos) {
|
|
|
|
- await new Promise(resolve => {
|
|
|
|
- tween(origin)
|
|
|
|
- .to(0.3, { position: originalPos })
|
|
|
|
- .call(resolve)
|
|
|
|
- .start();
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //隐藏原浆杯当前水层 等待倒水动画
|
|
|
|
- private async hideCurrentWaterLayer(originCup: OriginCup) {
|
|
|
|
- const activeWaters = originCup.waters.children.filter(n => n.active);
|
|
|
|
- const topIndex = originCup.waters.children.length - activeWaters.length;
|
|
|
|
- if (activeWaters.length >= 0) {
|
|
|
|
- originCup.getComponent(OriginCup)?.playAnimation(OriginCupState.PourWater, topIndex + 1);
|
|
|
|
- activeWaters[activeWaters.length - 1].active = false;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private async spawnNewOriginCup(targetPos: Vec3) {
|
|
private async spawnNewOriginCup(targetPos: Vec3) {
|